Question

I have a simple scenario, where publisher(my java application) publish the message on topic. 50 clients have subscribed on same JMS topic.As soon as message is published on topic, all the 50 subscriber will be notified .Say only one subscriber(0ut 0f 50) process the message and send the acknowledgement after processing.(Once this client processing is done, i can see the message as consumed on apache MQ console. Otherwise if no client sends the acknowledgment after receiving the message i see the message as pending message).

Now question is once any client sends the acknowledgment and any new client subscribe on topic, will he be notified about the message ? or it works in a way where message has been consumed by any of the client (which internally means acknowledgment has been sent by any of the client), no further notification will be sent to any new subscriber and message will be taken off from the Topic(This is the behaviuor i am experiencing but looks like it should not work in this fashion as per as per Publish/subscribe model under http://en.wikipedia.org/wiki/Java_Message_Service )?

Was it helpful?

Solution

I have not worked with Apache MQ. But in general:

In a Publish/Subscribe model, when a message is published, all subscribers will receive that publication.

Acknowledgement by subscribers is only to messaging providers and not to the publisher. When a subscriber acknowledges the receipt of a message, that message is removed by the messaging provider so that the message is not delivered again.

If a new subscriber comes in after a message is published on a topic, then the subscriber will not get that publication. Any new publication on the topic will be received by the subscriber. Some providers like IBM WebSphere MQ have a feature called "Retain Publication" wherein a copy of a publication is cached. Any new subscribers who come in after a publication is made will receive this cached publication. Retain publication feature is useful when there is a time delay between publications on a topic, new subscribers will get the cached publication immediately rather than waiting for a new publication to be made by publisher.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top