[jira] [Commented] (QPIDJMS-395) connection:forced leads to JMSException even though reconnect is enabled

2018-06-25 Thread Timothy Bish (JIRA)


[ 
https://issues.apache.org/jira/browse/QPIDJMS-395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16522592#comment-16522592
 ] 

Timothy Bish commented on QPIDJMS-395:
--

Fix for handling connection remote closed and resending pending messages:
https://git1-us-west.apache.org/repos/asf?p=qpid-jms.git;a=commit;h=fe0307b58beb7ec344f728e34a7ca0e3ef103add

{noformat}
QPIDJMS-395 Resend message in flight when remote closed

When the remote closes the connection and an inflight send
is outstanding we should handle the close and resend those
messages that are still awaiting dispositions in the same
manner as we do when the connection unexpectedly drops when
using the Failover feature.
{noformat}

> connection:forced leads to JMSException even though reconnect is enabled
> 
>
> Key: QPIDJMS-395
> URL: https://issues.apache.org/jira/browse/QPIDJMS-395
> Project: Qpid JMS
>  Issue Type: Bug
>  Components: qpid-jms-client
>Affects Versions: 0.33.0
>Reporter: Jiri Daněk
>Assignee: Timothy Bish
>Priority: Major
> Fix For: 0.34.0
>
>
> Based on 
> http://qpid.2158936.n2.nabble.com/Reconnect-and-amqp-connection-forced-td7659043.html,
>  I believe that reconnect:force error should not be propagated to library 
> user and the library should silently reconnect. This does not happen in the 
> test below, when I am sending messages fast--I do get exception caused by 
> connection:forced. Notice the commented out sleep() call.
> In ActiveMQ Artemis testsuite:
> {noformat}
> diff --git 
> a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFailoverEndpointDiscoveryTest.java
>  
> b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFailoverEndpointDiscoveryTest.java
> index 81c28855ef..888171227b 100644
> --- 
> a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFailoverEndpointDiscoveryTest.java
> +++ 
> b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFailoverEndpointDiscoveryTest.java
> @@ -86,6 +86,32 @@ public class AmqpFailoverEndpointDiscoveryTest extends 
> FailoverTestBase {
>}
> }
>  
> +   @Test(timeout = 12)
> +   public void testReconnectWhileSendingWithAMQP() throws Exception {
> +  JmsConnectionFactory factory = getJmsConnectionFactory();
> +  try (Connection connection = factory.createConnection()) {
> + connection.start();
> + Session session = connection.createSession(false, 
> Session.AUTO_ACKNOWLEDGE);
> + javax.jms.Queue queue = session.createQueue(ADDRESS.toString());
> + MessageProducer producer = session.createProducer(queue);
> + Thread t = new Thread(() -> {
> +try {
> +   while(true) {
> +  System.out.println("sending message");
> +  producer.send(session.createTextMessage("hello before 
> failover"));
> +//  Thread.sleep(1000);  // comment out to send messages 
> quickly
> +   }
> +} catch (Exception e ) {
> +   e.printStackTrace();
> +}
> + });
> + t.start();
> + Thread.sleep(2000);  // simpler to read than actual synchronization
> + liveServer.crash(true, true);
> + Thread.sleep(2000);
> +  }
> +   }
> +
> private JmsConnectionFactory getJmsConnectionFactory() {
>if (protocol == 0) {
>   return new 
> JmsConnectionFactory("failover:(amqp://localhost:61616)");
> {noformat}
> The above will print (only print, there aren't asserts)
> {noformat}
> javax.jms.JMSException: Received error from remote peer without description 
> [condition = amqp:connection:forced]
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpSupport.convertToException(AmqpSupport.java:164)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpSupport.convertToException(AmqpSupport.java:117)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpAbstractResource.processRemoteClose(AmqpAbstractResource.java:262)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpProvider.processUpdates(AmqpProvider.java:971)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpProvider.access$1900(AmqpProvider.java:105)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpProvider$17.run(AmqpProvider.java:854)
>   at 
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
>   at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>   at 
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
>   at 
> 

[jira] [Commented] (QPIDJMS-395) connection:forced leads to JMSException even though reconnect is enabled

2018-06-25 Thread Robbie Gemmell (JIRA)


[ 
https://issues.apache.org/jira/browse/QPIDJMS-395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16522055#comment-16522055
 ] 

Robbie Gemmell commented on QPIDJMS-395:


The git->JIRA comment bot is playing up. Changes were made against this JIRA in 
the following commits:

http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/4bfe7f5a
{noformat}
commit 4bfe7f5ae60680d220dbe2b7cbcfeb824b5e6e9d
Author: Timothy Bish 
Date:   Tue Jun 19 15:03:15 2018 -0400

QPIDJMS-395 Add failed state in provider to prevent possible race

Adds a failed state to the AMQP provider such that any queued actions
such as a send which race into the provider between the time a
connection error is detected and the failover bits close the provider
received a consistent exception that allows normal failover processing
to occur.
{noformat}

http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/38459911
{noformat}
commit 3845991106aaad1421fbf3bdb4375f367c2ac9cd
Author: Timothy Bish 
Date:   Tue Jun 19 19:04:20 2018 -0400

QPIDJMS-395 Throw a more descriptive exception type when forced

Use a somewhat more descriptive exception type when the connection is
remotely closed due to a forced error condition to aid in debug.
{noformat}

http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/09546c55
{noformat}
commit 09546c553c0a8fccedcc36b73e4ef33d42ceff7f
Author: Timothy Bish 
Date:   Thu Jun 21 18:13:31 2018 -0400

QPIDJMS-395 Adding additional failover handling tests

Add new test that validates reconnect on error after a successful
connection was made and the next reconnect has its open attempt
rejected.  Client should reconnect to final peer and return to normal
operation.
{noformat}


> connection:forced leads to JMSException even though reconnect is enabled
> 
>
> Key: QPIDJMS-395
> URL: https://issues.apache.org/jira/browse/QPIDJMS-395
> Project: Qpid JMS
>  Issue Type: Bug
>  Components: qpid-jms-client
>Affects Versions: 0.33.0
>Reporter: Jiri Daněk
>Priority: Major
>
> Based on 
> http://qpid.2158936.n2.nabble.com/Reconnect-and-amqp-connection-forced-td7659043.html,
>  I believe that reconnect:force error should not be propagated to library 
> user and the library should silently reconnect. This does not happen in the 
> test below, when I am sending messages fast--I do get exception caused by 
> connection:forced. Notice the commented out sleep() call.
> In ActiveMQ Artemis testsuite:
> {noformat}
> diff --git 
> a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFailoverEndpointDiscoveryTest.java
>  
> b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFailoverEndpointDiscoveryTest.java
> index 81c28855ef..888171227b 100644
> --- 
> a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFailoverEndpointDiscoveryTest.java
> +++ 
> b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFailoverEndpointDiscoveryTest.java
> @@ -86,6 +86,32 @@ public class AmqpFailoverEndpointDiscoveryTest extends 
> FailoverTestBase {
>}
> }
>  
> +   @Test(timeout = 12)
> +   public void testReconnectWhileSendingWithAMQP() throws Exception {
> +  JmsConnectionFactory factory = getJmsConnectionFactory();
> +  try (Connection connection = factory.createConnection()) {
> + connection.start();
> + Session session = connection.createSession(false, 
> Session.AUTO_ACKNOWLEDGE);
> + javax.jms.Queue queue = session.createQueue(ADDRESS.toString());
> + MessageProducer producer = session.createProducer(queue);
> + Thread t = new Thread(() -> {
> +try {
> +   while(true) {
> +  System.out.println("sending message");
> +  producer.send(session.createTextMessage("hello before 
> failover"));
> +//  Thread.sleep(1000);  // comment out to send messages 
> quickly
> +   }
> +} catch (Exception e ) {
> +   e.printStackTrace();
> +}
> + });
> + t.start();
> + Thread.sleep(2000);  // simpler to read than actual synchronization
> + liveServer.crash(true, true);
> + Thread.sleep(2000);
> +  }
> +   }
> +
> private JmsConnectionFactory getJmsConnectionFactory() {
>if (protocol == 0) {
>   return new 
> JmsConnectionFactory("failover:(amqp://localhost:61616)");
> {noformat}
> The above will print (only print, there aren't asserts)
> {noformat}
> javax.jms.JMSException: Received error from remote peer without description 
> [condition = amqp:connection:forced]
>   

[jira] [Commented] (QPIDJMS-395) connection:forced leads to JMSException even though reconnect is enabled

2018-06-19 Thread Timothy Bish (JIRA)


[ 
https://issues.apache.org/jira/browse/QPIDJMS-395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16517277#comment-16517277
 ] 

Timothy Bish commented on QPIDJMS-395:
--

Would you not be testing for 
[JMSSecurityException|https://docs.oracle.com/javaee/7/api/javax/jms/JMSSecurityException.html]
 in that case?

> connection:forced leads to JMSException even though reconnect is enabled
> 
>
> Key: QPIDJMS-395
> URL: https://issues.apache.org/jira/browse/QPIDJMS-395
> Project: Qpid JMS
>  Issue Type: Bug
>  Components: qpid-jms-client
>Affects Versions: 0.33.0
>Reporter: Jiri Daněk
>Priority: Major
>
> Based on 
> http://qpid.2158936.n2.nabble.com/Reconnect-and-amqp-connection-forced-td7659043.html,
>  I believe that reconnect:force error should not be propagated to library 
> user and the library should silently reconnect. This does not happen in the 
> test below, when I am sending messages fast--I do get exception caused by 
> connection:forced. Notice the commented out sleep() call.
> In ActiveMQ Artemis testsuite:
> {noformat}
> diff --git 
> a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFailoverEndpointDiscoveryTest.java
>  
> b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFailoverEndpointDiscoveryTest.java
> index 81c28855ef..888171227b 100644
> --- 
> a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFailoverEndpointDiscoveryTest.java
> +++ 
> b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFailoverEndpointDiscoveryTest.java
> @@ -86,6 +86,32 @@ public class AmqpFailoverEndpointDiscoveryTest extends 
> FailoverTestBase {
>}
> }
>  
> +   @Test(timeout = 12)
> +   public void testReconnectWhileSendingWithAMQP() throws Exception {
> +  JmsConnectionFactory factory = getJmsConnectionFactory();
> +  try (Connection connection = factory.createConnection()) {
> + connection.start();
> + Session session = connection.createSession(false, 
> Session.AUTO_ACKNOWLEDGE);
> + javax.jms.Queue queue = session.createQueue(ADDRESS.toString());
> + MessageProducer producer = session.createProducer(queue);
> + Thread t = new Thread(() -> {
> +try {
> +   while(true) {
> +  System.out.println("sending message");
> +  producer.send(session.createTextMessage("hello before 
> failover"));
> +//  Thread.sleep(1000);  // comment out to send messages 
> quickly
> +   }
> +} catch (Exception e ) {
> +   e.printStackTrace();
> +}
> + });
> + t.start();
> + Thread.sleep(2000);  // simpler to read than actual synchronization
> + liveServer.crash(true, true);
> + Thread.sleep(2000);
> +  }
> +   }
> +
> private JmsConnectionFactory getJmsConnectionFactory() {
>if (protocol == 0) {
>   return new 
> JmsConnectionFactory("failover:(amqp://localhost:61616)");
> {noformat}
> The above will print (only print, there aren't asserts)
> {noformat}
> javax.jms.JMSException: Received error from remote peer without description 
> [condition = amqp:connection:forced]
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpSupport.convertToException(AmqpSupport.java:164)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpSupport.convertToException(AmqpSupport.java:117)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpAbstractResource.processRemoteClose(AmqpAbstractResource.java:262)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpProvider.processUpdates(AmqpProvider.java:971)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpProvider.access$1900(AmqpProvider.java:105)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpProvider$17.run(AmqpProvider.java:854)
>   at 
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
>   at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>   at 
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
>   at 
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
>   at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
>   at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>   at java.lang.Thread.run(Thread.java:748)
> {noformat}
> The PN_TRACE_FRM log for this is
> {noformat}
> [...]
> [1476077082:1] -> Transfer{handle=0, deliveryId=221, deliveryTag=\x00, 
> messageFormat=0, settled=null, more=false, 

[jira] [Commented] (QPIDJMS-395) connection:forced leads to JMSException even though reconnect is enabled

2018-06-19 Thread JIRA


[ 
https://issues.apache.org/jira/browse/QPIDJMS-395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16517274#comment-16517274
 ] 

Jiri Daněk commented on QPIDJMS-395:


I do need to inspect the exception I got from send, because I may also get 
exception due to missing SEND permission to a queue, which I must handle 
differently.

So I end up with

{code}
try {
msgProducer.send(message);
} catch (JMSException jex) {
if (jex.getMessage().contains("[condition = 
amqp:connection:forced]")) {
LOG.warn("Resending message %d due to unblocking a 
blocking send.", msgCounter);
msgProducer.send(message);
} else {
throw jex;
}
}
{code}

> connection:forced leads to JMSException even though reconnect is enabled
> 
>
> Key: QPIDJMS-395
> URL: https://issues.apache.org/jira/browse/QPIDJMS-395
> Project: Qpid JMS
>  Issue Type: Bug
>  Components: qpid-jms-client
>Affects Versions: 0.33.0
>Reporter: Jiri Daněk
>Priority: Major
>
> Based on 
> http://qpid.2158936.n2.nabble.com/Reconnect-and-amqp-connection-forced-td7659043.html,
>  I believe that reconnect:force error should not be propagated to library 
> user and the library should silently reconnect. This does not happen in the 
> test below, when I am sending messages fast--I do get exception caused by 
> connection:forced. Notice the commented out sleep() call.
> In ActiveMQ Artemis testsuite:
> {noformat}
> diff --git 
> a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFailoverEndpointDiscoveryTest.java
>  
> b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFailoverEndpointDiscoveryTest.java
> index 81c28855ef..888171227b 100644
> --- 
> a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFailoverEndpointDiscoveryTest.java
> +++ 
> b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFailoverEndpointDiscoveryTest.java
> @@ -86,6 +86,32 @@ public class AmqpFailoverEndpointDiscoveryTest extends 
> FailoverTestBase {
>}
> }
>  
> +   @Test(timeout = 12)
> +   public void testReconnectWhileSendingWithAMQP() throws Exception {
> +  JmsConnectionFactory factory = getJmsConnectionFactory();
> +  try (Connection connection = factory.createConnection()) {
> + connection.start();
> + Session session = connection.createSession(false, 
> Session.AUTO_ACKNOWLEDGE);
> + javax.jms.Queue queue = session.createQueue(ADDRESS.toString());
> + MessageProducer producer = session.createProducer(queue);
> + Thread t = new Thread(() -> {
> +try {
> +   while(true) {
> +  System.out.println("sending message");
> +  producer.send(session.createTextMessage("hello before 
> failover"));
> +//  Thread.sleep(1000);  // comment out to send messages 
> quickly
> +   }
> +} catch (Exception e ) {
> +   e.printStackTrace();
> +}
> + });
> + t.start();
> + Thread.sleep(2000);  // simpler to read than actual synchronization
> + liveServer.crash(true, true);
> + Thread.sleep(2000);
> +  }
> +   }
> +
> private JmsConnectionFactory getJmsConnectionFactory() {
>if (protocol == 0) {
>   return new 
> JmsConnectionFactory("failover:(amqp://localhost:61616)");
> {noformat}
> The above will print (only print, there aren't asserts)
> {noformat}
> javax.jms.JMSException: Received error from remote peer without description 
> [condition = amqp:connection:forced]
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpSupport.convertToException(AmqpSupport.java:164)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpSupport.convertToException(AmqpSupport.java:117)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpAbstractResource.processRemoteClose(AmqpAbstractResource.java:262)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpProvider.processUpdates(AmqpProvider.java:971)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpProvider.access$1900(AmqpProvider.java:105)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpProvider$17.run(AmqpProvider.java:854)
>   at 
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
>   at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>   at 
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
>   at 
> 

[jira] [Commented] (QPIDJMS-395) connection:forced leads to JMSException even though reconnect is enabled

2018-06-19 Thread Timothy Bish (JIRA)


[ 
https://issues.apache.org/jira/browse/QPIDJMS-395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16517273#comment-16517273
 ] 

Timothy Bish commented on QPIDJMS-395:
--

Having a JMS client specific exception would mean that those using it are now 
tied to that client implementation.  The other question I'd ask would be, what 
exception that is thrown from send would indicate that a resend wasn't needed? 

> connection:forced leads to JMSException even though reconnect is enabled
> 
>
> Key: QPIDJMS-395
> URL: https://issues.apache.org/jira/browse/QPIDJMS-395
> Project: Qpid JMS
>  Issue Type: Bug
>  Components: qpid-jms-client
>Affects Versions: 0.33.0
>Reporter: Jiri Daněk
>Priority: Major
>
> Based on 
> http://qpid.2158936.n2.nabble.com/Reconnect-and-amqp-connection-forced-td7659043.html,
>  I believe that reconnect:force error should not be propagated to library 
> user and the library should silently reconnect. This does not happen in the 
> test below, when I am sending messages fast--I do get exception caused by 
> connection:forced. Notice the commented out sleep() call.
> In ActiveMQ Artemis testsuite:
> {noformat}
> diff --git 
> a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFailoverEndpointDiscoveryTest.java
>  
> b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFailoverEndpointDiscoveryTest.java
> index 81c28855ef..888171227b 100644
> --- 
> a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFailoverEndpointDiscoveryTest.java
> +++ 
> b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFailoverEndpointDiscoveryTest.java
> @@ -86,6 +86,32 @@ public class AmqpFailoverEndpointDiscoveryTest extends 
> FailoverTestBase {
>}
> }
>  
> +   @Test(timeout = 12)
> +   public void testReconnectWhileSendingWithAMQP() throws Exception {
> +  JmsConnectionFactory factory = getJmsConnectionFactory();
> +  try (Connection connection = factory.createConnection()) {
> + connection.start();
> + Session session = connection.createSession(false, 
> Session.AUTO_ACKNOWLEDGE);
> + javax.jms.Queue queue = session.createQueue(ADDRESS.toString());
> + MessageProducer producer = session.createProducer(queue);
> + Thread t = new Thread(() -> {
> +try {
> +   while(true) {
> +  System.out.println("sending message");
> +  producer.send(session.createTextMessage("hello before 
> failover"));
> +//  Thread.sleep(1000);  // comment out to send messages 
> quickly
> +   }
> +} catch (Exception e ) {
> +   e.printStackTrace();
> +}
> + });
> + t.start();
> + Thread.sleep(2000);  // simpler to read than actual synchronization
> + liveServer.crash(true, true);
> + Thread.sleep(2000);
> +  }
> +   }
> +
> private JmsConnectionFactory getJmsConnectionFactory() {
>if (protocol == 0) {
>   return new 
> JmsConnectionFactory("failover:(amqp://localhost:61616)");
> {noformat}
> The above will print (only print, there aren't asserts)
> {noformat}
> javax.jms.JMSException: Received error from remote peer without description 
> [condition = amqp:connection:forced]
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpSupport.convertToException(AmqpSupport.java:164)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpSupport.convertToException(AmqpSupport.java:117)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpAbstractResource.processRemoteClose(AmqpAbstractResource.java:262)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpProvider.processUpdates(AmqpProvider.java:971)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpProvider.access$1900(AmqpProvider.java:105)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpProvider$17.run(AmqpProvider.java:854)
>   at 
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
>   at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>   at 
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
>   at 
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
>   at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
>   at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>   at java.lang.Thread.run(Thread.java:748)
> {noformat}
> The PN_TRACE_FRM log for this is
> {noformat}
> [...]
> [1476077082:1] -> 

[jira] [Commented] (QPIDJMS-395) connection:forced leads to JMSException even though reconnect is enabled

2018-06-19 Thread JIRA


[ 
https://issues.apache.org/jira/browse/QPIDJMS-395?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16517248#comment-16517248
 ] 

Jiri Daněk commented on QPIDJMS-395:


I will just resend if I get such exception.

Artemis Core JMS is throwing a specific subclass of JMSException in this 
situation. It is a bit clearer, but it makes the program JMS provider 
specific... The Artemis Core JMS version would be something like

{code}
try {
msgProducer.send(message);
} catch (JMSException jex) {
if (jex.getCause() instanceof ActiveMQUnBlockedException) {
// Resend missed messages due to unblocking blocking 
call.
// See "Handling Blocking Calls During Failover" in 
link below
// 
https://activemq.apache.org/artemis/docs/latest/ha.html
LOG.warn("Resending message %d due to unblocking a 
blocking send.", msgCounter);
msgProducer.send(message);
} else {
throw jex;
}
}
{code}

> connection:forced leads to JMSException even though reconnect is enabled
> 
>
> Key: QPIDJMS-395
> URL: https://issues.apache.org/jira/browse/QPIDJMS-395
> Project: Qpid JMS
>  Issue Type: Bug
>  Components: qpid-jms-client
>Affects Versions: 0.33.0
>Reporter: Jiri Daněk
>Priority: Major
>
> Based on 
> http://qpid.2158936.n2.nabble.com/Reconnect-and-amqp-connection-forced-td7659043.html,
>  I believe that reconnect:force error should not be propagated to library 
> user and the library should silently reconnect. This does not happen in the 
> test below, when I am sending messages fast--I do get exception caused by 
> connection:forced. Notice the commented out sleep() call.
> In ActiveMQ Artemis testsuite:
> {noformat}
> diff --git 
> a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFailoverEndpointDiscoveryTest.java
>  
> b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFailoverEndpointDiscoveryTest.java
> index 81c28855ef..888171227b 100644
> --- 
> a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFailoverEndpointDiscoveryTest.java
> +++ 
> b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/AmqpFailoverEndpointDiscoveryTest.java
> @@ -86,6 +86,32 @@ public class AmqpFailoverEndpointDiscoveryTest extends 
> FailoverTestBase {
>}
> }
>  
> +   @Test(timeout = 12)
> +   public void testReconnectWhileSendingWithAMQP() throws Exception {
> +  JmsConnectionFactory factory = getJmsConnectionFactory();
> +  try (Connection connection = factory.createConnection()) {
> + connection.start();
> + Session session = connection.createSession(false, 
> Session.AUTO_ACKNOWLEDGE);
> + javax.jms.Queue queue = session.createQueue(ADDRESS.toString());
> + MessageProducer producer = session.createProducer(queue);
> + Thread t = new Thread(() -> {
> +try {
> +   while(true) {
> +  System.out.println("sending message");
> +  producer.send(session.createTextMessage("hello before 
> failover"));
> +//  Thread.sleep(1000);  // comment out to send messages 
> quickly
> +   }
> +} catch (Exception e ) {
> +   e.printStackTrace();
> +}
> + });
> + t.start();
> + Thread.sleep(2000);  // simpler to read than actual synchronization
> + liveServer.crash(true, true);
> + Thread.sleep(2000);
> +  }
> +   }
> +
> private JmsConnectionFactory getJmsConnectionFactory() {
>if (protocol == 0) {
>   return new 
> JmsConnectionFactory("failover:(amqp://localhost:61616)");
> {noformat}
> The above will print (only print, there aren't asserts)
> {noformat}
> javax.jms.JMSException: Received error from remote peer without description 
> [condition = amqp:connection:forced]
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpSupport.convertToException(AmqpSupport.java:164)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpSupport.convertToException(AmqpSupport.java:117)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpAbstractResource.processRemoteClose(AmqpAbstractResource.java:262)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpProvider.processUpdates(AmqpProvider.java:971)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpProvider.access$1900(AmqpProvider.java:105)
>   at 
> org.apache.qpid.jms.provider.amqp.AmqpProvider$17.run(AmqpProvider.java:854)
>