Developed a flow service “A” which fetches data from a database(“DB1”) and publishes it to a publishable document(The publishable document contains a document list ) .
Developed a flow service “B” to Subscribe the published document(which contains a document list published by the flow service “A”) and insert into a database “DB2” .
The “B” (Subscribe) flow service has the below logic.
i) Subscribes the published document which contains a document list ( published the flow service “A” )
ii) Loop the document list
Inside the loop
Try
{
a) Start transaction
b) Insert adapter (for header table)
c) Batch insert adapter(for child table)
d) Commit transaction
}
catch
{
Invoked - pub.flow:getLastError
Rollback Transaction
}
Created a Trigger “T”
Which calls the flow service “B” when the publishable documents has data
Works State : working fine if I maintain a correct set of data
Then, Executed flow service “A”
(Internally the trigger “T” calls the flow service “B” and inserts the data into “DB2” correctly)
Issue : If I purposely maintain a wrong set of data.
Then, executed flow service “A”
Internally the trigger "T" calls the flow service "B" and try to insert the data into "DB2", due to some constraint the data is not inserted
And the Transaction is Rolled back
[b]But trigger "T" repeatedly calls the Subscribe flow service ("B") and keep on tries to insert the wrong records and rollbacks.
How can I handle / stop the repeated execution of the flow service “B” if wrong set of data maintained ?
[/b]
Regards,
Daniel Sebastian .C
To answer your question, if you rollback the transaction, then it is expected that you will get the same message again. Are you in your catch-block also calling pub.flow:throwExceptionForRetry?
What behavior do you actually want if the database insert fails?
Generally you would want it to be logged to the service audit database so you can manually resubmit it later (when you have fixed the data issue). In that case, you don’t actually need the transaction management and try-catch block, as the JDBC service will throw an exception. Just configure service auditing on the top-level service to log on error and include pipeline on error. That should ensure only a single execution attempt for each message.
In catch block I didn’t invoke pub.flow:throwExceptionForRetry.
(What behavior do you actually want if the database insert fails? ) If any exception occurs in the flow service, it should go into catch block and gets finished.
But now when exception occurs(inside subscription service) the trigger repeatedly calls again and again the subscription service.
My need is, if exception occurs the flow service should go into catch block and gets finished, It should not execute repeatedly.
And can you please elaborate the part
" [Generally you would want it to be logged to the service audit database so you can manually resubmit it later (when you have fixed the data issue). In that case, you don’t actually need the transaction management and try-catch block, as the JDBC service will throw an exception. Just configure service auditing on the top-level service to log on error and include pipeline on error. That should ensure only a single execution attempt for each message. ]"
Because the subscribe flow service will receive a document(which contains a document list ).
And i should iterate(loop over) the document list and insert into the database. So that i perform start and insert transaction inside try and roll back transaction inside catch.
Are you sure that the publishing service is not publishing each instance of the document and it is publishing all the once. The subscriber service and trigger looks ok as there is no retry enabled.