Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActiveMQ how to keep message that failed to sent to consumer on queue /topic?


I am still learning about this activemq and jms stuff. I already tried some example and now I can produce and consuming message from the queue/topic.

Now I have a problem, when my client/consumer lost the connection, the message in queue/topic still send out that message, that message become lost and not kept in the queue/topic. So my question is how I can keep that failed message and how to make the broker resend that message again?

thanks

like image 220
Mari_Yaguchi Avatar asked Dec 05 '25 17:12

Mari_Yaguchi


1 Answers

You are mixing up terminology a bit.

Queues will hold messages until consumed or the broker is restarted, unless the message has been marked as persistent, in which case they will stick around even after a broker restart.

Topics only deliver the current message to any current subscriber. However there are several methods you can use to persist messages published to a topic:

  1. Durable subscribers.
  2. Virtual Destinations .

Virtual Topics tend to be popular for many reasons over durable subscribers, but it really depends on the use-case.

How you create a durable subscriber depends on what you are using to create the subscriber (Spring, POJO, some other API?). All methods will at some point call the Session.createDurableSubscriber method, but I suggest reading up on how they behave before choosing this over Virtual Topic or Composite Queues.

like image 82
Erik Williams Avatar answered Dec 09 '25 03:12

Erik Williams