You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by ahuhatwork <ah...@protonmail.com> on 2019/09/12 21:08:56 UTC
Producer failover behaviour
In my setup, I have a one master and one slave. I have a sample app:
Steps
1. Start up the above app
2. Kill -9 artemis master
3. Bring artemis master back up
Once in a while, my app gets stuck looping on the following exception (After
step 3).
Any ideas?
--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
Re: Producer failover behaviour
Posted by ahuhatwork <ah...@protonmail.com>.
It seems that using "reconnectAttempts=-1" or using "reconnectAttempts=500"
both work. In other words, it looks like setting it at reconnectAttempts=6
(along with the other connection parameters I have) wasn't sufficient time
for failover and failback.
--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
Re: Producer failover behaviour
Posted by yw yw <wy...@gmail.com>.
Can you try the url "tcp://artemis:61616?ha=true&reconnectAttempts=-1"?
Here -1 means infinite retry. Default reconnect attempts is
DEFAULT_RECONNECT_ATTEMPTS=0.
ahuhatwork <ah...@protonmail.com> 于2019年9月13日周五 下午11:23写道:
> Oh, that's unfortunate. I used the "< raw >" tag using nabble.
>
> Here is the artemis (2.9) client code snippet (hopefully this works):
>
> public class SampleProducer {
> public static void main(String[] args) throws JMSException,
> InterruptedException {
> String brokerUrl = "tcp://artemis:61616?ha=true";
> ConnectionFactory cf = new ActiveMQConnectionFactory(brokerUrl);
>
> try (Connection connection = cf.createConnection();
> Session session = connection.createSession(false,
> Session.AUTO_ACKNOWLEDGE)) {
> connection.start();
>
> Queue queue = session.createQueue("myJmsQueue");
> try (MessageProducer producer = session.createProducer(queue))
> {
> for (int i = 0; i < 500000; i++) {
> try {
> TextMessage message =
> session.createTextMessage("Message " + i);
> producer.send(message);
> } catch (JMSException e) {
> e.printStackTrace();
> }
> Thread.sleep(500);
> }
> }
> }
> }
> }
>
>
> Here is the exception that I get:
> javax.jms.IllegalStateException: Session is closed
> at
>
> org.apache.activemq.artemis.jms.client.ActiveMQSession.checkClosed(ActiveMQSession.java:1249)
> at
>
> org.apache.activemq.artemis.jms.client.ActiveMQSession.createTextMessage(ActiveMQSession.java:248)
>
>
>
> I do have a follow up question - is the sample code correct in terms of a
> producer handling automatic failover/failback?
>
>
>
> --
> Sent from:
> http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
>
Re: Producer failover behaviour
Posted by ahuhatwork <ah...@protonmail.com>.
Oh, that's unfortunate. I used the "< raw >" tag using nabble.
Here is the artemis (2.9) client code snippet (hopefully this works):
public class SampleProducer {
public static void main(String[] args) throws JMSException,
InterruptedException {
String brokerUrl = "tcp://artemis:61616?ha=true";
ConnectionFactory cf = new ActiveMQConnectionFactory(brokerUrl);
try (Connection connection = cf.createConnection();
Session session = connection.createSession(false,
Session.AUTO_ACKNOWLEDGE)) {
connection.start();
Queue queue = session.createQueue("myJmsQueue");
try (MessageProducer producer = session.createProducer(queue)) {
for (int i = 0; i < 500000; i++) {
try {
TextMessage message =
session.createTextMessage("Message " + i);
producer.send(message);
} catch (JMSException e) {
e.printStackTrace();
}
Thread.sleep(500);
}
}
}
}
}
Here is the exception that I get:
javax.jms.IllegalStateException: Session is closed
at
org.apache.activemq.artemis.jms.client.ActiveMQSession.checkClosed(ActiveMQSession.java:1249)
at
org.apache.activemq.artemis.jms.client.ActiveMQSession.createTextMessage(ActiveMQSession.java:248)
I do have a follow up question - is the sample code correct in terms of a
producer handling automatic failover/failback?
--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
Re: Producer failover behaviour
Posted by Justin Bertram <jb...@apache.org>.
None of your code snippets or exception messages came through so it's
impossible to provide any ideas at this point.
Justin
On Thu, Sep 12, 2019 at 4:09 PM ahuhatwork <ah...@protonmail.com>
wrote:
> In my setup, I have a one master and one slave. I have a sample app:
>
>
>
> Steps
> 1. Start up the above app
> 2. Kill -9 artemis master
> 3. Bring artemis master back up
>
> Once in a while, my app gets stuck looping on the following exception
> (After
> step 3).
>
>
>
> Any ideas?
>
>
>
> --
> Sent from:
> http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html
>