Announcement Announcement Module
Collapse
No announcement yet.
MDP that calls rest web service Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      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..

      Comment


      • #4
        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.

        Comment


        • #5
          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.

          Comment


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

            Comment


            • #7
              desperate times need desperate mesasures

              Comment

              Working...
              X