Reputation: 5816
At back end i want the atomic transactions which means that
try{
get database connection
update employee record;
update department record;
produces messages 1 on queue1
produces messages 2 on queue2
// some exception occured
}
finally{
connection.rollback();
// how to roll back the messages from queue
}
similarily if message broker is down how will i ensure , message is deilvered once it is up.
I am using ActiveMQ
Upvotes: 0
Views: 1000
Reputation: 718
Assuming you have a JmsSession to send the messages, you can do jmsSession.commit()
and jmsSession.rollback()
to complete the jms transaction.
If you want the messages to be persistent, i.e. they can be delivered after jms server crash, you can set the delivery mode of the message to be persistent: jmsMessageProducer.send(msg, DeliveryMode.PERSITENT)
See this for details:
http://docs.oracle.com/javaee/6/api/javax/jms/Session.html
Upvotes: 1