Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8000893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:56:22+00:00 2026-06-04T15:56:22+00:00

I am working on a stand-alone application that uses both JMS and Hibernate. The

  • 0

I am working on a stand-alone application that uses both JMS and Hibernate.

The documentation suggests JTA has to be used if I want to have transactions across both resources.

However, right now with a @Transaction annotated DAO method (and HibernateTransactionManager), this already seems to work. When I call send() on the JmsTemplate, the message is not immediately sent, but rather the JMS session is committed with the Hibernate session as the method returns.

I didn’t know how this is possible without the JtaTransactionManager, so I checked the source code. It turns out both the wrapper for Hibernate and JmsTemplate registers the sessions with TransactionSynchronizationManager and the JMS session will be committed when the Hibernate session commits.

What’s the different between this and a JTA transaction. Can I use this to replace the latter??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T15:56:23+00:00Added an answer on June 4, 2026 at 3:56 pm

    In short no, you can’t get support for 2-phase commit without a JTATransactionManager and XA aware datasources.

    What you are witnessing is a co-ordination of two Local Transactions supporting 1-phase commit only. Roughly performing this sequence of events…

    1. Start JMS Transaction
    2. Read JMS message
    3. Start JDBC Transaction
    4. Write to database
    5. Commit JDBC Transaction
    6. Commit/Acknowledge JMS

    The JMS transaction will be started first wrapping the nested JDBC transaction, so that the JMS queue will rollback if the Hibernate/JDBC commit fails. Your JMS Listener Container should be setup not to acknowledge="auto" and instead wait for the Hibernate transaction to complete before sending the acknowledgement.

    If you only have these two resources then the issue you will have to consider is when Hibernate succeeds in persiting then you get an Exception before you can acknowledge the JMS server. Not a big issue as the JMS message is not lost and you will read it again.

    However

    1. You must write your MessageListener to handle duplicate messages from the server

    2. You must also handle a message that cannot be processed due to bad data and ending up in an infinite loop of trying to comsume it. In this case the server may be configured to move the message to a “dead message queue”, or you deal with this yourself in the MessageListener

    Other options and further reading

    If your JMS server does not support XA (global) transactions this is pretty much your only solution.

    If JMS server does support XA transactions but JDBC doesn’t then you can use a JTATransactionManager and use the LastResourceCommitOptimisation. There are open source JTATransactionManagers you can use like JOTM

    This JavaWorld article goes into more detail on your problem space.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are working on a new application that uses C#, WPF4, Prism4 and MEF.
I tried working Ftp download stand alone application and it works fine. But when
I'm working on a unique windows desktop application that requires both a standalone and
Working on a website that has Employee and Branch entities, using a database table
i have the following situation, i have a Reporting layer(stand alone) in asp.net application(NOT
I am working on a C# application that involves using XML schema file as
Environnement : Simple Java stand-alone application. AspectJ jar inside. I've two projects. The first
I'm working with a flash application that runs as a standalone executable by way
I'm working at a helpdesk application where i have a standalone script that queries
We are currently using SVN to develop an internal application that has most of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.