One Star

Best practice to insert in a database with a route

Hi guys.
I would like to know if there a best practice to fast inject some data, coming from a JMS queue, in a database.
Of course, I want to manage the commit or the rollback option when inserting...
For the moment I have designed a route like this :
cJMS -> cTalendJob -> cMessageEndPoint
In the cTalendJob, I have to insert the message given by the cJMS in 7 tables. If an error occures, I must rollback the DB transaction and send a error code using a tRouteFault for example...
My questions are :
- how can I use the tPrejob and the tRouteInput components?
- If I use a shared connexion, how can I detect an error if an insert goes wrong? (I don't want to use the rejected rows because it slows the transaction...)
Any idea?
Best regards
2 REPLIES
Community Manager

Re: Best practice to insert in a database with a route

Hi
You have to share the DB connection between all of the DB output components if you want to manage the commit or the rollback option, use a txxxConnection to create a DB connection, and check the 'use an existing connection' option on all the DB output components, in addition, check the 'die on error' option on all DB output component so as to make the job stop once an error occurs during the job execution.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: Best practice to insert in a database with a route

Thanks Shong.
This is exactly what I've made in the job I call in the route with the cTalendJob Component.
Regards.