How to save messages and topics in Activemq?

I have Queue and Topic with 2 posts in Activemq . If I restart Activemq . I am losing posts as well as Topic .

Even if I restart Activemq , I do not want to lose messages from any Topic and Queue . Is it possible.

I am using Activemq 5.8.0 .

0
source share
1 answer

The producer creates a message and sends it to the topic that the consumer is ever working at this point in time, will receive the message. If you want a consumer who is not working right now, but who can work in the Future to receive this message, you will have to tell the Broker to save the message and keep the information that this percussive consumer has not received the message.

If you have working code without a trusted subscriber, you will need to make the following changes.

In the consumer
1. Install the clientele. Because the Subject must know which consumer has not yet received the message. Or received a message.

 Connection.setClientID(String) 

2. A reliable subscriber must be created for your topic.

 Connection.createDurableSubscriber() 

3. Add your listener to this subscriber.

 subscriber.setMessageListener(yourlistener) 

4. When you receive the message, you will need to confirm it.

This link shows how this is done: But its in C # I think.

http://myadventuresincoding.wordpress.com/2011/08/16/jms-how-to-setup-a-durablesubscriber-with-a-messagelistener-using-activemq/

Read these links for more information:

http://activemq.apache.org/how-do-durable-queues-and-topics-work.html http://activemq.apache.org/why-do-i-not-receive-messages-on-my -durable-topic-subscription.html http://activemq.apache.org/manage-durable-subscribers.html

0
source

Source: https://habr.com/ru/post/904165/


All Articles