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.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.Suspendable
AConsumer
which uses Spring'sAbstractMessageListenerContainer
implementations 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 void
createMessageListener(JmsEndpoint endpoint, org.apache.camel.Processor processor)
protected void
createMessageListenerContainer()
protected void
doResume()
protected void
doStart()
protected void
doStop()
protected void
doSuspend()
JmsEndpoint
getEndpoint()
EndpointMessageListener
getEndpointMessageListener()
org.springframework.jms.listener.AbstractMessageListenerContainer
getListenerContainer()
String
getMessageSelector()
Set the JMS message selector expression (ornull
if none).protected void
prepareAndStartListenerContainer()
void
setMessageSelector(String messageSelector)
void
startListenerContainer()
Starts the JMS listener containerprotected void
stopAndDestroyListenerContainer()
protected void
testConnectionOnStartup()
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, getProcessor, getRoute, getRouteId, handleException, handleException, releaseExchange, setExceptionHandler, 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:
getEndpoint
in interfaceorg.apache.camel.EndpointAware
- Overrides:
getEndpoint
in 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.FailedToCreateConsumerException
Pre 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:
doStart
in classorg.apache.camel.support.DefaultConsumer
- Throws:
Exception
-
prepareAndStartListenerContainer
protected void prepareAndStartListenerContainer()
-
stopAndDestroyListenerContainer
protected void stopAndDestroyListenerContainer()
-
doStop
protected void doStop() throws Exception
- Overrides:
doStop
in classorg.apache.camel.support.DefaultConsumer
- Throws:
Exception
-
doSuspend
protected void doSuspend() throws Exception
- Overrides:
doSuspend
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doResume
protected void doResume() throws Exception
- Overrides:
doResume
in 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 (ornull
if 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)
-
-