0

Let's suppose I have several subscribers consuming from a topic. After a message has been delivered to all the subscribers I'd like to trigger a job that would use this message in input.

So the easy way to do that would be to move messages that have been succesfully delivered to all the sucscribers to a queue from which my job would consume messages. Is it part of JMS?

Is there any message broker able to do that directly?

If not is there a simple solution to solve this problem?

R3DL
  • 219
  • 2
  • 8

2 Answers2

1

You should be able to do this using activemq's advisories.

See here for more about advisory messages: http://activemq.apache.org/advisory-message.html

So what you want to do, for the topic in question, is track:

  • the number of consumers
  • when a message is dispatched to them
  • when the message has been ack'd by each of the consumers

to get the number of consumers, listen to the "ActiveMQ.Advisory.Consumer.Topic." advisory topic

to get when a message is dispatched, listen to the "ActiveMQ.Advisory.MessageDelivered.Topic."

to get when a message has been ack'd, listen to "ActiveMQ.Advisory.MessageConsumed.Topic."

you could easily use Apache Camel to help out with this (listening to the topics) and aggregating whether or not all consumers have processed (ack'd) the message.. then that could kick off your further processing..

ceposta
  • 436
  • 3
  • 7
0

You could just create another durable subscription to route the message from the topic to queue directly. From that queue your job can consume messages. This is much easier than creating a trigger to route the messages to a queue.

So the easy way to do that would be to move messages that have been succesfully delivered to all the sucscribers to a queue from which my job would consume messages. Is it part of JMS?

No, this is not part of JMS specification.

Shashi
  • 14,980
  • 2
  • 33
  • 52
  • To clarify, I need the job to run after all the subscribers succesfully consumed (and processed) the message. In that scenario I assume that the subscribers ackowledge the message only after they processed it. The job I'm talking could be for example a process logging something like "the message [messID] has been consumed by everyone" – R3DL Oct 30 '13 at 14:58
  • There are some questions that need to be answers here. Is the number of subscribers fixed? If yes then you can use a one of the queue for coordinating between all your subscribes. When the last subscriber processes a message your job can go ahead process the message using the way I mentioned in my above answer. If the number of subscribers is not fixed then coordination may not be possible. – Shashi Oct 31 '13 at 02:42