|
Spring AMQP | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.amqp.rabbit.support.RabbitAccessor
org.springframework.amqp.rabbit.listener.AbstractRabbitListeningContainer
public abstract class AbstractRabbitListeningContainer
Nested Class Summary | |
---|---|
static class |
AbstractRabbitListeningContainer.SharedConnectionNotInitializedException
Exception that indicates that the initial setup of this container's shared Rabbit Connection failed. |
Field Summary |
---|
Fields inherited from class org.springframework.amqp.rabbit.support.RabbitAccessor |
---|
logger |
Constructor Summary | |
---|---|
AbstractRabbitListeningContainer()
|
Method Summary | |
---|---|
void |
afterPropertiesSet()
Delegates to validateConfiguration() and initialize() . |
protected Connection |
createSharedConnection()
Create a shared Connection for this container. |
void |
destroy()
Calls shutdown() when the BeanFactory destroys the container instance. |
protected abstract void |
doInitialize()
Register any invokers within this container. |
protected abstract void |
doShutdown()
Close the registered invokers. |
protected void |
doStart()
Start the shared Connection, if any, and notify all invoker tasks. |
protected void |
doStop()
Notify all invoker tasks and stop the shared Connection, if any. |
protected void |
establishSharedConnection()
Establish a shared Connection for this container. |
protected String |
getBeanName()
Return the bean name that this listener container has been assigned in its containing bean factory, if any. |
int |
getPhase()
Return the phase in which this container will be started and stopped. |
protected Connection |
getSharedConnection()
Return the shared Rabbit Connection maintained by this container. |
void |
initialize()
Initialize this container. |
boolean |
isActive()
Return whether this container is currently active, that is, whether it has been set up but not shut down yet. |
boolean |
isAutoStartup()
|
boolean |
isRunning()
Determine whether this container is currently running, that is, whether it has been started and not stopped yet. |
protected void |
prepareSharedConnection(Connection connection)
Prepare the given Connection, which is about to be registered as shared Connection for this container. |
protected void |
refreshSharedConnection()
Refresh the shared Connection that this container holds. |
protected boolean |
runningAllowed()
Check whether this container's listeners are generally allowed to run. |
void |
setAutoStartup(boolean autoStartup)
Set whether to automatically start the container after initialization. |
void |
setBeanName(String beanName)
|
void |
setPhase(int phase)
Specify the phase in which this container should be started and stopped. |
protected abstract boolean |
sharedConnectionEnabled()
Return whether a shared Rabbit Connection should be maintained by this container base class. |
void |
shutdown()
Stop the shared Connection, call doShutdown() ,
and close this container. |
void |
start()
Start this container. |
void |
stop()
Stop this container. |
void |
stop(Runnable callback)
|
protected void |
stopSharedConnection()
Stop the shared Connection, logging any exception thrown by Rabbit API methods. |
protected void |
validateConfiguration()
Validate the configuration of this container. |
Methods inherited from class org.springframework.amqp.rabbit.support.RabbitAccessor |
---|
convertRabbitAccessException, createChannel, createConnection, getChannel, getConnection, getConnectionFactory, getTransactionalResourceHolder, isChannelTransacted, setChannelTransacted, setConnectionFactory |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AbstractRabbitListeningContainer()
Method Detail |
---|
public void setAutoStartup(boolean autoStartup)
Default is "true"; set this to "false" to allow for manual startup
through the start()
method.
public boolean isAutoStartup()
isAutoStartup
in interface SmartLifecycle
public void setPhase(int phase)
public int getPhase()
getPhase
in interface Phased
public void setBeanName(String beanName)
setBeanName
in interface BeanNameAware
protected final String getBeanName()
public void afterPropertiesSet()
validateConfiguration()
and initialize()
.
afterPropertiesSet
in interface InitializingBean
afterPropertiesSet
in class RabbitAccessor
protected void validateConfiguration()
The default implementation is empty. To be overridden in subclasses.
public void destroy()
shutdown()
when the BeanFactory destroys the container instance.
destroy
in interface DisposableBean
shutdown()
public void initialize()
Creates a Rabbit Connection and calls doInitialize()
.
public void shutdown()
doShutdown()
,
and close this container.
public final boolean isActive()
public void start()
start
in interface Lifecycle
doStart()
protected void doStart() throws Exception
AbstractRabbitListeningContainer.SharedConnectionNotInitializedException
- if thrown by Rabbit API methods
Exception
establishSharedConnection()
public void stop()
stop
in interface Lifecycle
doStop()
public void stop(Runnable callback)
stop
in interface SmartLifecycle
protected void doStop()
stopSharedConnection()
public final boolean isRunning()
isRunning
in interface Lifecycle
start()
,
stop()
,
runningAllowed()
protected boolean runningAllowed()
This implementation always returns true
; the default 'running'
state is purely determined by start()
/ stop()
.
Subclasses may override this method to check against temporary
conditions that prevent listeners from actually running. In other words,
they may apply further restrictions to the 'running' state, returning
false
if such a restriction prevents listeners from running.
protected void establishSharedConnection() throws Exception
The default implementation delegates to createSharedConnection()
,
which does one immediate attempt and throws an exception if it fails.
Can be overridden to have a recovery process in place, retrying
until a Connection can be successfully established.
AbstractRabbitListeningContainer.SharedConnectionNotInitializedException
- if thrown by Rabbit API methods
Exception
protected final void refreshSharedConnection() throws Exception
Called on startup and also after an infrastructure exception that occurred during invoker setup and/or execution.
AbstractRabbitListeningContainer.SharedConnectionNotInitializedException
- if thrown by Rabbit API methods
Exception
protected Connection createSharedConnection() throws Exception
The default implementation creates a standard Connection
and prepares it through prepareSharedConnection(org.springframework.amqp.rabbit.connection.Connection)
.
AbstractRabbitListeningContainer.SharedConnectionNotInitializedException
- if the creation failed
Exception
protected void prepareSharedConnection(Connection connection)
The default implementation sets the specified client id, if any. Subclasses can override this to apply further settings.
connection
- the Connection to prepareprotected void stopSharedConnection()
protected final Connection getSharedConnection()
null
)
IllegalStateException
- if this container does not maintain a
shared Connection, or if the Connection hasn't been initialized yetsharedConnectionEnabled()
protected abstract boolean sharedConnectionEnabled()
getSharedConnection()
protected abstract void doInitialize() throws Exception
Subclasses need to implement this method for their specific invoker management process.
A shared Rabbit Connection
AbstractRabbitListeningContainer.SharedConnectionNotInitializedException
Exception
getSharedConnection()
protected abstract void doShutdown()
Subclasses need to implement this method for their specific invoker management process.
A shared Rabbit Connection, if any, will automatically be closed afterwards.
shutdown()
|
Spring AMQP | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |