Connect multiple rabbitMQ to each other - rabbitmq

I have been searching, and I couldn't find if it is possible to connect two rabbitmq instances together. I am thinking of this as an alternative to RabbitMQ Clustering feature.
My goal is that for each message that a broker receives, it routes to another broker. Does the exchange or queues in rabbitMQ allow to have this architecture?
Producer -> Broker <-> Broker -> Consumer

You can use exchange federation to publish to both the original broker and another (downstream) broker.

Related

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.

Spring+RabbitMQ make queues non durable

I am using RabbitMQ as a Stomp broker for Spring Websocket application. The client uses SockJS library to connect to the websocket interface.
Every queue created on the RabbitMQ by the Spring is durable while topics are non durable. Is there any way to make the queues non durable as well?
I do not think I can configure on the application side. I played a bit with RabbitMQ configuration but could not set it up either.
Example destination on RabbitMQ used for SUBSCRIBE and SEND:
services-user-_385b304f-7a8f-4cf4-a0f1-d6ceed6b8c92
It will be possible to specify properties for endpoints as of RabbitMQ 3.6.0 according to comment in RabbitMQ issues - https://github.com/rabbitmq/rabbitmq-stomp/issues/24#issuecomment-137896165:
as of 3.6.0, it will be possible to explicitly define properties for endpoints such as /topic/ and /queue using subscription headers: durable, auto-delete, and exclusive, respectively.
As a workaround you can try to create queues by your own using AMQP protocol and then refer to that queues from STOMP protocol.

RabbitMQ mirroring queues and exchanges

Is it possible to use federations or shovels to mirror the creation of exchanges and queues on one server to another ?
All the examples I've seen of using shovels and federations use exchanges and queues that already exist on the servers. What I want to do is create an exchange on server A and have a federation or shovel re-create it on Server B then start to send messages to it.
If this cannot be done with a federation or shovel is there anyway of achieving this without using clustering, the connection between the two servers is not consistent so clustering isn't possible.
I'm running RabbitMQ on windows.
You can use the federation plug-in.
It supports the exchange exchange and the queue federation, in order to mirror the queues and exchanges you can configure a policies ( using the management console or command line),for example with this parameters:
Name: my_policy
Pattern: ^mirr\. <---- mirror exchanges and queues with prefix “mirr.”
Definition: federation-upstream-set:all
you can apply the configuration for exchanges and queues, as:
The pattern policy supports regular expression
In this way each new or old exchange or queue that starts with the prefix “mirr.” will be mirrored to the other broker.
I think this could solve your problem.
Unfortunately in this way it is not possible to do this, because the connection is a point-to-point connection. You have to link a exchange with a remote exchange and in your topology this cant be created automatically.
I had also this problem in the past. And how i resolved the problem was over a business logic side. If there was a need for a new Exchange/Queue "on the fly", my data input gateway recognized this and created on the local and on the remote exchange the new exchange and queues with the connection, before the message was sent to RabbitMQ.

Rabbitmq federation delete messages

I'm planning to use rabbitmq federation plugin to replicate messages from master data center to standby, so I can't use cluster mirrored queues.
Is it possible to replicate message deletion to auto sync queue?
In case you need to replicate message from one queue to many consumers use an shovel to map the desired queue to a fanout exchange...then consume directly from the exchange using exclusive queues for each consumer

Can topic messages be made persistent in 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.