I'm using Artemis 2.18.0
and some Spring Boot
clients that communicate with each other via topics. The Spring Boot
clients use JMS
for all MQTT
operations. I'd like to know if it is possible for a producer with one or more subscribers to find out whether a certain subscriber is actively listening or not.
For example, there are 3 clients, SB1, SB2, and SB3.
SB1 publishes to test/topic
, and SB2 and SB3 are subscribed to test/topic
. If SB2 shuts down for any reason, would it be possible for SB1 to become aware of this?
I understand that queues
would be the way to go for this, but my project is much better suited to the use of topics
, and it is set up this way already and works fine. There's just one operation where it must be determined whether the listener is active or not, in order to update the listener's online status
, a crucial parameter. Right now, clients and the server continually poll a database so that the online status
is periodically updated, I want to avoid doing this and use something that Artemis may provide instead.
CodePudding user response:
Apache ActiveMQ Artemis emits notifications to inform listeners of potentially interesting events as consumer created or closed, see Management Notifications at http://activemq.apache.org/components/artemis/documentation/latest/management.html.
A listener of the management notification address would receive a message for each consumer created or closed, see the Management Notification Example at http://activemq.apache.org/components/artemis/documentation/latest/examples.html#management-notification
CodePudding user response:
Part of the point to pub/sub based messaging is to decouple the information producer (publisher) from the consumer (subscriber). As a rule a published REALLY shouldn't care if there even are any subscribers.
If you want to know the status of the subscriber then it's up to the subscriber to update this, not the publisher. Things like the Last Will & Testament feature allow the subscriber to update it's status in the event of a failure to explicitly do it when going offline.