Reputation: 3988
I am using JMS (ActiveMQ) between a Topic Publisher and a variable number of Topic Subscribers.
I would have to check if, at a given moment in time, some of the subscribers are "offline" (disconnected, shutdown, unable to communicate, etc...).
Is there a way that JMS allows the publisher to know which subscribers are "registered"?
Right now, I have it implemented so that subscribers send an "alive" message on a specific Queue (acting as producers) and the publisher receives them (acting as a consumer): if it is detected that any of the subscribers didn't "ping" for X seconds (threshold), it is assumed to be offline. It works, but I was curious to know if I reinvented the wheel...
I know that this feature is not completely related to Messaging or Pub/Sub paradigm and I also know that Pub/Sub is specifically designed so that the publisher doesn't have to worry about who/where/when its messages will be consumed....but I was wondering that, if it DID want to know, maybe there was a way. After all, it doesn't seem like a particularly uncommon usecase....
Thank you very much.
Upvotes: 1
Views: 693
Reputation: 31832
JMS explicitly decouples publishers from subscribers. The whole point was supposed to be that the two did not need to know or care about the state of the other. Therefore JMS has no facility to do what you require. On the other hand, providers will have vendor-specific administration APIs and, as Paul notes, the AMQ advisory messages are what you want with Active MQ. Because these are vendor-specific it will not be portable to any other provider though and will not be JMS compliant. Not the fault of AMQ, just that it's not part of the JMS spec.
Upvotes: 2
Reputation: 1875
I don't think there is a way to tell your publisher the information about the subscribers directly.
what you should do is actually use AMQ advisory messages to keep track of the statuses of your subscribers. Read the article - it provides all the information you need.
Upvotes: 2