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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:55:17+00:00 2026-05-12T16:55:17+00:00

We have a JMS queue of job statuses, and two identical processes pulling from

  • 0

We have a JMS queue of job statuses, and two identical processes pulling from the queue to persist the statuses via JDBC. When a job status is pulled from the queue, the database is checked to see if there is already a row for the job. If so, the existing row is updated with new status. If not, a row is created for this initial status.

What we are seeing is that a small percentage of new jobs are being added to the database twice. We are pretty sure this is because the job’s initial status is quickly followed by a status update – one process gets one, another process the other. Both processes check to see if the job is new, and since it has not been recorded yet, both create a record for it.

So, my question is, how would you go about preventing this in a vendor-neutral way? Can it be done without locking the entire table?

EDIT: For those saying the “architecture” is unsound – I agree, but am not at liberty to change it.

  • 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-12T16:55:17+00:00Added an answer on May 12, 2026 at 4:55 pm

    Create a unique constraint on JOB_ID, and retry to persist the status in the event of a constraint violation exception.

    That being said, I think your architecture is unsound: If two processes are pulling messages from the queue, it is not guaranteed they will write them to the database in queue order: one consumer might be a bit slower, a packet might be dropped, …, causing the other consumer to persist the later messages first, causing them to be overridden with the earlier state.

    One way to guard against that is to include sequence numbers in the messages, update the row only if the sequence number is as expected, and delay the update otherwise (this is vulnerable to lost messages, though …).

    Of course, the easiest way would be to have only one consumer …

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

Sidebar

Related Questions

I have a server application receiving messages from a JMS queue. And client applications
I have a message handler, which consumes from a JMS queue and that sends
Say you have a JMS queue, and multiple consumers are watching the queue for
I have a class that after it does some stuff, sends a JMS message.
do you have idea, if there would be some nice way to browse/log JMS
I keep a JMS connection always open, because I have a MessageListener on it.
I have a Queue configured in the Rational Application Developer for WebSphere, using a
How can I instantiate a JMS queue listener in java (JRE /JDK / J2EE
I have problem with Oracle 9.2 and JMS. I created PL/SQL routine to send
Have just started using Google Chrome , and noticed in parts of our site,

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.