Mannekenpix
Mannekenpix

Reputation: 752

Spring Integration poller hangs or stop after a while

I have an application which reads JMS message coming from a HornetQ.

<int-jms:message-driven-channel-adapter
            id="myJmsChannelAdapter"
            channel="myJmsChannel"
            connection-factory="myCredentialsConnectionFactory"
            destination-name="${my.jms.topic}"
            pub-sub-domain="true"
            subscription-durable="${my.jms.subscription.durable}"
            client-id="${my.jms.client.id}"
            durable-subscription-name="${my.jms.subscription.name}"
            />

When a message arrive, I treat them via a poller

<!-- Send Jms message one by one to creation -->
<int:bridge input-channel="myJmsChannel" output-channel="jmsMessageCreateInputChannel">
    <int:poller max-messages-per-poll="1" fixed-delay="100">
        <int:transactional transaction-manager="transactionManager" propagation="REQUIRES_NEW"/>
    </int:poller>
</int:bridge>

The poller call a chain which store the content of the message in my DB

<chain id="jmsMessageCreate" input-channel="jmsMessageCreateInputChannel">
    <!-- extract the operation from the message itself -->
    <int-xml:xpath-header-enricher>
        <int-xml:header name="operation" xpath-expression="name(./node())" overwrite="true"/>
    </int-xml:xpath-header-enricher>

    <service-activator expression="@jmsMessageService.createNewJmsMessage(payload, headers['operation'])"/>
    <!-- have a JPA entity in the payload -->
    <gateway request-channel="persistEntityChannel"/>
    <logging-channel-adapter logger-name="JmsLogger" expression="'JMS message with operation ['+headers['operation']+'] created in DB'"/>
</chain>

My problem is the following, sometimes, for no apparent reason and without any error message in the logs, my messages are no treated anymore. The chain id jmsMessageCreate is not called anymore like if the poller stopped working. If the server is restarted, it works well again but I have lost the JMS messages that were sent between the moment the poller stopped and the moment the server is restarted.

I really don't know where to look or what to do to prevent that. Maybe a change in the config?

Thanks in advance for your help.

Upvotes: 0

Views: 1580

Answers (1)

Gary Russell
Gary Russell

Reputation: 174494

Most likely the poller thread is "stuck" somewhere in your code. Use jstack <pid> to take a thread dump to see what the thread is doing. You can use jps to find the pid.

To avoid losing messages you should set acknowledge="transacted" on the message-driven adapter - this was changed to default to true in version 4.2.

You should not be using QueueChannels and pollers in this environment - the threading is managed by the message-driven adapter. With a queue channel, even with transacted sessions, the container will commit as soon as the message is put in the queue.

Upvotes: 1

Related Questions