Results 1 to 5 of 5

Thread: Acknowledge message on the Client by using Spring Integration

  1. #1

    Default Acknowledge message on the Client by using Spring Integration

    Hi,

    I have spring configuration:

    Code:
    <int:gateway id="gatewayAsynchService" service-interface="pl.firstdata.maqc.integration.GatewayAsynchService" >
            <int:method name="process" request-channel="requestChannel" />
        </int:gateway>
    
        <int:poller default="true" fixed-delay="250"/>
    
        <int:channel id="requestChannel">
            <int:dispatcher task-executor="simpleAsyncTaskExecutor"/>
        </int:channel>
    
        <bean id="simpleAsyncTaskExecutor" class="org.springframework.core.task.SimpleAsyncTaskExecutor" />
    
    
    
        <int-jms:outbound-gateway request-channel="requestChannel" request-destination="requestQueue"
                                  connection-factory="connFactory"/>
    
        <int-jms:message-driven-channel-adapter acknowledge="client" id="mdChannel" connection-factory="connFactory"
                                                selector="imie='ania'"
                                                destination="replyQueue" channel="replyChannel" />
    
        <int:outbound-channel-adapter id="replyChannel" ref="integrationAsynchService" method="logMessage"  />
    
        <bean id="integrationAsynchService" class="pl.firstdata.maqc.integration.IntegrationAsynchService"/>
    
        <jee:jndi-lookup id="requestQueue" expected-type="javax.jms.Destination" jndi-name="jms/queue/req"/>
    
        <jee:jndi-lookup id="replyQueue" expected-type="javax.jms.Destination" jndi-name="jms/queue/reply"/>
    
        <bean id="myTargetConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
            <property name="jndiName" value="jms/RemoteConnectionFactory"/>
        </bean>
    
        <bean id="connFactory" class="org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapter">
            <property name="targetConnectionFactory" ref="myTargetConnectionFactory"/>
            <property name="username" value="robert"/>
            <property name="password" value="sys"/>
        </bean>
    In message-driven-channel-adapter I have acknowledge="client" and that's works so that when no runtime exception is thrown in outbound-channel-adapter method (logMessage) than every message is consumed. When runtime exception is thrown then messages that wasn't delivered are not lost and remain in a queue. That's fine, but I would like to have possibility to steer with it for instance by invoking message.acknowledge();
    I would like not to acknowledge process untill I get all messages for example.

    How can I do it by using Spring Integration in a client?

  2. #2
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,022

    Default

    If you set 'extract-payload="false"' on the message-driven adapter, the payload of the message sent to 'replyQueue' will be the (unconverted) JMS Message.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  3. #3

    Default

    Thank you Gary for reply!

    I have noticed that when I (in the above example) set acknowledge="client" then the messages are not lost when the method logMessage in IntegrationAsynchService throw RuntimeException and messages remain in the queue. The messages are removed from the queue only then when the method ends successfully. That's great.

    I don't acknowledge messages by message.acknowledge().
    It looks like the invoke message.acknowledge() is not necessary. Does SI automatically acknowledge messages when they are received in client without error?

    I would be grateful for any hint what is a recommended way to do in this case in order to prevent messages loss (if I do something wrong)
    Last edited by RobertVox1977; Feb 20th, 2013 at 08:32 AM.

  4. #4
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,022

    Default

    Sorry - yes, I forgot that the listener container (used by the adapter) acks the message when the thread returns normally.

    So, no, there is no way to "batch" the acks using standard components. You would have to use a custom adapter that uses JMS (or Spring JMS) at a lower level.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  5. #5

    Default

    That behaviour is guite good for me.

    Now I'm sure how it works. Thanks a lot Gary!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •