reQueue message if SOAP calls fails

Five Stars

reQueue message if SOAP calls fails

Hi Community !

 

I'm quiet new to Talend and i'm still learning but here's my issue :

 

I've a route which takes a xml message from the Queue and pass it to the cSOAP component.

I'd like to find a way to requeue the message if the SOAP call fails, is it possible ? 

Should i use a job to do that ?

 

 U0FRIm4.png

It currently uses a cErrorHandler but it doesn't fit my needs.

 

I use :

- Talend ESB 7.1.1.20181026_1147

- ActiveMQ

 

Thanks !

Moderator

Re: reQueue message if SOAP calls fails

Hello,

Here is a cLoop component which processes messages repetitively and possibly in different ways.

https://help.talend.com/reader/1kWlkHx_7IKc6y3wZ0GMsg/eTqvr3f6CLDXbPiNYEiVng

Let us know if it helps.

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Five Stars

Re: reQueue message if SOAP calls fails

Hello,

 

I don't need to retry/loop it x times but put it into a queue if the SOAP action/call fails.

 

Thanks,

Employee

Re: reQueue message if SOAP calls fails

Hi,

 

    In that case, the first step you need to do is to capture the input message to a tHashOutput for later use.

 

    Then you can send the data to SOAP request and based on the success or failure message, you can create a RunIf condition to read the Hash value using tHashInput and pass the value to output failure queue.

 

     Please note that you will have to clear the Hash details by reading the data using tHashInput for both success and failure cases and by selecting the hash clear option.

 

     tHashInput and tHashOutput may not visible in the Palette. In that case, you need to go to Palette preference to select these components.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

Five Stars

Re: reQueue message if SOAP calls fails

Hello ! 

 

Thank you for you reply !

 

Is this the good way of doing it ? How can i access the message within the "Run if" condition ? 

mb9QGDi.png

 

Best regards and Happy new year ! Robot Happy

Highlighted
Employee

Re: reQueue message if SOAP calls fails

Hi,

 

    A minor modification is needed as you need to first collect the output of the SOAP request back to a context variable (may be by using a tjavarow to assign the value to context variable) and then initiate the run if conditions.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

Seven Stars

Re: reQueue message if SOAP calls fails

Our approach to this (tREST rather than tSOAP, but the same principle should apply) by writing the failed content to a file and calling a subsequent job that retries the failures. This could be the same job but with context variables that define the input and output files, or a separate job.

 

We use a separate job with an additional delay in between calls in case the failure was an API rate limit, and we are happy to only retry it once. We could call the retry job in a loop with some logic to detect records that are never going to work, but we decided that that would be a manual process if necessary.

Eight Stars

Re: reQueue message if SOAP calls fails

Hi there

 

There's absolutly no need of a job to do this ! 

 

1) Between your MQ and your cSoap use a cSetProperty to store the initial message body into a property

 

2) after your Exception component, add a cSetBody that will put your property into the body again, then add a cJMS component to send the message back to the queue.

 

3) beware of dead loop , there are several options for this, for instance you could add a cProcessor that will count the number of times the same message has been executed, or whatever you want.

 

Arnaud

Five Stars

Re: reQueue message if SOAP calls fails

Thanks for those responses

 

Now the thing is that i need to print both message into a file.

(message i sent to the soap request and message i get back from the soap request)

 

Any ideas ? 

 

Eight Stars

Re: reQueue message if SOAP calls fails

Very easy if you store the sent message into a header or a property as I said before. Just add a cProcessor at the end of your route with

 

exchange.getIn().setBody( exchange.getIn().getHeader("myHeader",String.class) + exchange.getIn().getBody(String.class) ) Then add a cMessagingEndpoint to store this into a file.

Five Stars

Re: reQueue message if SOAP calls fails

Hello !

 

When you says :

 

2) after your Exception component, add a cSetBody that will put your property into 
the body again, then add a cJMS component to send the message back to the queue.

 cErrorHandler can't be a start Node. 

 

3HC8zb1.png

Eight Stars

Re: reQueue message if SOAP calls fails

Hi

Instead of gfcErrorHandler, use cOnexception --> cProcessor

 

Then you can call any java code you want, in cProcessor or from a bean for easier development.

Five Stars

Re: reQueue message if SOAP calls fails

Hi !


Thanks for your help, i'll try to make it work following your guidance. I'm not used to ESB routes so i need to learn Smiley Tongue

 

  use a cSetProperty to store the initial message body into a property


Not sure how i can do that .... 

Eight Stars

Re: reQueue message if SOAP calls fails

cProcessor : 

exchange.getIn().setProperty( "pInitialBody", exchange.getIn().getBody(String.class)) ;

 

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

An API-First Approach to Modernizing Applications

Learn how to use an API-First Approach to Modernize your Applications

Watch Now

Talend API Designer – Technical Overview

Take a look at this technical overview video of Talend API Designer

Watch Now

Getting Started with APIs

Find out how to get started with APIs

Read