0

So here is the requirement.

  1. The process of publishing messages into a topic should occur within a transaction

  2. If the transaction succeeds then we return 0

  3. If the transaction fails then we return 1

I know how to publish messages into a topic. I am using JMS template to publish into topic.

jmsTemplate.convertAndSend(topic, event);

But how can I make sure this is within a transaction? Can someone use code and explain the above requirement?

I have searched similar questions for a possible solution to my query, but they are not the ones which resolves my issue. Please do not point to other answers.

africandrogba
  • 334
  • 1
  • 3
  • 21

1 Answers1

0
template.setSessionTransacted(true).

If the commit fails, an exception is thrown.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179