We are using spring integration/spring batch job to run jobs within multiple jboss nodes connected to the common ActiveMQ queue. We have configured auto startup as false for inbound gateway listening to the queue/channel. Problem with auto-start as true is that if inbound gateway has more concurrent consumers property, then those many number of consumer threads would be active in all nodes started during server startup even through frequency of the job requiring these consumer threads is very rare. In this scenario, spring batch job gets triggered in one of the 4 nodes. We can make use of control bus to start inbound gateway component when the job starts, it works for the same JVM. But in the worker nodes ( running in different JVM), how do we send the control bus message to start the inbound gateway component so that they start consuming the message put by the triggering job ?
Asked
Active
Viewed 138 times
1 Answers
1
The Control Bus is just an endpoint to consume messages from it input channel. The channel could be an in-memory one, or distributed, based on some shared store. For example, the mention ActiveMQ is just a JMS vendor, so you can use a JMS Inbound Endpoint to consume command messages from ActiveMQ topic and produce it to that Control Bus input channel: https://docs.spring.io/spring-integration/docs/current/reference/html/jms.html#jms-message-driven-channel-adapter

Artem Bilan
- 113,505
- 11
- 91
- 118
-
This is exactly what we tried ( i.e using ActiveMq topic to send the message for control bus to start inbound gateway on all subscribers ( 4 nodes or jvms ) ). But imagine a case where one of the VM goes down after processing, when it comes back again, it would not start its inbound gateway until another topic message is received from the triggering node or VM. Basically in that case, we would run with 3 VM's even though 4 servers are available. – rockycres Nov 10 '21 at 06:06
-
1Then you need to have a durable subscription: https://activemq.apache.org/how-do-durable-queues-and-topics-work. There is such an option on the mentioned JMS Message Driven Endpoint. – Artem Bilan Nov 10 '21 at 12:14
-
Able to achieve the outcome 1. By auto-start as true ( default ) on inbound gateway 2. by setting max-concurrent-consumers to a higher value , leaving concurrent-consumers as 1 (default). 3. When the job finishes, send a durable topic message to subscribers to stop the inbound gateway so that all consumer threads are released once the job completes. – rockycres Nov 11 '21 at 22:02
-
clicked on submit button too soon.. can you check my edited response on the solution ? – rockycres Nov 11 '21 at 22:06
-
Sounds good. Is anything wrong with that? What doubts do you have yet? – Artem Bilan Nov 11 '21 at 22:08
-
No all good..no more questions.. thanks for your assistance. – rockycres Nov 11 '21 at 22:11