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.HostedService, 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:
  • 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)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    createMessageListener(JmsEndpoint endpoint, org.apache.camel.Processor processor)
     
    protected void
     
    protected void
     
    protected void
     
    protected void
     
    protected void
     
     
     
    org.springframework.jms.listener.AbstractMessageListenerContainer
     
    Set the JMS message selector expression (or null if none).
    protected void
     
    void
    setMessageSelector(String messageSelector)
     
    void
    Starts the JMS listener container
    protected void
     
    protected void
    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, handleException, isHostedService, releaseExchange, setExceptionHandler, setHealthCheck, setRoute, setRouteId, toString

    Methods inherited from class org.apache.camel.support.service.BaseService

    build, doFail, doLifecycleChange, fail, getInternalLock, 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

    Methods inherited from interface org.apache.camel.Service

    build, close, init, start, stop

    Methods inherited from interface org.apache.camel.ShutdownableService

    shutdown

    Methods inherited from interface org.apache.camel.StatefulService

    getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending

    Methods inherited from interface org.apache.camel.SuspendableService

    isSuspended, resume, suspend
  • Constructor Details

    • JmsConsumer

      public JmsConsumer(JmsEndpoint endpoint, org.apache.camel.Processor processor, org.springframework.jms.listener.AbstractMessageListenerContainer listenerContainer)
  • Method Details

    • 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
    • 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 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)