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

  • Home
  • SEARCH
  • 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 9237361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:31:08+00:00 2026-06-18T07:31:08+00:00

I have a stand alone Java process that is reading messages off of a

  • 0

I have a stand alone Java process that is reading messages off of a JMS durable topic and submitting them to threadpool for processing. I am doing it this way for obvious concurrency reasons, but maintain the order of processing of those messages, I am still submitting them to a single thread pool. Now here are my concerns relating to JVM crash..

–Non Transactional
I am NOT reading and processing every message in a Transactional context, which I avoided as it slows down my process. So, I am accumulating messages in the blocking queue of the threadpool. But if JVM crashes while say 10 messages are in the threadpool waiting to be processed, I will lose that data.

–Transactional
I believe if I read and process each message in a transaction, if something goes wrong that message will be redelivered to the process when it comes backup.

Since it is a common problem to many people working in low-latency systems, wondering how experienced people approach this problem? Thanks.

  • 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-18T07:31:09+00:00Added an answer on June 18, 2026 at 7:31 am

    Peter’s AFAIK is correct. One way to work around this is, if the pattern is applicable to you, is use some sort of demarcation to create different queues to group messages into. That is to say, this requirement frequently breaks down to mean something like “all messages for one account must be processed in order“. So if you have something similar to this, you can create either:

    • One topic and have multiple subscribers each using an exclusive selector (or sub-topic patterns)
    • Multiple topics with each one having a single subscriber.

    Then your publisher must determine:

    • The headers on the published message so the corrects selector is effected for the subscriber, or
    • The correct sub-topic to publish on, or
    • The correct topic to publish on

    An easilly maintainable pattern for doing this is to use one of your business fields (for example, an account number) and calculate a mod(x) on it where x is the number of subscribers you want to have to share the work load. Hopefully your business key is numeric and will give you a decent distribution, but you can always use some other deterministic algorithm to generate this number by reversing keys and/or hashing their non-numeric values.

    As an aside, your outline has much more of a Point-to-Point/JMS Queue feel to it, rather than a Pub-Sub/JMS Topic one. Are you sure you want to use topics ?

    If you absolutely cannot lose data, then you should use transactional messages. If you use transactional messages, then you cannot delegate to a thread pool. A JMS message’s transactional context (which is the session) is bound to the thread that the message is received on, so unless you enable some “funny-business” to transfer this context to another thread…..

    I’m not even sure how to finish that sentence.

    ==== Update ====

    Now that I think about it, if you can benefit from parallelizing the processing of messages, you could retrieve batches of messages, all within one transaction, and delegate them all to an ExecutorService.invokeAll call, wait for completion and commit the transaction when they’re all complete. If the invokeAll times out, or one of the tasks throws an exception, then you would have to rollback the transaction or take some sort of compensating action.

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

Sidebar

Related Questions

I have a stand alone java application that receives SNMP messages via an SNMP
I have a stand alone java application that will be used in a macintosh
I have a stand-alone java application that makes some database read/write business on a
I have a stand alone java program having 'main method' that runs continuously in
I have stand alone Java Application with Spring 3.0. I am calling REST service
I have a standalone java application that fires up several JMS consumers using the
I have an Ant task to call a java process that takes a file
I have a java application that up until now was run as a stand
I have a stand-alone Java windows application developed based on Swing. It connects to
I have an Stand alone Application which runs Shell Script(with parameters)in Ubuntu. ProcessBuilder pb1

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.