Class 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
    A Consumer which uses Spring's AbstractMessageListenerContainer implementations to consume JMS messages.
    See Also:
    DefaultJmsMessageListenerContainer, SimpleJmsMessageListenerContainer
    • Field Summary

      • Fields inherited from class org.apache.camel.support.service.BaseService

        BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
    • Constructor Summary

      Constructors 
      Constructor Description
      JmsConsumer​(JmsEndpoint endpoint, org.apache.camel.Processor processor, org.springframework.jms.listener.AbstractMessageListenerContainer listenerContainer)  
    • 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 interface org.apache.camel.EndpointAware
        Overrides:
        getEndpoint in class org.apache.camel.support.DefaultConsumer
      • getListenerContainer

        public org.springframework.jms.listener.AbstractMessageListenerContainer getListenerContainer()
                                                                                               throws Exception
        Throws:
        Exception
      • 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 class org.apache.camel.support.DefaultConsumer
        Throws:
        Exception
      • prepareAndStartListenerContainer

        protected void prepareAndStartListenerContainer()
      • stopAndDestroyListenerContainer

        protected void stopAndDestroyListenerContainer()
      • doStop

        protected void doStop()
                       throws Exception
        Overrides:
        doStop in class org.apache.camel.support.DefaultConsumer
        Throws:
        Exception
      • doSuspend

        protected void doSuspend()
                          throws Exception
        Overrides:
        doSuspend in class org.apache.camel.support.service.BaseService
        Throws:
        Exception
      • doResume

        protected void doResume()
                         throws Exception
        Overrides:
        doResume in class org.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 (or null 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)