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 7533683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:47:43+00:00 2026-05-30T05:47:43+00:00

In our backend there are several services that send and receive messages via JMS

  • 0

In our backend there are several services that send and receive messages via JMS with Apache ActiveMQ. Each service has a single session to the ActiveMQ broker. We now want to do the following (pseudo code):

Service s1:

Message m = createMessage("s2","Hello World")
sendMessage(m)
try {
   Message answer = commit()
   ...
} catch (TransactionFailedException e){
   ...
}

Service s2:

onMessageReceive:
try {
   Message m = getReceivedMessage()
   Message answer = doSomeStuff()
   send(answer)
} (Exception e) {
   rollback()
}

The commit obviuosly has to block until the answer arrives or the transaction failes. It should also be possible that service s2 creates a new nested transaction because s2 is sending a message to another service. How can transactions from ActiveMQ be used to achieve this behaviour? There are some examples available but in these examples transactions are merely used as a batch mechanism to send messages.

  • 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-05-30T05:47:45+00:00Added an answer on May 30, 2026 at 5:47 am

    I’m interpreting you question to mean that you want a failure of work in s2 to cause an ongoing transaction in s1 to be rolled back.

    So you want

    s1 do some work
    
    s2 do some work
    
    if ( s2 OK )
       perhaps do even more work in s1
       commit s1
    else
       rollback s1
    

    The asynchronous model of JMS is not classically designed for this purpose. The fundamental reason is because

    1. During a transaction resources (eg database records) are locked – s1 has done some work, until the transaction has resolved those resources must be kept locked.
    2. Asynch processing is designed to decouple s2 work from s1 work, s2 work might happen many minutes or indeed days after the request was placed on the queue. S2 can’t know whether or not s1 is still waiting for him. The whole design point of JMS is to decouple processing in s1 and s2.

    There are two approaches to achieving coordination between s1 and s2:

    One is to use true distributed transactions, using a protocol other than JMS, for example EJBs can propagate transactions from one process to another, or use WS-AtomicTransaction and web Services. This does add operational complexity – you have to manange transaction logs and scenarios where you have a long-term failure of one component.

    The alternative is to design the two cooperating systems to robustly handle “compensating” work. You accept that, for example s2 may fail, and have secondary processing to deal with resending requests, dealing with timeouts etc. In the end you may come down to some situations where humans need to be involved, but with good design these situations can be minimal. In large scale systems there’s often no alternative to this, for example an airline’s booking system and a hotel chain’s booking system may well not be designed for distributed transaction coordination so there’s no alternative to having some careful processing to manage reserving flights and rooms.

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

Sidebar

Related Questions

We have a C# client app that communicates to our C# backend service via
One of our 'frontend' developers keeps requesting from us backend developers that the backend
We have a couple of .asmx soap web services that handle communication between our
We're starting to experiment with implementing our backend services using CDI. The scenario is
Our application uses several back-end services and we maintain wrappers which contain the methods
Our application provides multiple query interfaces that are basically just text inputs. Is there
Our websites article backend does not allow access to anything above </head> which prevents
We are currently replacing our product search from mysql to a SOLR backend. Our
My company provides a large .NET service-oriented solution. The services layer interact with a
My Company is running several international websites for selling insurance products. Our current setup

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.