Pergunta

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?

Foi útil?

Solução

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..

Outras dicas

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top