I have a scenario where we use spring jms to post events to queue and update status in database but sometimes posting to end queue is success but updating status to database is failed so in this particular scenario the events posted to queue should be rolled back as updating to database is failed,so posting to queue is in another framework and updating to database is another framework so we cant put the event posting to queue and database update at same place we used currently JMSTEMPLATE.EXECUTE(new ProducerCallback{}) to post in queue.
I am aware of when execution reaches end of JMSTEMPLATE.EXECUTE(new ProducerCallback{}) method it will commit but my database updation logic is outside the JMSTEMPLATE.EXECUTE(new ProducerCallback{}) method so I want to control the event posting to queue based on the successful insertion in to database that means if insertion of success response fails events posted to queue should be rolled back.
Can any one help me out to figure out how to achieve this scenario.
Thanks in advance.
You need to perform the database update within the doInJms() method too. If an exception is thrown, the JMS updates will roll back.