We are using ActiveMQ and have defined a network of brokers (2 in our test setup). We have configured the brokers to accept AMQP connections and we have enable "updateClusterClients" and "rebalanceClusterClients" like so:
<transportConnector name="amqp" uri="amqp+ssl://0.0.0.0:5673?maximumConnections=1000&wireFormat.maxFrameSize=104857600&transport.transformer=jms" updateClusterClients="true" rebalanceClusterClients="true"/>
Furthermore, we have build our clients using Qpid JMS. The clients have been configured using a failover-url.
The clients can communicate with each other just fine. Also, when I stop one of the two brokers, they switch to the remaining broker.
However, when I restart the broker, I had expected to see some of the clients move to the new broker. Unfortunately, what I actually see is that they all stay connected to the same broker.
What might be the reason that they don't rebalance themselves?
Also, I would like the clients to spread over the two brokers when they connect initially. Is there a way how I can achieve this?
The ActiveMQ broker does not attempt to rebalance the AMQP clients in the Broker network. There could be a way to accomplish it but it makes some assumptions about the nature of every AMQP client that's connect such as the fact that they all support connection redirects which not all of them do.
Until a better mechanism is defined such that a client can connect and advertise that it is willing to be redirected I don't think you'll see ActiveMQ forcibly dropping connections on AMQP clients to rebalance them.
The broker is able to rebalance OpenWire clients because it knows that an OpenWire client connected with the failover transport will deal with the Connection Control command that requests the client to leave, where a client that is not connect with failover will ignore that command.
Related
The ActiveMQ Artemis documentation says:
Slave will be in passive mode until the master crashes...
That's OK, but it's not clear if brokers in passive mode can be a connection point. In other words, can I put my slave in the connection list for a remote client like below?
(tcp://my-master:61616,tcp://my-slave:61616)?reconnectAttempts=5
If yes, does it means that a broker in passive mode is just a router?
The ActiveMQ Artemis JMS client supports a list of servers to be used for the initial connection attempt. It can be specified in the connection URI using a syntax with (), e.g.: (tcp://myhost:61616,tcp://myhost2:61616)?reconnectAttempts=5. The client uses this list of servers to create the first connection.
The slave broker doesn't accept incoming client connections until it becomes live, but it is important to include both the master and the slave uri in the list because the client can't know who is live when it creates the initial connection.
I have successfully able to connect worker and broker on tcp protocol and then client to broker on tcp.
Now i am evaluating that is it possible that worker and broker can connect on ipc/inproc protocol while client will connect to broker on tcp.
My workers and broker will be on same machine and might even reside in same process. My client can connect to my broker from different machine that's why it needed to be on tcp
Can Broker be binded in dual way ?
Yes, there's no problem doing what you suggest. Each ZMQ socket operates completely distinct from the other sockets in your code. It often makes sense to mix connection protocols to optimize communication the way you're looking to do.
One assumption I'm making here is that your broker has 2 sets of sockets: client facing sockets that you can connect via TCP and worker facing sockets that you can connect via some other protocol. If both client and worker are connecting to the same socket on the broker, then they must connect via the same protocol.
The only thing to consider is whether your workers will always reside in the same process as your broker, or if it might grow to a point where it makes sense to separate them. But, if you define your socket connections in some sort of configurable way, rather than baking it into the code, even that could be a relatively easy fix if you decide to change things down the line.
I have a master/slave AMQ broker setup for JMS messaging. I have two servers that I would like to setup as a master/slave durable consumers using Apache Camel. We've been achieving this by having both servers attempt to connect with the same client ID. One node handles all of the work but if it goes down the other node connects and picks right back up on the work. This has been working fine for having a single consumer at a time but it makes noise in disconnected server's log files with the message
ERROR org.apache.camel.component.jms.DefaultJmsMessageListenerContainer]
(Camel (spring-context) thread #0 - JmsConsumer[global.topic.event]) Could
not refresh JMS Connection for destination 'global.topic.event' - retrying
using FixedBackOff{interval=5000, currentAttempts=12,
maxAttempts=unlimited}. Cause: Broker: broker - Client: client already
connected from tcp://xxx.xx.xx.xxx:xxxx
Is there a proper way to get the functionality that I'm looking to achieve? I was considering having the slave server ping the master to coordinate which one is connected but I'd like to keep the implementation as simple as possible.
Convert your usage of topics on the consumer side to Virtual Topics. Virtual Topics allow you to continue to have existing message flows produce and consume from the topic, but also have consumers listen on specially named queues.
Once you are consuming from a queue, you can implement all the consumer patterns-- exclusive consumer (which allows that hot-standby backup consumer), message groups, parallel consumers, etc.
I need to scale up my ActiveMQ solution so I have defined a network of brokers.
I'm tring to figure out how to connect my producers and consumers to the cluster.
does each producer has to be connected to a single broker (with the failover uri for availability)? in this case how can I guarentry the distribution of traffic accross the brokers? do I need to configure the producers to connect each to a diffrent broker?
should I apply the same schema for the consumers?
This makes the application aware of the cluster topology, which I hope can be avoided by a discent cluster
Tx
Tomer
I strongly suggest you carefully read through the documentation from activemq.apache.org on clustering ActiveMQ. There are a lot of very helpful tips.
From what you have written I suggest you pay special attention to this. At the bottom of the page it details how you can control from server side the failover/failback configuration for your producers.
For example:
updateClusterClients - if true pass information to connected clients about changes in the topology of the broker cluster
rebalanceClusterClients - if true, connected clients will be asked to rebalance across a cluster of brokers when a new broker joins the network of brokers
updateURIsURL - A URL (or path to a local file) to a text file containing a comma separated list of URIs to use for reconnect in the case of failure
In a production active system then I would think that making use of updateURIsURL would make it a lot less painful scaling out.
I have set up a network of brokers exactly as per this post of Bruce Snyder:
Broker 1:
<networkConnector name="amq1-nc"
uri="static:(tcp://localhost:61617)"
userName="system"
password="manager"
/>
Broker 2:
<networkConnector name="amq2-nc"
uri="static:(tcp://localhost:61616)"
userName="system"
password="manager"
/>
I have advisorySupport="false" in the broker tag of both the broker's config XML and started both the brokers.
Then I started the consumer using the command:
ant consumer -Durl=tcp://0.0.0.0:61616
and finally started producer using this command:
ant producer -Durl=tcp://0.0.0.0:61617
All the produced messaged then go in the pending state on the broker running on port 61617 and consumer connected on port 61616 broker never gets the messages.
Does the network of brokers stop forwarding messages without advisorySupport enabled? I thought that was fixed in a recent release. (I'm using activemq 5.4.2 release).
Does ActiveMQ static network of brokers stop forwarding messages advisorySupport is disabled?
Update:
I ran into issues using advisorySupport="false" and staticallyIncludedDestinations.
We use JMS for mostly request-response like described here: http://activemq.apache.org/how-should-i-implement-request-response-with-jms.html
We are using a temporary queue on the Producer side to be able to receive response from Consumers and since staticallyIncludedDestinations cannot include these temporary queue names in it, therefore, all the Producers are unable to receive responses back from clients when advisorySupport is disabled.
I am coming to the conclusion that for our scenario advisorySupport cannot be turned off unless there is some other config trick I'm not aware of.
The documentation sais:
"Warning:
Advisory messages are required for
dynamic network broker topologies as
NetworkConnectors subscribe to
advisory messages. In the absence of
advisories, a network must be
statically configured.
The Advisory messages tell a node where remote consumers are and therefore where to send incoming messages. WITHOUT them, you have to configure that stuff yourself.
The documentation has an example how to do that: http://activemq.apache.org/networks-of-brokers.html