Failed to send event with message "Server has been disposed" but the server keeps accepting other events
Solution 1:
When the exception message say, "Server has been disposed," it's not talking about the entire instance of ActiveMQ. It's only talking about the instance of the org.apache.activemq.transport.vm.VMTransportServer
the client is using to make a VM connection to the broker. I recommend you activate DEBUG logging for org.apache.activemq.transport.vm.VMTransportFactory
. That might shed some light on what's happening behind the scenes.
Aside from that, I strongly recommend that you change the way you're using the JMSTemplate to send messages. As the documentation states:
The thing to remember is JmsTemplate is designed for use in EJBs using the EJB containers JMS pooling abstraction. So every method will typically create a connection, session, producer or consumer, do something, then close them all down again. The idea being that this will use the J2EE containers pooling mechanism to pool the JMS resources under the covers. Without using a pooled JMS provider from the EJB container this is the worst possible way of working with JMS; since typically each create/close of a connection, producer/consumer results in a request-response with the JMS broker.
Instead of creating and passing an instance of ActiveMQConnectionFactory
directly to the JMSTemplate I recommend you use a single instance of a pooled connection factory implementation.