diff --git a/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java b/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java index 2faa5e2fe6..1f360cb792 100755 --- a/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java +++ b/activemq-client/src/main/java/org/apache/activemq/ActiveMQConnection.java @@ -685,7 +685,7 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon RemoveInfo removeCommand = info.createRemoveCommand(); removeCommand.setLastDeliveredSequenceId(lastDeliveredSequenceId); try { - doSyncSendPacket(removeCommand, closeTimeout); + syncSendPacket(removeCommand, closeTimeout); } catch (JMSException e) { if (e.getCause() instanceof RequestTimedOutIOException) { // expected @@ -1377,13 +1377,15 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon onException(new IOException("Force close due to SecurityException on connect", exception)); } - public Response syncSendPacket(Command command) throws JMSException { + public Response syncSendPacket(Command command, int timeout) throws JMSException { if (isClosed()) { throw new ConnectionClosedException(); } else { try { - Response response = (Response)this.transport.request(command); + Response response = (Response)(timeout > 0 + ? this.transport.request(command, timeout) + : this.transport.request(command)); if (response.isException()) { ExceptionResponse er = (ExceptionResponse)response; if (er.getException() instanceof JMSException) { @@ -1422,32 +1424,8 @@ public class ActiveMQConnection implements Connection, TopicConnection, QueueCon * * @throws JMSException */ - public Response syncSendPacket(Command command, int timeout) throws JMSException { - if (isClosed() || closing.get()) { - throw new ConnectionClosedException(); - } else { - return doSyncSendPacket(command, timeout); - } - } - - protected Response doSyncSendPacket(Command command, int timeout) - throws JMSException { - try { - Response response = (Response) (timeout > 0 - ? this.transport.request(command, timeout) - : this.transport.request(command)); - if (response != null && response.isException()) { - ExceptionResponse er = (ExceptionResponse)response; - if (er.getException() instanceof JMSException) { - throw (JMSException)er.getException(); - } else { - throw JMSExceptionSupport.create(er.getException()); - } - } - return response; - } catch (IOException e) { - throw JMSExceptionSupport.create(e); - } + public Response syncSendPacket(Command command) throws JMSException { + return syncSendPacket(command, 0); } /** diff --git a/activemq-client/src/main/java/org/apache/activemq/TransactionContext.java b/activemq-client/src/main/java/org/apache/activemq/TransactionContext.java index efe12c441c..2188ff97eb 100755 --- a/activemq-client/src/main/java/org/apache/activemq/TransactionContext.java +++ b/activemq-client/src/main/java/org/apache/activemq/TransactionContext.java @@ -277,7 +277,7 @@ public class TransactionContext implements XAResource { TransactionInfo info = new TransactionInfo(getConnectionId(), transactionId, TransactionInfo.ROLLBACK); this.transactionId = null; //make this synchronous - see https://issues.apache.org/activemq/browse/AMQ-2364 - this.connection.doSyncSendPacket(info, this.connection.isClosing() ? this.connection.getCloseTimeout() : 0); + this.connection.syncSendPacket(info, this.connection.isClosing() ? this.connection.getCloseTimeout() : 0); // Notify the listener that the tx was rolled back if (localTransactionEventListener != null) { localTransactionEventListener.rollbackEvent();