public abstract class AbstractBrokerMessageHandler extends Object implements MessageHandler, SmartLifecycle, ApplicationEventPublisherAware
| Constructor and Description |
|---|
AbstractBrokerMessageHandler(Collection<String> destinationPrefixes) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
checkDestinationPrefix(String destination) |
ApplicationEventPublisher |
getApplicationEventPublisher() |
Collection<String> |
getDestinationPrefixes() |
int |
getPhase()
Return the phase value of this object.
|
void |
handleMessage(Message<?> message)
Handles the message if possible.
|
protected abstract void |
handleMessageInternal(Message<?> message) |
boolean |
isAutoStartup()
Return whether this Lifecycle component should be started automatically
by the container when the ApplicationContext is refreshed.
|
boolean |
isRunning()
Check whether this component is currently running.
|
protected void |
publishBrokerAvailableEvent() |
protected void |
publishBrokerUnavailableEvent() |
void |
setApplicationEventPublisher(ApplicationEventPublisher publisher)
Set the ApplicationEventPublisher that this object runs in.
|
void |
setAutoStartup(boolean autoStartup) |
void |
start()
Start this component.
|
protected void |
startInternal() |
void |
stop()
Stop this component, typically in a synchronous fashion, such that
the component is fully stopped upon return of this method.
|
void |
stop(Runnable callback)
Indicates that a Lifecycle component must stop if it is currently running.
|
protected void |
stopInternal() |
protected final Log logger
public AbstractBrokerMessageHandler(Collection<String> destinationPrefixes)
public Collection<String> getDestinationPrefixes()
public void setApplicationEventPublisher(ApplicationEventPublisher publisher)
ApplicationEventPublisherAwareInvoked after population of normal bean properties but before an init callback like InitializingBean's afterPropertiesSet or a custom init-method. Invoked before ApplicationContextAware's setApplicationContext.
setApplicationEventPublisher in interface ApplicationEventPublisherAwarepublisher - event publisher to be used by this objectpublic ApplicationEventPublisher getApplicationEventPublisher()
public void setAutoStartup(boolean autoStartup)
public boolean isAutoStartup()
SmartLifecycleisAutoStartup in interface SmartLifecyclepublic int getPhase()
Phasedpublic final boolean isRunning()
LifecycleIn the case of a container, this will return true
only if all components that apply are currently running.
public final void start()
LifecycleIn the case of a container, this will propagate the start signal to all components that apply.
protected void startInternal()
public final void stop()
LifecycleSmartLifecycle and its stop(Runnable)
variant in cases where asynchronous stop behavior is necessary.
Should not throw an exception if the component isn't started yet.
In the case of a container, this will propagate the stop signal to all components that apply.
stop in interface LifecycleSmartLifecycle.stop(Runnable)protected void stopInternal()
public final void stop(Runnable callback)
SmartLifecycleThe provided callback is used by the LifecycleProcessor to support an
ordered, and potentially concurrent, shutdown of all components having a
common shutdown order value. The callback must be executed after
the SmartLifecycle component does indeed stop.
The LifecycleProcessor will call only this variant of the
stop method; i.e. Lifecycle.stop() will not be called for
SmartLifecycle implementations unless explicitly delegated to within
this method.
stop in interface SmartLifecyclepublic final void handleMessage(Message<?> message)
MessageHandlerMessageRejectedException e.g.
in case of a Selective Consumer. When a consumer tries to handle a
message, but fails to do so, a MessageHandlingException is
thrown. In the last case it is recommended to treat the message as tainted
and go into an error scenario.
When the handling results in a failure of another message being sent
(e.g. a "reply" message), that failure will trigger a
MessageDeliveryException.
handleMessage in interface MessageHandlermessage - the message to be handled
reply related to the handling of the messageprotected abstract void handleMessageInternal(Message<?> message)
protected boolean checkDestinationPrefix(String destination)
protected void publishBrokerAvailableEvent()
protected void publishBrokerUnavailableEvent()