2

I want with jms:inbound-channel-adapter to read a jms message and apply treatment, if treatment throw exception i want that broker keep message

<int-jms:inbound-channel-adapter 
        id="jmsAdapter"
        session-transacted="true"
        destination="destination"
        connection-factory="cachedConnectionFactory"
        channel="inboundChannel"
        auto-startup="false">
    <int:poller fixed-delay="100"></int:poller>
</int-jms:inbound-channel-adapter>

I look code of jmsTemplate.doReceive

Message message = doReceive(consumer, timeout);
        if (session.getTransacted()) {
            // Commit necessary - but avoid commit call within a JTA transaction.
            if (isSessionLocallyTransacted(session)) {
                // Transacted session created by this template -> commit.
                JmsUtils.commitIfNecessary(session);
            }
        }
        else if (isClientAcknowledge(session)) {
            // Manually acknowledge message, if any.
            if (message != null) {
                message.acknowledge();
            }
        }

We acknowledge after reading directly

How can i do ?

Samir
  • 51
  • 3
  • I forget to specify that i want to use client acknowledge – Samir May 19 '15 at 13:23
  • Well, why don't use `transactionManager` (e.g. `JmsTransactionManager`) on the `poller` to have the robust *treatment* with transactions and without client acknowledge? – Artem Bilan May 19 '15 at 13:36
  • I cant use transactionManager because that not match to my application need. I want to have a total control – Samir May 19 '15 at 13:38
  • Well, how about do not use `session-transacted="true"`? `false` I mean. And don't use `CLIENT_ACKNOWLEDGE`, too. – Artem Bilan May 19 '15 at 14:04
  • Default value is AUTO_ACKNOWLEDGE – Samir May 19 '15 at 14:08
  • It's much easier with a message-driven-channel-adapter. When using local transactions, and an inbound channel adapter, the `receive()` is committed before the flow is invoked. If you must use a polled adapter, you need to use a transaction manager. – Gary Russell May 19 '15 at 14:12
  • I have a specific use, i have a thousand of queue (i cant reduce this number). I cant use message-driven-channel-adapter Perhaps i mut write my jms endpoint ? – Samir May 19 '15 at 14:17

0 Answers0