[ 
https://issues.apache.org/jira/browse/CAMEL-8749?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Thomas Diesler updated CAMEL-8749:
----------------------------------
    Description: 
On a JMS message consumer route, we support

{code}
jms:...&acknowledgementModeName=CLIENT_ACKNOWLEDGE
{code}

The pattern is that a client may chose to process a batch of msgs before it 
acks. If batch processing succeeds the client calls Message.acknowledge(). If 
it fails, the client may choose to recover the msgs in the batch with 
Session.recover()

In a Processor we can now call Message.acknowledge() or  Session.recover(). 
However, even if the route (i.e. the client) does not call 
Message.acknowledge() it is called automatically in 
{{org.springframework.jms.listener.AbstractMessageListenerContainer}}

{code}
        protected void commitIfNecessary(Session session, Message message) 
throws JMSException {
                // Commit session or acknowledge message.
                if (session.getTransacted()) {
                        // Commit necessary - but avoid commit call within a 
JTA transaction.
                        if (isSessionLocallyTransacted(session)) {
                                // Transacted session created by this container 
-> commit.
                                JmsUtils.commitIfNecessary(session);
                        }
                }
                else if (message != null && isClientAcknowledge(session)) {
                        message.acknowledge();
                }
        }
{code}

This would not be correct if the route is the JMS client. Redelivery can only 
be achieved in the context of one message invocation

CrossRef: https://jira.spring.io/browse/SPR-12995


  was:
On a JMS message consumer route, we support

{code}
jms:...&acknowledgementModeName=CLIENT_ACKNOWLEDGE
{code}

The pattern is that a client may chose to process a batch of msgs before it 
acks. If batch processing succeeds the client calls Message.acknowledge(). If 
it fails, the client may choose to recover the msgs in the batch with 
Session.recover()

In a Processor we can now call Message.acknowledge() or  Session.recover(). 
However, even if the route (i.e. the client) does not call 
Message.acknowledge() it is called automatically in 
{{org.springframework.jms.listener.AbstractMessageListenerContainer}}

{code}
        protected void commitIfNecessary(Session session, Message message) 
throws JMSException {
                // Commit session or acknowledge message.
                if (session.getTransacted()) {
                        // Commit necessary - but avoid commit call within a 
JTA transaction.
                        if (isSessionLocallyTransacted(session)) {
                                // Transacted session created by this container 
-> commit.
                                JmsUtils.commitIfNecessary(session);
                        }
                }
                else if (message != null && isClientAcknowledge(session)) {
                        message.acknowledge();
                }
        }
{code}

This would not be correct if the route is the JMS client. Redelivery can only 
be achieved in the context of one message invocation



> JMS message always acknowledged even with CLIENT_ACKNOWLEDGE
> ------------------------------------------------------------
>
>                 Key: CAMEL-8749
>                 URL: https://issues.apache.org/jira/browse/CAMEL-8749
>             Project: Camel
>          Issue Type: Wish
>          Components: camel-jms
>            Reporter: Thomas Diesler
>             Fix For: 2.16.0
>
>
> On a JMS message consumer route, we support
> {code}
> jms:...&acknowledgementModeName=CLIENT_ACKNOWLEDGE
> {code}
> The pattern is that a client may chose to process a batch of msgs before it 
> acks. If batch processing succeeds the client calls Message.acknowledge(). If 
> it fails, the client may choose to recover the msgs in the batch with 
> Session.recover()
> In a Processor we can now call Message.acknowledge() or  Session.recover(). 
> However, even if the route (i.e. the client) does not call 
> Message.acknowledge() it is called automatically in 
> {{org.springframework.jms.listener.AbstractMessageListenerContainer}}
> {code}
>       protected void commitIfNecessary(Session session, Message message) 
> throws JMSException {
>               // Commit session or acknowledge message.
>               if (session.getTransacted()) {
>                       // Commit necessary - but avoid commit call within a 
> JTA transaction.
>                       if (isSessionLocallyTransacted(session)) {
>                               // Transacted session created by this container 
> -> commit.
>                               JmsUtils.commitIfNecessary(session);
>                       }
>               }
>               else if (message != null && isClientAcknowledge(session)) {
>                       message.acknowledge();
>               }
>       }
> {code}
> This would not be correct if the route is the JMS client. Redelivery can only 
> be achieved in the context of one message invocation
> CrossRef: https://jira.spring.io/browse/SPR-12995



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to