You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Frank Meilinger <fr...@gmx.net> on 2019/07/09 21:49:30 UTC
replicated static master/slave - which is the correct URI for an
artemis-jms-client?
Hello,
I've followed the test setup and installed a replicated static master/slave environment (like documented here: https://github.com/jbossdemocentral/amq-ha-replicated-demo). Version is Artemis 2.7.0. Both master and slave processes start without errors.
Now I try to find out which is the correct URI using in a artemis-jms-client.
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-jms-client</artifactId>
<version>2.7.0</version>
</dependency>
After doing a lot of Artemis document and google research, I've tried the following variants:
tcp://master:61616?ha=true&reconnectAttempts=-1
(tcp://master:61616,tcp://slave:61616)?ha=true&reconnectAttempts=-1
failover:(tcp://master:61616,tcp://slave:61616)?ha=true&reconnectAttempts=-1
(tcp://master:61616,tcp://slave:61616)?randomize=false&backup=true
failover:(tcp://master:61616,tcp://slave:61616)?randomize=false&backup=true
Nothing really works. The tested variants with "failover:" schema are not supported for this client, as I can read in the error message. The other variants work, as long as the master is running. When regular stopping (or killing with -9) the master, there are errors in the client code and no transparent failover happens (session get's invalid and/or connection get's invalid).
I also tried to use these 5 different URI's with command line consumer and producer but I have the same problems as in the artemis-jms-client.
Here are my tests with the command line tools:
Starting the consumer in one console:
./artemis consumer --url "<one of the 5 URI's mentioned above>" --destination topic://abc.def --message-count 10 --data /dev/stdout --durable --clientID myclient
Starting the producer in an other console:
./artemis producer --url "<one of the 5 URI's mentioned above>" --destination topic://abc.def --message test --sleep 1000 --message-count 10
While the command line producer is sending messages with 1 second delay and the command line consumer receives them, I stop/kill the master and have hoped that the failover will happen transparently. But I got more or less the same errors as in the artemis-jms-client.
So my question is just, what is the correct syntax for the client URI to get transparent failover for such a master/slave setup (working with both artemis-jms-client and command line clients)?
Thanks in advance,
Frank
Re: replicated static master/slave - which is the correct URI for
an artemis-jms-client?
Posted by mk666aim <ma...@aimia.com>.
Also, in a scenario where master server is started again, and backup server
should fail back to the master from that moment onwards....
Should the client also reconnect to the master? It does not seem to be
happening, as my client is still locked to the backup server.
When I shut down backup server, client then reconnects to the master, and
then I can start the backup server back.
Is this the expected behaviour?
--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
Re: replicated static master/slave - which is the correct URI for
an artemis-jms-client?
Posted by mk666aim <ma...@aimia.com>.
Thank you Justin.
I can indeed see in your source code that this flag is being used all over
the place.
I am now using it and also using reconnectAttempts=-1 and things behave ok.
I ran into the issue in one of the client environments where clients did not
want to failover, as if locked in to the same node.
I have found out that the time between the different servers was 1 hour
apart (ntp was not active).
I wonder if this was causing the failover issues, as the problems went away
once all boxes were using the same time (we have got 2 boxes where artemis
brokers run, and 2 boxes where micro-services run).
--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
Re: replicated static master/slave - which is the correct URI for an artemis-jms-client?
Posted by Justin Bertram <jb...@apache.org>.
The "ha" parameter tells the client to use the backup information it
receives from the broker so in case the original connection fails it will
automatically connect (i.e. failover) to the backup. Without ha=true on
your client URL you won't get true failover.
I believe what you're seeing is just the client connection failing and then
retrying the initial connectors. However, you haven't provided many
concrete details so it's hard to say.
Justin
On Tue, Aug 13, 2019 at 10:54 AM mk666aim <ma...@aimia.com> wrote:
> So what exactly is the ha parameter for?
> Does it treat servers somehow differently? E.g. *non-ha* pool of servers,
> vs. *ha* pool of servers?
>
> Form what I am seeing, even without it, client fails over to slave after
> retrying master 5 times and then fail over to the slave... So the fail over
> is somehow triggered still...
>
>
>
>
> --
> Sent from:
> http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
>
Re: replicated static master/slave - which is the correct URI for
an artemis-jms-client?
Posted by mk666aim <ma...@aimia.com>.
So what exactly is the ha parameter for?
Does it treat servers somehow differently? E.g. *non-ha* pool of servers,
vs. *ha* pool of servers?
Form what I am seeing, even without it, client fails over to slave after
retrying master 5 times and then fail over to the slave... So the fail over
is somehow triggered still...
--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
Re: replicated static master/slave - which is the correct URI for an artemis-jms-client?
Posted by Justin Bertram <jb...@apache.org>.
I'd say you're missing the ha flag. To enable failover you need to use
"ha=true" in your URL. Otherwise the client won't know that it's connection
to an HA (i.e. highly available) master/slave pair.
Justin
On Thu, Aug 1, 2019 at 6:35 AM mk666aim <ma...@aimia.com> wrote:
> The below URL does not seem to work for me.
> Client basically never switches to the backup node. Isn't that what
> reconnectAttempts=-1 will cause?
>
> I used following URL before and the switching happened:
>
> *(tcp://master:61616,tcp://slave:61616)?reconnectAttempts=5*
>
> What am I missing?
>
> And what is the *ha* flag about?
>
>
> jbertram wrote
> > Thanks for following up, Frank. I would expect a URL like this to work:
> >
> > (tcp://master:61616,tcp://slave:61616)?ha=true&reconnectAttempts=-1
>
>
>
>
>
> --
> Sent from:
> http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
>
Re: replicated static master/slave - which is the correct URI for
an artemis-jms-client?
Posted by mk666aim <ma...@aimia.com>.
The below URL does not seem to work for me.
Client basically never switches to the backup node. Isn't that what
reconnectAttempts=-1 will cause?
I used following URL before and the switching happened:
*(tcp://master:61616,tcp://slave:61616)?reconnectAttempts=5*
What am I missing?
And what is the *ha* flag about?
jbertram wrote
> Thanks for following up, Frank. I would expect a URL like this to work:
>
> (tcp://master:61616,tcp://slave:61616)?ha=true&reconnectAttempts=-1
--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
replicated static master/slave - which is the correct URI for an
artemis-jms-client?
Posted by Frank Meilinger <fr...@gmx.net>.
Hi Justin,
thanks a lot for clarification. I couldn't find a documentation with all supported URI schemes and all supported options for the Artemis JMS core client. Maybe you have a link...
Frank
Re: replicated static master/slave - which is the correct URI for an artemis-jms-client?
Posted by Justin Bertram <jb...@apache.org>.
Thanks for following up, Frank. I would expect a URL like this to work:
(tcp://master:61616,tcp://slave:61616)?ha=true&reconnectAttempts=-1
Both "randomize" and "backup" are not used by the Artemis JMS core client.
Also, the "failover://" schema is used by OpenWire clients, not Artemis JMS
core clients.
Justin
On Fri, Jul 12, 2019 at 7:13 AM Frank Meilinger <fr...@gmx.net>
wrote:
> Hello all,
>
> there was an error in my broker.xml files on both master and slave. After
> correcting these, the following URI is working with the "ActiveMQ JMS Core
> Client" library (and also with the artemis command line clients), like it
> should.
>
>
> (tcp://master:61616,tcp://slave:61616)?ha=true&reconnectAttempts=-1&randomize=false&backup=true
>
> Regards
>
>
>
replicated static master/slave - which is the correct URI for an
artemis-jms-client?
Posted by Frank Meilinger <fr...@gmx.net>.
Hello all,
there was an error in my broker.xml files on both master and slave. After correcting these, the following URI is working with the "ActiveMQ JMS Core Client" library (and also with the artemis command line clients), like it should.
(tcp://master:61616,tcp://slave:61616)?ha=true&reconnectAttempts=-1&randomize=false&backup=true
Regards