0

According to Spring reference documentation, method annotated with @JmsListener and have a non-void return type will have the result of the invocation encapsulated in a javax.jms.Message and sent either in the destination specified in the JMSReplyTo header of the original message or in the default destination configured on the listener.

If no destination is found then an InvalidDestinationException will be thrown.

Is there a way to disable this behavior of automatic reply ?

EDIT

I'm using an @AroundAdvice to log the result of the execution that's why i need to have a return type on my listener.

Marouane Lakhal
  • 774
  • 1
  • 15
  • 42

1 Answers1

1

Returning null from the method if it has a return type, will disable reply processing.

You can detect the presence (or not) of a replyTo by adding a @Header parameter to the method.

Or, add a @SendTo with a destination to use if there's no header.

EDIT

Since you are using an advice to log the return value, you can simply return null from the advice, instead of the result of invocation.proceed().

Gary Russell
  • 166,535
  • 14
  • 146
  • 179