46559

spring jms error handler access to message

We are using spring-jms to receive message off the queue. But sometimes we got a connection issue (downstream JDBC on the listener thread) where we don't have enough connection in the pool. So we want to retry that message again and if we still dont have connection then we will reject the message

We are trying this in error handler and that error handler instance is inject to spring default message listener container but I am not sure how to access the message object as it only provides Throwable object.

Does anyone know how to access actual message object?

Answer1:

The only way to pass the message to the error handler is to catch the exception in your listener and add the message as a property to a new exception (probably wrapping the original exception in the cause).

You may find it simpler to just handle the exception in your user code.

If you are using message-driven POJOs instead of a MessageListener; you would have to subclass the MessageListenerAdapter and call super.onMessage() in a try/catch block.

<strong>EDIT:</strong>

In any case, the ErrorHandler is invoked after the rollback, so it can't change that behavior.

Recommend

  • Number of input rows in spark structured streaming with custom sink
  • Correctly recognise an int[] passed as a varargs parameter
  • How to escalate top-most supervisors in Akka?
  • Configure SwiftMailer “Local Domain” setting easily, in Symfony 2
  • Getting the result of the promise returned by an asyncValidator
  • TextPad “find in files” not matching on simple OR regex
  • How can I get a specific version of a dataset row?
  • How to protect an asp:textbox from user input?
  • Wait for .each() .getJSON request to finish before executing a callback
  • passing parameter to DownloadStringCompletedEventHandler in C#
  • Configuring multiple DefaultJmslistenercontainerfactory
  • How to merge keras sequential models with same input?
  • (Tcl/Expect) clear screen after exit
  • Android onKey w/ virtual keyboard
  • Faster Way To Simultaneously Iterate Over Rolling Window Of Two Or More Numpy Arrays?
  • iOS Cordova first plugin - plugin.xml to inject a feature
  • What command do i need to pass in SabreCommandLLSRQ to get current price of PNR?
  • JSR-330 support in Picocontainer : @Inject … @Named(\"xxx)
  • Creating a DropDownList
  • Who propagate bugfixes across branches (corporate development)?
  • presentShareDialogWithParams posts to FB wall, but callback handler results say error
  • Detect when Facebook like button is clicked
  • AJAX Html Editor Extender upload image appearing blank
  • Time complexity of a program which involves multiple variables
  • Checking free space on FTP server
  • Exception “firebase.functions() takes … no argument …” when specifying a region for a Cloud Function
  • Highlight one bar in a series in highcharts?
  • Scrapy recursive link crawler
  • PHP - How to update data to MySQL when click a radio button
  • Spray.io: When (not) to use non-blocking route handling?
  • angularjs unit test when to use $rootScope.$new()
  • Modifying destination and filename of gulp-svg-sprite
  • GridView Sorting works once only
  • Calling of Constructors in a Java
  • PHP: When would you need the self:: keyword?
  • Angular 2 constructor injection vs direct access
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Exception on Android 4.0 `android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode)`
  • Linking SubReports Without LinkChild/LinkMaster
  • XCode 8, some methods disappeared ? ex: layoutAttributesClass() -> AnyClass