45636

Writing to database log in the middle of rollback

Question:

I am using jboss5.1.x, ejb3.0

I have a transaction which goes like this: MDB listen to JMS Queue. MDB takes msg from JMS writing to Database.

in some of the catch clauses i throw "New EJBException(..)", in order to have rollbacks when specific exceptions occurs.

beside of that I have configured a re-try mechanism, after 3 times the msg going to error queue.

What i wanna achive is:

when Iam having a rollback, i want to increase the current re-try number, so if some1 is observing the database, he/she can see <strong>on-line</strong> the current re-try number.

the problem is: when I do rollback, so even the "insert_number_of_retry" query is being rolled back itself, which preventing from me to add the current retry number to the database

how can I solve this?

Thanks,

ray.

Answer1:

You can try to execute your logging method inside a separate transaction by annotating it with @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW).

Answer2:

You need a separate transaction in a separate thread (you may use dedicated thread/pool for or spawn one, if need be). You have an option to wait for the forked tx to end or forfeit (and just continue w/ the rollback and fast exit), that depends on the extra logic and so.

Recommend

  • Need advice in designing tables in SQL-Server
  • CakePHP Subquery from SQL
  • How does CoreLocation locate the device?
  • How to subscribe to an event without preventing garbage collection?
  • How to set infinite shared access signature policy in azure?
  • Get textarea in codebehind
  • Error “Reflect.defineMetadata” while trying to load a transient web worker
  • Ability to use Bootstrap 3 grid system to specify width of select element
  • Cordova Apache wrong module path
  • How do you keep a running instance for Google App Engine
  • ASPNetCore MVC Routing Let Server Handle Specific Route
  • Manually Timing out a C# Thread
  • Spring Integration Bridge with poller not working as expected for JMS
  • Problem with Django using Apache2 (mod_wsgi), Occassionally is “unable to import from module” for no
  • How to make Twilio api Post request with the help of AFNetworking?
  • Prevent Tomcat from caching request during starup
  • Servlet stops working on Tomcat server after some hits or time
  • Does it make sense to call System.gc() and Thread.sleep() when working on Bitmaps?
  • MongoDb aggregation
  • Is there a way to do normal logging with EureakLog?
  • Atlas images wrong size on iPad iOS 9
  • Debugging ASP.NET on a built-in web server suddenly stops
  • Is there a javascript serializer for JSON.Net?
  • NetLogo BehaviorSpace - Measure runs using reporters
  • Menu Color Fade on Hover with Jquery
  • Where to put my custom functions in Wordpress?
  • ActionScript 2 vs ActionScript 3 performance
  • Hazelcast - OperationTimeoutException
  • How can I estimate amount of memory left with calling System.gc()?
  • Matrix multiplication with MKL
  • Buffer size for converting unsigned long to string
  • CSS Applying specific rule for a specific monitor resolution with only CSS is posible?
  • Hits per day in Google Big Query
  • What are the advantages and disadvantages of reading an entire file into a single String as opposed
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Linking SubReports Without LinkChild/LinkMaster
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass
  • Binding checkboxes to object values in AngularJs
  • Converting MP3 duration time
  • java string with new operator and a literal