Results 1 to 7 of 7

Thread: MDP that calls rest web service

  1. #1
    Join Date
    Nov 2005
    Location
    US of A
    Posts
    43

    Question MDP that calls rest web service

    I am trying to develop an integration system that hooks together 2 third party systems, and on receiving a 'sync' message from app A I need to invoke 2 web services on app B.

    I would like to manage the ACK so that in case situations like the 1st call succeeds and 2nd call fails, the message still remains in the queue. I use MessageListenerAdapter and DefaultMessageListenerContainer via the JMSTemplate.

    How do I get control of when to 'ACK' the message ? Any code snippets ?

    TIA
    -jv

  2. #2
    Join Date
    Jan 2008
    Location
    San Diego
    Posts
    780

    Default

    Quote Originally Posted by jvictor View Post
    I am trying to develop an integration system that hooks together 2 third party systems, and on receiving a 'sync' message from app A I need to invoke 2 web services on app B.

    I would like to manage the ACK so that in case situations like the 1st call succeeds and 2nd call fails, the message still remains in the queue. I use MessageListenerAdapter and DefaultMessageListenerContainer via the JMSTemplate.

    How do I get control of when to 'ACK' the message ? Any code snippets ?

    -jv
    Just use a transaction. If one of the WS calls throws an exception, the transaction will abort and the message will be redelivered.

    Note that you will need to ensure that the WS calls are idempotent in your scenario or you WILL have issues.

  3. #3
    Join Date
    Nov 2005
    Location
    US of A
    Posts
    43

    Default

    I tried adding

    <property name="sessionTransacted" value="true" /> to

    <bean id="jmsContainer"
    class="org.springframework.jms.listener.DefaultMes sageListenerContainer">
    ....
    <property name="sessionTransacted" value="true" />
    </bean>


    will that do the trick ?

    Thanks for taking the time..

  4. #4
    Join Date
    Jan 2008
    Location
    San Diego
    Posts
    780

    Default

    Session transacted means that it typically ignores the message ack mode. I don't think that will allow you to not ack the message if you decide your processing isn't going to complete.

    Typically, you should be doing the receive of your messages within a transaction. If you specify a transaction manager for your listener container, it will automatically wrap the receive in a transaction.

  5. #5
    Join Date
    Nov 2005
    Location
    US of A
    Posts
    43

    Default

    I added
    Code:
    <property name="sessionTransacted" value="true" />
    		<property name="sessionAcknowledgeMode">
    			<value>2</value>
    		</property>
    to the jmsTemplate and DefaultMessageListenerContainer bean

    further more I added

    Code:
    <property name="messageConverter">
    			<null/>
    		</property>
    to the messageListener so that we get the Raw message in the receiver class

    and finally the receive method was changed to

    Code:
    TransactionStatus txnStatus = jmsTransactionManager.getTransaction(new DefaultTransactionDefinition());
    
    MyMsgIfc myMsg = (MyMsgIfc) objMsg.getObject();
    
    handleMsg(myMsg );
    // Acknowledge only if everything went fine.
    objMsg.acknowledge();
    jmsTransactionManager.commit(txnStatus);
    Now stuff works as it should..

    The next challenge is to handle poisson messages.

  6. #6
    Join Date
    Jan 2008
    Location
    San Diego
    Posts
    780

    Default

    I prefer not to handle transactions programattically but if it works for ya...

  7. #7
    Join Date
    Nov 2005
    Location
    US of A
    Posts
    43

    Default

    desperate times need desperate mesasures

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
  •