Andrei Shakirin created CXF-5769:
------------------------------------
Summary: JMS message redelivery in CXF 2.7.X
Key: CXF-5769
URL: https://issues.apache.org/jira/browse/CXF-5769
Project: CXF
Issue Type: Improvement
Components: Transports
Affects Versions: 2.7.11
Reporter: Andrei Shakirin
I am trying to get working the JMS message redelivery in CXF 2.7.X.
Use case: CXF client sends JMS message to the service one-way operation.
Business implementation of oneWay method throws runtime exception.
Expected: message will be redelivered according RedeliveryPolicy and finally
placed in dead queue, if all attempts are failed.
In CXF 3.0.0 this works out of the box, it is enough to set sessionTransacted
property of the JMSListener (via JMSConfiguration) to true.
In CXF 2.7.X the problem is that JMSDestination onMessage() method (is JMS
listener) doesn't throw exception, because of the following check:
<code>
//need to propagate any exceptions back to Spring container
//so transactions can occur
if (inMessage.getContent(Exception.class) != null && session !=
null) {
PlatformTransactionManager m =
jmsConfig.getTransactionManager();
if (m != null) {
TransactionStatus status = m.getTransaction(null);
JmsResourceHolder resourceHolder =
(JmsResourceHolder) TransactionSynchronizationManager
.getResource(jmsConfig.getConnectionFactory());
boolean trans = resourceHolder == null
|| !resourceHolder.containsSession(session);
if (status != null && !status.isCompleted() && trans) {
Exception ex = inMessage.getContent(Exception.class);
if (ex.getCause() instanceof RuntimeException) {
throw (RuntimeException)ex.getCause();
} else {
throw new RuntimeException(ex);
}
}
}
}
</code>
resourceHolder.containsSession(session) always finds session and returns true
=> exception is never thrown from onMessage => message will not be redelivered.
The sessionTransacted is set to true and spring transaction manager
JmsTransactionManager is configured in JMSConfiguration.
--
This message was sent by Atlassian JIRA
(v6.2#6252)