Hi folks,
I recently realised that when JMS 0.24.0 publishes a message
asynchronously into non-existing destination over anonymous relay on
Qpid Broker-J v7.0 and transaction is committed, no exception is
reported to the caller of commit. I expected a JMSException to be
thrown on session.commit(), but commit was performed successfully.
This situation can potentially result in message loss, as client
application can consider such transaction successful.
The following code snippet demonstrate the problem:
try( Connection connection =
connectionFactory.createConnection(username, password))
{
Session session = connection.createSession(true,
Session.SESSION_TRANSACTED);
MessageProducer messageProducer = session.createProducer(null);
Queue nonExistingQueue = session.createQueue("nonExistingQueue");
messageProducer.send(nonExistingQueue,
session.createTextMessage("testMessage"));
session.commit();
}
I originally thought that it is a fault of Broker-J but after looking
into Broker code I came to a conclusion that Broker behaviour could be
spec compliant.
On attach, the client specifies the following outcomes on the source:
outcomes=[amqp:accepted:list, amqp:rejected:list, amqp:released:list,
amqp:modified:list]}
On receiving a message for non-existing destination, the anonymous
relay generates rejected outcome as 'rejected' outcome is in the list
of source supported outcomes. The Broker replies with settled
disposition having rejected outcome with error 'not-found'. Here is an
example of disposition
Disposition{role=receiver,first=1,last=1,settled=true,state=TransactionalState{txnId=\x00\x00\x00\x00,outcome=Rejected{error=Error{condition=not-found,description=Unknown
destination 'nonExistingQueue'}}}}
The JMS client receives the disposition and reports an exception
"javax.jms.InvalidDestinationException: Unknown destination
'nonExistingQueue' [condition = amqp:not-found]" into
ExceptionListener if one is set.
If no ExceptionListener is set, the exception is logged. Thus, if
ExceptionListener is not set, a message loss can occur.
The previous 6.x versions of Broker-J detach the link with error
'not-found' but v7.0 simply settles with the rejected outcome.
It seems both parties adhere to the AMQP spec requirements but the
result is surprising. I am not sure how to resolve this problem. Part
of me thinks that detaching of the link on broker side could be the
best solution of the problem, but, that would make broker behaviour
JMS specific rather than AMQP specific. Any thoughts about how to
solve this problem are highly appreciated.
Kind Regards,
Alex
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]