user3198603
user3198603

Reputation: 5816

How to support transaction/failover on jms?

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

Answers (1)

Julio
Julio

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

Related Questions