1

I am trying to figure out how to conveniently pause all consumers/message-listeners, while my application is in controlled maintenance mode. The application is using ActiveMQ 5.13.3 client libraries.

Some time ago I have switched from a single ActiveMQConnectionFactory to a PooledConnectionFactory. It is being setup like so:

ActiveMQConnectionFactory amcf = new ActiveMQConnectionFactory(config.getMessageBrokerUrl());
amcf.setTrustedPackages(Arrays.asList(new String[] {
    "some.package.or.other",
    "java.lang",
    "java.util"
}));

connectionFactory = new PooledConnectionFactory(amcf);
connectionFactory.setCreateConnectionOnStartup(true);

Consumers and producers "create" (= fetch) a connection from the connection pool and "close" it when they are done, returning it to the pool. Obviously in the case of MessageListeners, it is obtained once at startup and returned on application shutdown.

ActiveMQConnection.stop() says it Temporarily stops a connection's delivery of incoming messages. Perfect for what I want, only the pool obviously contains many connections, not just one.

How do you pause all connections of an ActiveMQ connection pool?

Hank
  • 4,597
  • 5
  • 42
  • 84

1 Answers1

0

I guess you have to resort to other means of pausing the message delivery using pooled connection pools. See this question for example when using spring DMLC (may not be the case for you): Start and Stop JMS Listener using Spring

You can also pause that queue from the broker side. There is a pause/resume operation on the JMX MBean of the queue. See attached screenshot.

It does not answer the question about pausing the client, but may solve your problem.

pause queue jmx operation in jconsole

Community
  • 1
  • 1
Petter Nordlander
  • 22,053
  • 5
  • 50
  • 84
  • Thanks. Pausing the queue is no solution for me, other clients shall still be communicating over it. The use case is controlled shutdown of individual nodes of a cluster. I'll look into stopping the messageListeners rather than the connection. – Hank Sep 28 '16 at 07:29