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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:18:22+00:00 2026-05-28T07:18:22+00:00

I have an event-driven application based on MDB, spring integration and JPA for persistence.

  • 0

I have an event-driven application based on MDB, spring integration and JPA for persistence.
The application is deployed on weblogic 10.3 with a max-pool-size default value (16).

My application need to handle some messages that modfies DB.
Imagine that I have use case where I have to handle some messages that for their logic need to insert a domain object if it does not exist or update it if it exists.

So my component that modifes the DB check if the object exists or not and then call the merge on JPA.
Since two concurrent messages are executed in parallel when I call the merge on dao, JPA triggers two insert statement since the object is not yet persisted and so only one of them is correctly executed.

Is there a pattern to handle this kind of “race condition” in an event-driven application?

Kind regards
Massimo

  • 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-28T07:18:22+00:00Added an answer on May 28, 2026 at 7:18 am

    The simplest solution is to catch the exception thrown by the second insert, then call merge again, which should perform the update.

    Alternatively, you could try performing the merge in SERIALIZABLE transaction isolation, which should ensure that the second merge is blocked until the first one has completed, and the second one should then perform an update.

    The main problem with this whole scenario is that if you have multiple concurrent events coming in which entail modifying a given entity, then how do you ensure that you’re executing them in the correct sequence? Surely you need to process these sequentially, rather than concurrently? If you use concurrent event consumers, the order is going to be non-deterministic.

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

Sidebar

Related Questions

I have some event handler on a boundary class that manages a persistence mechanism
I have a number data-driven web based applications that serve both internal and public
I am trying to use IIS to host an event-driven web-application. Lets say I
The goal is to have a single-threaded event-driven framework. The end-user will do something
I have event manager process that dispatches events to subscribers (e.g. http_session_created, http_sesssion_destroyed). If
Input rz value In the head I have: Event.observe(window, 'load', function() { $$(input).each(function(field){ Event.observe(field,
I have an event handler that needs to determine a type and execute code
I have an event handler that will remove an element from a list of
I have following event class. I have a question related to the Property method
I have 2 event handlers: Y.all(.ptl).on(mouseover, handleOverlay); Y.all(.ptl).on(mouseout, handleOverlay); And I would like to

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.