Six Stars

How to check if SQL service is working or not

Hi,

  I have a user case where I have data in queue (like Active MQ) where I am calling it in route and sending it to DI job using cTalendJob,

where in DI job i want to store it into database. But if database server is not working like (service is not working , connection failed due network issue) i am loosing my queue. So, I don't want to lose my data in queue.

 

I want to know if there any component where It can wait until connection can reestablish the connection.

2 ACCEPTED SOLUTIONS

Accepted Solutions
Employee

Re: How to check if SQL service is working or not

You should not use a tDie in a cTalendJob route job.  tDie are for batch job, not for route.  

 

You should use a tRouteFault and throw back a fault into the orchestration route.   And just before calling the cTalendJob, add a cJavaDSLProcessor with the code .handleFault().

 

Your cMQConnectionFactory should have transaction checked.

Also why are you doing a tFlowToIterate in the job?  You can extract the body values of the tRouteInput directly using a tMap or tXMLMap and send to the MySQLOutput.

 

The tRouteFault should be onSubjobErrror on tRouteInput.

Four Stars

Re: How to check if SQL service is working or not

I got the answer just reading some articles on Camel Documentation.

The .handleFault() needs to be added just after the first component of the Route.

8 REPLIES
Moderator

Re: How to check if SQL service is working or not

Hi,

From your description, you can try to build a loop in your work flow.
Here is a tInfiniteLoop component which allows you to execute a task or a job automatically, based on a loop. Or You can have a look at tSleep component which implements a time off in a Job execution.

 

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.
Six Stars

Re: How to check if SQL service is working or not

Even I use the tSleep i will loose my queue so, what i am trying to achieve is same use-case while using twaitforfile where I have to wait until db connection is established 

Employee

Re: How to check if SQL service is working or not

Are you using transaction on the cMQConnectionFactory?  If you are in a transaction, you should be able to abort the transaction and that should not take the message off the queue. Are you reading the message from the queue in the DI job or on the route itself? 

Six Stars

Re: How to check if SQL service is working or not

2017-06-29 11_16_46-Talend Data Fabric (6.3.1.20161216_1026) _ ESBDemo (Connection_ Local).png2017-06-29 11_17_01-Talend Data Fabric (6.3.1.20161216_1026) _ ESBDemo (Connection_ Local).png

 

My usecase is get the queue in route and send it to the DI job which will store the queue in DB but for some reason if DB is not working i am loosing my queue how can i prevent my queue from loosing the data

Employee

Re: How to check if SQL service is working or not

You should not use a tDie in a cTalendJob route job.  tDie are for batch job, not for route.  

 

You should use a tRouteFault and throw back a fault into the orchestration route.   And just before calling the cTalendJob, add a cJavaDSLProcessor with the code .handleFault().

 

Your cMQConnectionFactory should have transaction checked.

Also why are you doing a tFlowToIterate in the job?  You can extract the body values of the tRouteInput directly using a tMap or tXMLMap and send to the MySQLOutput.

 

The tRouteFault should be onSubjobErrror on tRouteInput.

Four Stars

Re: How to check if SQL service is working or not

I am in a similar situation on Talend Data Service Platform 6.2.1 despite my Talend Job is not about MySQL.
I tried to add a cJavaDSLProcessor with .handleFault() method but I always got an error like "The method .handleFault() is not defined for the type ExpressionNode" (or similar if I add a cTry block before). What am I doing wrong?

Here is the interested part of my route:

.to("file://"
+ context.message_dir
+ "?noop=true"
+ "&autoCreate=true"
+ "&flatten=false"
+ "&fileName=refund_${in.header.ProcessingDate}_${in.header.platform}_order_${in.header.OrderNumber}.json"
+ "&charset=UTF-8" + "&bufferSize=128")
.id("RefundESBMagento_cFile_1")
.handleFault().id("RefundESBMagento_cJavaDSLProcessor_1")
.to(endpoint_cTalendJob_1).id("RefundESBMagento_cTalendJob_1")
.convertBodyTo(String.class) 

Thanks in advance,

Manuel

Four Stars

Re: How to check if SQL service is working or not

I got the answer just reading some articles on Camel Documentation.

The .handleFault() needs to be added just after the first component of the Route.

Moderator

Re: How to check if SQL service is working or not

Hello,

Thanks for sharing your solution on forum.

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.