Template for saving an object, then a queue in RabbitMQ
I have a problem with RabbitMQ. I have a Notification class that I am trying to store in a database from a web service running under tomcat and then queue that object id to RabbitMQ for the consumer to pick up.
The problem is that the message is being queued before the transaction completes, so the consumer cannot find the record.
I tried to create a separate transaction for only the persistence part via Propagation.REQUIRES_NEW, but I got a Hibernate exception saying this:
org.hibernate.HibernateException: Illegally tried to bind a proxy with two open sessions
Is there a pattern for this that people usually do to solve this problem?
Any help is appreciated.
source to share
In response to your comment after mine; a simple solution would be to use the linked transaction manager as described in the Dave Syer JavaWorld article .
source to share