Can topic messages be made persistent in activemq? - activemq

I am very new to JMS and ESB.
I am using activemq as JMS and mule as ESB. When i am forwarding the messages from one queue to another with jms connector parameter "persistentDelivery" as "true" it retains the messages in the target queue after activemq re-start. But in case of forwarding messages from one topic to another,the messages are not retained in the target topic after restart.
Is there any limitation for persistence of messages in case of topic in activemq?
Thanks in advance.
Regards,
Arijit

topics are different in that messages are only retained if there is a durable consumer.
see these for more info...
http://activemq.apache.org/how-do-durable-queues-and-topics-work.html
http://stefanlearninglog.blogspot.com/2009/07/persistent-jms-topics-using-activemq.html

Topics in Activemq are not durable and persistent, so in case one of your consumer is down. You would lost your messages.
To make topic durable and persistent you can create a durable consumer by creating unique client id per consumer.
But again, that is not distributed in case you are following microservices architecture. So multiple pods or replicas will create problem while consuming messages as in no load balancing is possible for durable consumers.
To mitigate this scenario, there is a option of Virtual topics in Activemq.More details have been provided below,
You can send your messages via your producer in topic named as VirtualTopic.MyTopic.
** Note: you must have to follow this naming convention for default activemq configuration. But yes there is also a way to override this naming convention.
Now, to consume your messages via multiple consumers, you have to set naming convention for your consumer side destination as well for eg. Consumer.A.VirtualTopic.MyTopic
Consumer.B.VirtualTopic.MyTopic
These two consumer will receive messages through the topic created above, also with load balancing enabled between multiple replicas of same consumer.
I hope this will help you fixing your problem with activemq topic.

Related

ActiveMQ - how to set persistency from config?

I have a topic and three queues in activeMQ. Producer is publishing the message to the topic and it's routing the same message in these three queues. Now my question is:
I haven't set persistency in producer and I don't want to because of some project limitation. How caan I set persistency for the topic and queues from ActiveMQ broker? I am using ActiveMQ 5.15.12 version.
Can I set persistency for one queue and don't set for another?
What will happen if I don't use the persistency? I know there have chances of losing messages during broker restart but is there any other way to overcome this issue?

How to create a topic exchange in Qpid JMS for ActiveMQ like RabbitMQ?

I've got a Java application that uses RabbitMQ. This application creates a TOPIC exchange and pushes messages to the TOPIC with its own routing key. From this way if I want the data from any application I create a queue binding with the exchange TOPIC and the routing key I want to.
I want to do the same thing by using a Java application with Qpid JMS as the client and ActiveMQ as the server. The information says it's possible, but I don't know how. I cannot found a specific example seems to RabbitMQ. I can create queues but I don't know how to create the exchange and the binding. What steps should I follow to achieve it?
You might consider using ActiveMQ Artemis instead of ActiveMQ 5.x as the address model of Artemis is much more similar to RabbitMQ's than 5.x's address model (which is more JMS-centric).
As far as JMS goes I think what you need is:
A topic. This is analogous to the "exchange" from RabbitMQ. Any message sent to a JMS topic is delivered to every subscriber. It's basic publish/subscribe semantics.
A topic subscriber with a selector. As noted in #1, every subscriber on a topic will get any message sent to that topic, but a JMS "selector" can be used to filter messages similar to the routing key in RabbitMQ.
An agreed-upon key for a message property. In order to create a viable selector for the topic subscriber the producer and the subscriber must agree upon the property key to filter on.
If each subscription is going to have lots of messages and those messages need to be shared among multiple subscribers/consumers (e.g. for load-balancing/distribution) then you will need to use a JMS "shared subscription." However, shared subscriptions are only part of JMS 2 and only ActiveMQ Artemis implements JMS 2. You can't use ActiveMQ 5.x with JMS shared subscriptions as it only supports JMS 1.1.
Both ActiveMQ 5.x and ActiveMQ Artemis create server-side resources (e.g. topics, queues, etc.) on-demand by default so all you need to do is write your JMS application.

ActiveMQ topics vs RabbitMQ Direct exchanges

We are currently looking at ActiveMQ.
Previously we've used RabbitMQ and in particular Direct exchanges whereby a producer can send a single message to a broker which then fans this out onto 1:N other queues.
We would like a similar setup in ActiveMQ where the broker holds the configuration for which messages go where, rather than the services sending messages directly to specific queues or consumers needing to subscribe to specific topics.
I've dug into the documentation and found Virtual Topic Composite Destinations which looks to provide this functionality.
What I am trying to understand now is if this is the ActiveMQ recommended approach and if there are any pitfalls I should be wary of?
Any ActiveMQ war stories much appreciated!

Does MQTT use AMQP?

I was fiddling with MQTT brokers and created channels and subscribed to them. Today I log into my RabbitMq interface and I find two queues titled
mqtt-subscription-1qos1 and mqtt-subscription-2qos1. I was very confused because I don't know how the two relate to each other.
Is MQTT built on top of AMQP so thats why it creates queues?
To answer the question in the subject, No MQTT is it's own independent protocol and has nothing to do with AMQP.
RabbitMQ's implementation of MQTT may make use of queues for clients subscribing to topics at QOS 1/2 in order to ensure those messages are delivered when the client is offline and also to ensure the messages are delivered in order.

What is good practice to strore application config at RabbitMQ queue?

There is a set of same listeners that listens TCP ports and publishes received data to RabbitMQ queue. I need to have ability to configure listeners from backend at other side of the queue. There is no other connection to listeners except RMQ. What is the good practice to store application config within queue? Must it be a separate queue and exchange? Which parameters queue should have, where to read more? Thanks for any advising.
RabbitMQ doesn't store data. After message is consumed, it will be deleted. If you want to use rmq to send NOTIFICATION to consumers, that is doable. For configuration, my suggestion is zookeeper which also support listener on change.