E.S.
E.S.

Reputation: 2841

Make sure the broker holds messages until at least one consumer gets it

I am begining to implement an ActiveMQ based messaging service to send worker tasks to various servers, however I am noticing that in the default mode, if no one is "listening" to a producer's topic, any message from that producer will be lost.

I.e.,

I would like instead for the Broker to hold on to messages until at least one listener receives it.

I am trying a couple ways of implementing this, but not sure on the most optimal/right way way:

Ideally, there is a mode to send a (or a set of) messages, and after sending a Boolean is returned stating if the message(s) were listened by at least one consumer.

Upvotes: 2

Views: 273

Answers (2)

Beryllium
Beryllium

Reputation: 12988

Transactions and acknowlegdement conflict somehow with the general idea of a JMS topic.

Just use a queue instead of a topic. Access this queue using CLIENT_ACKNOWLEDGE or a transacted session. A worker task is to be processed by one worker only anyway, so the queue solves another problem.


If there was a special reason to use topics, you could consider a message driven bean (MDB) on the same host like the JMS provider (you could achieve this by using JBoss with its integrated HornetQ for example), but this is still not really correct.

Another possibility is to have both a topic and a queue. The latter is only for guaranteed delivery of each message.

Upvotes: 1

jtahlborn
jtahlborn

Reputation: 53674

This isn't really a typical messaging pattern. Typically, you have one receiver and a durable queue or multiple receivers with durable subscriptions to a topic. in either situation, each receiver will always receive the message. i don't really understand a use case where "at least one" receiver should receive it.

and yes, transactions only deal with the interactions between client and broker, not between client and eventual receiver(s).

Upvotes: 0

Related Questions