You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "Timothy Bish (JIRA)" <ji...@apache.org> on 2017/06/02 15:48:04 UTC
[jira] [Commented] (AMQ-6697) Aborting a STOMP 1.1 transaction
after ACK/NACK leads to invalid state
[ https://issues.apache.org/jira/browse/AMQ-6697?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16034908#comment-16034908 ]
Timothy Bish commented on AMQ-6697:
-----------------------------------
This test seems to indicate that all is working as designed.
{code}
@Test(timeout = 60000)
public void testTransactionRollback() throws Exception {
MessageProducer producer = session.createProducer(queue);
producer.send(session.createTextMessage("Hello"));
producer.close();
String frame = "STOMP\n" + "login:system\n" + "passcode:manager\n" +
"accept-version:1.1\n" + "host:localhost\n" + "client-id:test\n" + "\n" + Stomp.NULL;
stompConnection.sendFrame(frame);
String f = stompConnection.receiveFrame();
assertTrue(f.startsWith("CONNECTED"));
QueueViewMBean queueView = getProxyToQueue(getQueueName());
assertEquals(1, queueView.getQueueSize());
frame = "BEGIN\n" + "transaction: tx1\n" + "\n\n" + Stomp.NULL;
stompConnection.sendFrame(frame);
frame = "SUBSCRIBE\n" + "destination:/queue/" + getQueueName() + "\n" +
"id:12345\n" + "ack:client\n\n" + Stomp.NULL;
stompConnection.sendFrame(frame);
StompFrame received = stompConnection.receive();
assertTrue(received.getAction().equals("MESSAGE"));
// ack it
frame = "ACK\n" + "transaction: tx1\n" + "subscription:12345\n" + "message-id:" +
received.getHeaders().get("message-id") + "\n\n" + Stomp.NULL;
stompConnection.sendFrame(frame);
// rollback first message
frame = "ABORT\n" + "transaction: tx1\n" + "\n\n" + Stomp.NULL;
stompConnection.sendFrame(frame);
assertEquals(1, queueView.getQueueSize());
// ack it
frame = "ACK\n" + "subscription:12345\n" + "message-id:" +
received.getHeaders().get("message-id") + "\n\n" + Stomp.NULL;
stompConnection.sendFrame(frame);
assertTrue("Message not ack'd", Wait.waitFor(new Wait.Condition() {
@Override
public boolean isSatisified() throws Exception {
return queueView.getQueueSize() == 0;
}
}));
String unsub = "UNSUBSCRIBE\n" + "destination:/queue/" + getQueueName() + "\n" +
"receipt:1\n" + "id:12345\n\n" + Stomp.NULL;
stompConnection.sendFrame(unsub);
String receipt = stompConnection.receiveFrame();
assertTrue(receipt.contains("RECEIPT"));
}
{code}
The first thing I see wrong here is that you cannot NACK a message in a TX so that will definitely fail if you try and do it a second time as you've already NACK'd the message. My guess is that your first ACK is not including the TXID in the ACK an thereby just ACK'ing the message outside the TX.
> Aborting a STOMP 1.1 transaction after ACK/NACK leads to invalid state
> ----------------------------------------------------------------------
>
> Key: AMQ-6697
> URL: https://issues.apache.org/jira/browse/AMQ-6697
> Project: ActiveMQ
> Issue Type: Bug
> Components: stomp
> Affects Versions: 5.14.5
> Reporter: Markus Gerstel
>
> Reproducing the problem:
> * Receive a message via STOMP
> * Start a transaction
> * ACK (or NACK) the message within the transaction
> * Abort the transaction
> * ACK (or NACK) the message
> Expected behaviour:
> * The message is according to step #5 either ACKed or NACKed.
> Observed behaviour:
> * The message is neither ACKed nor NACKed, but stays in unacknowledged state
> * An exception is raised:
> org.apache.activemq.transport.stomp.ProtocolException: Unexpected ACK received for message-id [ID:(...)]
> at org.apache.activemq.transport.stomp.ProtocolConverter.onStompAck(ProtocolConverter.java:475)
> at org.apache.activemq.transport.stomp.ProtocolConverter.onStompCommand(ProtocolConverter.java:250)
> at org.apache.activemq.transport.stomp.StompTransportFilter.onCommand(StompTransportFilter.java:85)
> at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
> at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:233)
> at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:215)
> at java.lang.Thread.run(Thread.java:745)
> * an ERROR message is sent to the client
> As far as I can tell this is caused by code in both onStompAck() and onStompNack():
> https://git-wip-us.apache.org/repos/asf?p=activemq.git;a=blob;f=activemq-stomp/src/main/java/org/apache/activemq/transport/stomp/ProtocolConverter.java;h=b25860bf6895240c33a8643b6fcc731af126d32e;hb=refs/heads/master#l440
> With a STOMP 1.1 ACK/NACK, ackId == null, so the message entry is taken out of this.pedingAcks (sic!).
> When the transaction is aborted the message entry is then not put back into this.pedingAcks, so any subsequent ACK/NACK will find pendingAck==null, therefore acked==false, raising an exception.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)