Package org.apache.camel.component.jms
Class JmsConsumer
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.support.DefaultConsumer
-
- org.apache.camel.component.jms.JmsConsumer
-
- All Implemented Interfaces:
AutoCloseable,org.apache.camel.Consumer,org.apache.camel.EndpointAware,org.apache.camel.health.HealthCheckAware,org.apache.camel.RouteAware,org.apache.camel.Service,org.apache.camel.ShutdownableService,org.apache.camel.spi.RouteIdAware,org.apache.camel.StatefulService,org.apache.camel.Suspendable,org.apache.camel.SuspendableService
@ManagedResource(description="Managed JMS Consumer") public class JmsConsumer extends org.apache.camel.support.DefaultConsumer implements org.apache.camel.SuspendableAConsumerwhich uses Spring'sAbstractMessageListenerContainerimplementations to consume JMS messages.
-
-
Constructor Summary
Constructors Constructor Description JmsConsumer(JmsEndpoint endpoint, org.apache.camel.Processor processor, org.springframework.jms.listener.AbstractMessageListenerContainer listenerContainer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcreateMessageListener(JmsEndpoint endpoint, org.apache.camel.Processor processor)protected voidcreateMessageListenerContainer()protected voiddoResume()protected voiddoStart()protected voiddoStop()protected voiddoSuspend()JmsEndpointgetEndpoint()EndpointMessageListenergetEndpointMessageListener()org.springframework.jms.listener.AbstractMessageListenerContainergetListenerContainer()StringgetMessageSelector()Set the JMS message selector expression (ornullif none).protected voidprepareAndStartListenerContainer()voidsetMessageSelector(String messageSelector)voidstartListenerContainer()Starts the JMS listener containerprotected voidstopAndDestroyListenerContainer()protected voidtestConnectionOnStartup()Pre tests the connection before starting the listening.-
Methods inherited from class org.apache.camel.support.DefaultConsumer
createExchange, createUoW, defaultConsumerCallback, doBuild, doInit, doneUoW, doShutdown, getAsyncProcessor, getExceptionHandler, getHealthCheck, getProcessor, getRoute, getRouteId, handleException, handleException, releaseExchange, setExceptionHandler, setHealthCheck, setRoute, setRouteId, toString
-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doFail, doLifecycleChange, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Constructor Detail
-
JmsConsumer
public JmsConsumer(JmsEndpoint endpoint, org.apache.camel.Processor processor, org.springframework.jms.listener.AbstractMessageListenerContainer listenerContainer)
-
-
Method Detail
-
getEndpoint
public JmsEndpoint getEndpoint()
- Specified by:
getEndpointin interfaceorg.apache.camel.EndpointAware- Overrides:
getEndpointin classorg.apache.camel.support.DefaultConsumer
-
getListenerContainer
public org.springframework.jms.listener.AbstractMessageListenerContainer getListenerContainer() throws Exception- Throws:
Exception
-
getEndpointMessageListener
public EndpointMessageListener getEndpointMessageListener()
-
createMessageListener
protected void createMessageListener(JmsEndpoint endpoint, org.apache.camel.Processor processor)
-
createMessageListenerContainer
protected void createMessageListenerContainer() throws Exception- Throws:
Exception
-
startListenerContainer
public void startListenerContainer()
Starts the JMS listener container Can be used to start this consumer later if it was configured to not auto startup.
-
testConnectionOnStartup
protected void testConnectionOnStartup() throws org.apache.camel.FailedToCreateConsumerExceptionPre tests the connection before starting the listening. In case of connection failure the exception is thrown which prevents Camel from starting.- Throws:
org.apache.camel.FailedToCreateConsumerException- is thrown if testing the connection failed
-
doStart
protected void doStart() throws Exception- Overrides:
doStartin classorg.apache.camel.support.DefaultConsumer- Throws:
Exception
-
prepareAndStartListenerContainer
protected void prepareAndStartListenerContainer()
-
stopAndDestroyListenerContainer
protected void stopAndDestroyListenerContainer()
-
doStop
protected void doStop() throws Exception- Overrides:
doStopin classorg.apache.camel.support.DefaultConsumer- Throws:
Exception
-
doSuspend
protected void doSuspend() throws Exception- Overrides:
doSuspendin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doResume
protected void doResume() throws Exception- Overrides:
doResumein classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
getMessageSelector
@ManagedAttribute(description="Changes the JMS selector, as long the cache level is less than CACHE_CONSUMER.") public String getMessageSelector()
Set the JMS message selector expression (ornullif none). Default is none.See the JMS specification for a detailed definition of selector expressions.
Note: The message selector may be replaced at runtime, with the listener container picking up the new selector value immediately (works e.g. with DefaultMessageListenerContainer, as long as the cache level is less than CACHE_CONSUMER). However, this is considered advanced usage; use it with care!
-
setMessageSelector
@ManagedAttribute(description="Changes the JMS selector, as long the cache level is less than CACHE_CONSUMER.") public void setMessageSelector(String messageSelector)
-
-