I don't see in your code where you're calling rollback either on any Hibernate or JMS resource.
Typically in this kind of scenario you'd want the consumption of the message and the database operation to be atomic to ensure the integrity of your data (i.e. one message equals one database operation). Without atomicity you risk losing or duplicating data. These kinds of guarantees are really easy to configure in a Java EE environment (e.g. using container-managed transactions and an XA JDBC datasource), but I'm not familiar enough with Spring to make any recommendations. The bottom line here is that I think your application and/or architecture is the problem here and not the message broker. Justin ----- Original Message ----- From: "rsahadevan" <priyavira...@gmail.com> To: users@activemq.apache.org Sent: Friday, June 2, 2017 2:20:07 PM Subject: Re: ActiveMQ Embedded with Tomcat missing messages while restart HI Justin, What you understood is correct. Consumer is writing to database. I tried with rollback and is not happening. Commit is failing in the DB and not happening rollback into activemq_msgs. This is the reason I was thinking about this approach . Please let me know anything I am missing in config public void onMessage(Message message) { try { PlatformTransactionManager transactionManager = Context.getBean(Context.Name.TRANSACTION_MANAGER); TransactionStatus transaction = transactionManager.getTransaction(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRED)); updateDynamicBalance(new Integer(message.getIntProperty("entityId")),new Integer(message.getIntProperty("userId")),new BigDecimal(message.getDoubleProperty("amount")),message.getStringProperty("mediationKey")); transaction.flush(); return; } catch (Exception e) { LOG.error("Generating payment", e); } Spring Config ----------------- <jms:listener-container connection-factory="jmsConnectionFactory" transaction-manager="transactionManager" acknowledge="transacted"> <jms:listener ref="processBalanaceMDB" destination="queue.jbilling.balance"/> </jms:listener-container> -- View this message in context: http://activemq.2283324.n4.nabble.com/ActiveMQ-Embedded-with-Tomcat-missing-messages-while-restart-tp4726828p4726976.html Sent from the ActiveMQ - User mailing list archive at Nabble.com.