|
|
|
@ -46,13 +46,13 @@ import org.springframework.util.ErrorHandler; |
|
|
|
* |
|
|
|
* |
|
|
|
* <p><b>NOTE:</b> The default behavior of this message listener container is to |
|
|
|
* <p><b>NOTE:</b> The default behavior of this message listener container is to |
|
|
|
* <b>never</b> propagate an exception thrown by a message listener up to the JMS |
|
|
|
* <b>never</b> propagate an exception thrown by a message listener up to the JMS |
|
|
|
* provider. Instead, it will log any such exception at the error level. |
|
|
|
* provider. Instead, it will log any such exception at {@code WARN} level. |
|
|
|
* This means that from the perspective of the attendant JMS provider no such |
|
|
|
* This means that from the perspective of the attendant JMS provider no such |
|
|
|
* listener will ever fail. However, if error handling is necessary, then |
|
|
|
* listener will ever fail. However, if error handling is necessary, then |
|
|
|
* any implementation of the {@link ErrorHandler} strategy may be provided to |
|
|
|
* an implementation of the {@link ErrorHandler} strategy may be provided to |
|
|
|
* the {@link #setErrorHandler(ErrorHandler)} method. Note that JMSExceptions |
|
|
|
* the {@link #setErrorHandler(ErrorHandler)} method. Note that JMSExceptions |
|
|
|
* <b>will</b> be passed to the ErrorHandler in addition to (but after) being |
|
|
|
* <b>will</b> be passed to the {@code ErrorHandler} in addition to (but after) |
|
|
|
* passed to an {@link ExceptionListener}, if one has been provided. |
|
|
|
* being passed to an {@link ExceptionListener}, if one has been provided. |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>The listener container offers the following message acknowledgment options: |
|
|
|
* <p>The listener container offers the following message acknowledgment options: |
|
|
|
* <ul> |
|
|
|
* <ul> |
|
|
|
@ -496,8 +496,8 @@ public abstract class AbstractMessageListenerContainer extends AbstractJmsListen |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Configure the {@link QosSettings} to use when sending a reply. Can be set to |
|
|
|
* Configure the {@link QosSettings} to use when sending a reply. Can be set to |
|
|
|
* {@code null} to indicate that the broker's defaults should be used. |
|
|
|
* {@code null} to indicate that the broker's defaults should be used. |
|
|
|
* @param replyQosSettings the QoS settings to use when sending a reply or {@code null} |
|
|
|
* @param replyQosSettings the QoS settings to use when sending a reply, or |
|
|
|
* to use the default vas. |
|
|
|
* {@code null} to use the default value |
|
|
|
* @since 5.0 |
|
|
|
* @since 5.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setReplyQosSettings(@Nullable QosSettings replyQosSettings) { |
|
|
|
public void setReplyQosSettings(@Nullable QosSettings replyQosSettings) { |
|
|
|
@ -542,8 +542,8 @@ public abstract class AbstractMessageListenerContainer extends AbstractJmsListen |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Set the ErrorHandler to be invoked in case of any uncaught exceptions thrown |
|
|
|
* Set the {@link ErrorHandler} to be invoked in case of any uncaught exceptions |
|
|
|
* while processing a Message. |
|
|
|
* thrown while processing a {@link Message}. |
|
|
|
* <p>By default, there will be <b>no</b> ErrorHandler so that error-level |
|
|
|
* <p>By default, there will be <b>no</b> ErrorHandler so that error-level |
|
|
|
* logging is the only result. |
|
|
|
* logging is the only result. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -552,8 +552,8 @@ public abstract class AbstractMessageListenerContainer extends AbstractJmsListen |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return the ErrorHandler to be invoked in case of any uncaught exceptions thrown |
|
|
|
* Return the {@link ErrorHandler} to be invoked in case of any uncaught exceptions |
|
|
|
* while processing a Message. |
|
|
|
* thrown while processing a {@link Message}. |
|
|
|
* @since 4.1 |
|
|
|
* @since 4.1 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Nullable |
|
|
|
@Nullable |
|
|
|
@ -634,7 +634,7 @@ public abstract class AbstractMessageListenerContainer extends AbstractJmsListen |
|
|
|
* Execute the specified listener, |
|
|
|
* Execute the specified listener, |
|
|
|
* committing or rolling back the transaction afterwards (if necessary). |
|
|
|
* committing or rolling back the transaction afterwards (if necessary). |
|
|
|
* @param session the JMS Session to operate on |
|
|
|
* @param session the JMS Session to operate on |
|
|
|
* @param message the received JMS Message |
|
|
|
* @param message the received JMS {@link Message} |
|
|
|
* @see #invokeListener |
|
|
|
* @see #invokeListener |
|
|
|
* @see #commitIfNecessary |
|
|
|
* @see #commitIfNecessary |
|
|
|
* @see #rollbackOnExceptionIfNecessary |
|
|
|
* @see #rollbackOnExceptionIfNecessary |
|
|
|
@ -653,7 +653,7 @@ public abstract class AbstractMessageListenerContainer extends AbstractJmsListen |
|
|
|
* Execute the specified listener, |
|
|
|
* Execute the specified listener, |
|
|
|
* committing or rolling back the transaction afterwards (if necessary). |
|
|
|
* committing or rolling back the transaction afterwards (if necessary). |
|
|
|
* @param session the JMS Session to operate on |
|
|
|
* @param session the JMS Session to operate on |
|
|
|
* @param message the received JMS Message |
|
|
|
* @param message the received JMS {@link Message} |
|
|
|
* @throws JMSException if thrown by JMS API methods |
|
|
|
* @throws JMSException if thrown by JMS API methods |
|
|
|
* @see #invokeListener |
|
|
|
* @see #invokeListener |
|
|
|
* @see #commitIfNecessary |
|
|
|
* @see #commitIfNecessary |
|
|
|
@ -684,7 +684,7 @@ public abstract class AbstractMessageListenerContainer extends AbstractJmsListen |
|
|
|
* Invoke the specified listener: either as standard JMS MessageListener |
|
|
|
* Invoke the specified listener: either as standard JMS MessageListener |
|
|
|
* or (preferably) as Spring SessionAwareMessageListener. |
|
|
|
* or (preferably) as Spring SessionAwareMessageListener. |
|
|
|
* @param session the JMS Session to operate on |
|
|
|
* @param session the JMS Session to operate on |
|
|
|
* @param message the received JMS Message |
|
|
|
* @param message the received JMS {@link Message} |
|
|
|
* @throws JMSException if thrown by JMS API methods |
|
|
|
* @throws JMSException if thrown by JMS API methods |
|
|
|
* @see #setMessageListener |
|
|
|
* @see #setMessageListener |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -713,7 +713,7 @@ public abstract class AbstractMessageListenerContainer extends AbstractJmsListen |
|
|
|
* to the listener if demanded. |
|
|
|
* to the listener if demanded. |
|
|
|
* @param listener the Spring SessionAwareMessageListener to invoke |
|
|
|
* @param listener the Spring SessionAwareMessageListener to invoke |
|
|
|
* @param session the JMS Session to operate on |
|
|
|
* @param session the JMS Session to operate on |
|
|
|
* @param message the received JMS Message |
|
|
|
* @param message the received JMS {@link Message} |
|
|
|
* @throws JMSException if thrown by JMS API methods |
|
|
|
* @throws JMSException if thrown by JMS API methods |
|
|
|
* @see SessionAwareMessageListener |
|
|
|
* @see SessionAwareMessageListener |
|
|
|
* @see #setExposeListenerSession |
|
|
|
* @see #setExposeListenerSession |
|
|
|
@ -749,11 +749,11 @@ public abstract class AbstractMessageListenerContainer extends AbstractJmsListen |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Invoke the specified listener as standard JMS MessageListener. |
|
|
|
* Invoke the specified listener as standard JMS {@link MessageListener}. |
|
|
|
* <p>Default implementation performs a plain invocation of the |
|
|
|
* <p>Default implementation performs a plain invocation of the |
|
|
|
* {@code onMessage} method. |
|
|
|
* {@code onMessage} method. |
|
|
|
* @param listener the JMS MessageListener to invoke |
|
|
|
* @param listener the JMS {@code MessageListener} to invoke |
|
|
|
* @param message the received JMS Message |
|
|
|
* @param message the received JMS {@link Message} |
|
|
|
* @throws JMSException if thrown by JMS API methods |
|
|
|
* @throws JMSException if thrown by JMS API methods |
|
|
|
* @see jakarta.jms.MessageListener#onMessage |
|
|
|
* @see jakarta.jms.MessageListener#onMessage |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@ -763,8 +763,8 @@ public abstract class AbstractMessageListenerContainer extends AbstractJmsListen |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Perform a commit or message acknowledgement, as appropriate. |
|
|
|
* Perform a commit or message acknowledgement, as appropriate. |
|
|
|
* @param session the JMS Session to commit |
|
|
|
* @param session the JMS {@link Session} to commit |
|
|
|
* @param message the Message to acknowledge |
|
|
|
* @param message the {@link Message} to acknowledge |
|
|
|
* @throws jakarta.jms.JMSException in case of commit failure |
|
|
|
* @throws jakarta.jms.JMSException in case of commit failure |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected void commitIfNecessary(Session session, @Nullable Message message) throws JMSException { |
|
|
|
protected void commitIfNecessary(Session session, @Nullable Message message) throws JMSException { |
|
|
|
@ -877,7 +877,7 @@ public abstract class AbstractMessageListenerContainer extends AbstractJmsListen |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Handle the given exception that arose during listener execution. |
|
|
|
* Handle the given exception that arose during listener execution. |
|
|
|
* <p>The default implementation logs the exception at warn level, |
|
|
|
* <p>The default implementation logs the exception at {@code WARN} level, |
|
|
|
* not propagating it to the JMS provider — assuming that all handling of |
|
|
|
* not propagating it to the JMS provider — assuming that all handling of |
|
|
|
* acknowledgement and/or transactions is done by this listener container. |
|
|
|
* acknowledgement and/or transactions is done by this listener container. |
|
|
|
* This can be overridden in subclasses. |
|
|
|
* This can be overridden in subclasses. |
|
|
|
@ -916,8 +916,9 @@ public abstract class AbstractMessageListenerContainer extends AbstractJmsListen |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Invoke the registered ErrorHandler, if any. Log at warn level otherwise. |
|
|
|
* Invoke the registered {@link #getErrorHandler() ErrorHandler} if any. |
|
|
|
* @param ex the uncaught error that arose during JMS processing. |
|
|
|
* Log at {@code WARN} level otherwise. |
|
|
|
|
|
|
|
* @param ex the uncaught error that arose during JMS processing |
|
|
|
* @see #setErrorHandler |
|
|
|
* @see #setErrorHandler |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected void invokeErrorHandler(Throwable ex) { |
|
|
|
protected void invokeErrorHandler(Throwable ex) { |
|
|
|
@ -933,7 +934,7 @@ public abstract class AbstractMessageListenerContainer extends AbstractJmsListen |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Internal exception class that indicates a rejected message on shutdown. |
|
|
|
* Internal exception class that indicates a rejected message on shutdown. |
|
|
|
* Used to trigger a rollback for an external transaction manager in that case. |
|
|
|
* <p>Used to trigger a rollback for an external transaction manager in that case. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@SuppressWarnings("serial") |
|
|
|
@SuppressWarnings("serial") |
|
|
|
private static class MessageRejectedWhileStoppingException extends RuntimeException { |
|
|
|
private static class MessageRejectedWhileStoppingException extends RuntimeException { |
|
|
|
|