org.apache.servicemix.jms.endpoints
Class JmsConsumerEndpoint

java.lang.Object
  extended by org.apache.servicemix.common.endpoints.AbstractEndpoint
      extended by org.apache.servicemix.common.endpoints.SimpleEndpoint
          extended by org.apache.servicemix.common.endpoints.ConsumerEndpoint
              extended by org.apache.servicemix.jms.endpoints.AbstractConsumerEndpoint
                  extended by org.apache.servicemix.jms.endpoints.JmsConsumerEndpoint
All Implemented Interfaces:
Endpoint, JmsEndpointType
Direct Known Subclasses:
JmsSoapConsumerEndpoint

public class JmsConsumerEndpoint
extends AbstractConsumerEndpoint
implements JmsEndpointType

A Sping-based JMS consumer endpoint.

Since:
3.2
Author:
gnodet

Field Summary
static java.lang.String LISTENER_TYPE_DEFAULT
           
static java.lang.String LISTENER_TYPE_SIMPLE
           
static java.lang.String TRANSACTED_JMS
           
static java.lang.String TRANSACTED_NONE
           
static java.lang.String TRANSACTED_XA
           
 
Fields inherited from class org.apache.servicemix.jms.endpoints.AbstractConsumerEndpoint
PROP_JMS_CONTEXT
 
Fields inherited from class org.apache.servicemix.common.endpoints.SimpleEndpoint
logger
 
Fields inherited from class org.apache.servicemix.common.endpoints.AbstractEndpoint
definition, description, endpoint, interfaceName, service, serviceUnit
 
Constructor Summary
JmsConsumerEndpoint()
           
JmsConsumerEndpoint(DefaultComponent component, javax.jbi.servicedesc.ServiceEndpoint endpoint)
           
JmsConsumerEndpoint(ServiceUnit serviceUnit, javax.xml.namespace.QName service, java.lang.String endpoint)
           
 
Method Summary
 void activate()
           
protected  org.springframework.jms.listener.AbstractMessageListenerContainer createListenerContainer()
           
 void deactivate()
           
 int getCacheLevel()
           
 java.lang.String getClientId()
           
 int getConcurrentConsumers()
           
 javax.jms.Destination getDestination()
           
 java.lang.String getDestinationName()
           
 java.lang.String getDurableSubscriptionName()
           
 javax.jms.ExceptionListener getExceptionListener()
           
 int getIdleTaskExecutionLimit()
           
 java.lang.String getListenerType()
           
 java.lang.String getLocationURI()
           
 int getMaxConcurrentConsumers()
           
 int getMaxMessagesPerTask()
           
 java.lang.String getMessageSelector()
           
 long getReceiveTimeout()
           
 long getRecoveryInterval()
           
 int getSessionAcknowledgeMode()
           
 java.lang.String getTransacted()
           
 boolean isPubSubNoLocal()
           
 boolean isSubscriptionDurable()
           
 void setCacheLevel(int cacheLevel)
          Specifies the level of caching allowed by the listener.
 void setClientId(java.lang.String clientId)
          Specifies the JMS client id for a shared Connection created and used by this listener.
 void setConcurrentConsumers(int concurrentConsumers)
          Specifies the number of concurrent consumers created by the listener.
 void setDestination(javax.jms.Destination destination)
          Specifies the JMS Destination used to receive messages.
 void setDestinationName(java.lang.String destinationName)
          Specifies a string identifying the JMS destination used to recieve messages.
 void setDurableSubscriptionName(java.lang.String durableSubscriptionName)
          Specifies the name used to register the durable subscription.
 void setExceptionListener(javax.jms.ExceptionListener exceptionListener)
          Specifies an ExceptionListener to notify in case of a JMSException is thrown by the registered message listener or the invocation infrastructure.
 void setIdleTaskExecutionLimit(int idleTaskExecutionLimit)
          Specifies the limit for idle executions of a receive task, not having received any message within its execution.
 void setListenerType(java.lang.String listenerType)
          Specifies the type of Spring JMS message listener to use.
 void setMaxConcurrentConsumers(int maxConcurrentConsumers)
          Specifies the maximum number of concurrent consumers created by the listener.
 void setMaxMessagesPerTask(int maxMessagesPerTask)
          Specifies the number of attempts to receive messages per task.
 void setMessageSelector(java.lang.String messageSelector)
          Specifies the message selector string to use.
 void setPubSubNoLocal(boolean pubSubNoLocal)
          Specifies if messages published by the listener's Connection are suppressed.
 void setReceiveTimeout(long receiveTimeout)
          Specifies the timeout for receiving a message in milliseconds.
 void setRecoveryInterval(long recoveryInterval)
          Specifies the interval, in milliseconds, between attempts to recover after a failed listener set-up.
 void setSessionAcknowledgeMode(int sessionAcknowledgeMode)
          Specifies the acknowledgment mode that is used when creating a Session to send a message.
 void setSubscriptionDurable(boolean subscriptionDurable)
          Specifies if the listener uses a durable subscription to listen for messages.
 void setTransacted(java.lang.String transacted)
          Specifies the type of transaction used to wrap the message exchanges.
 void start()
           
 void stop()
           
 void validate()
           
 
Methods inherited from class org.apache.servicemix.jms.endpoints.AbstractConsumerEndpoint
getConnectionFactory, getDestinationChooser, getDestinationResolver, getMarshaler, getReplyDeliveryMode, getReplyDestination, getReplyDestination, getReplyDestinationName, getReplyPriority, getReplyProperties, getReplyTimeToLive, getStore, getStoreFactory, getUseMessageIdInResponse, handleException, isJms102, isPubSubDomain, isReplyExplicitQosEnabled, isStateless, isSynchronous, onMessage, process, processExchange, send, sendError, setConnectionFactory, setCorrelationId, setDestinationChooser, setDestinationResolver, setJms102, setMarshaler, setPubSubDomain, setReplyDeliveryMode, setReplyDestination, setReplyDestinationName, setReplyExplicitQosEnabled, setReplyPriority, setReplyProperties, setReplyTimeToLive, setStateless, setStore, setStoreFactory, setSynchronous, setUseMessageIdInResponse, treatExceptionAsFault
 
Methods inherited from class org.apache.servicemix.common.endpoints.ConsumerEndpoint
configureExchangeTarget, getRole, getTargetEndpoint, getTargetInterface, getTargetOperation, getTargetService, getTargetUri, setTargetEndpoint, setTargetInterface, setTargetOperation, setTargetService, setTargetUri
 
Methods inherited from class org.apache.servicemix.common.endpoints.SimpleEndpoint
done, fail, getChannel, getContext, getExchangeFactory, send, sendSync
 
Methods inherited from class org.apache.servicemix.common.endpoints.AbstractEndpoint
getDefinition, getDescription, getEndpoint, getInterfaceName, getKey, getService, getServiceUnit, isExchangeOkay, prepareExchange, setDefinition, setDescription, setEndpoint, setInterfaceName, setService, setServiceUnit, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

LISTENER_TYPE_DEFAULT

public static final java.lang.String LISTENER_TYPE_DEFAULT
See Also:
Constant Field Values

LISTENER_TYPE_SIMPLE

public static final java.lang.String LISTENER_TYPE_SIMPLE
See Also:
Constant Field Values

TRANSACTED_NONE

public static final java.lang.String TRANSACTED_NONE
See Also:
Constant Field Values

TRANSACTED_XA

public static final java.lang.String TRANSACTED_XA
See Also:
Constant Field Values

TRANSACTED_JMS

public static final java.lang.String TRANSACTED_JMS
See Also:
Constant Field Values
Constructor Detail

JmsConsumerEndpoint

public JmsConsumerEndpoint()

JmsConsumerEndpoint

public JmsConsumerEndpoint(DefaultComponent component,
                           javax.jbi.servicedesc.ServiceEndpoint endpoint)

JmsConsumerEndpoint

public JmsConsumerEndpoint(ServiceUnit serviceUnit,
                           javax.xml.namespace.QName service,
                           java.lang.String endpoint)
Method Detail

getTransacted

public java.lang.String getTransacted()
Returns:
the transacted

setTransacted

public void setTransacted(java.lang.String transacted)
Specifies the type of transaction used to wrap the message exchanges. Valid values are none, xa, and jms.

Parameters:
transacted - the type of transaction wrapper to use

getCacheLevel

public int getCacheLevel()
Returns:
the cacheLevel

setCacheLevel

public void setCacheLevel(int cacheLevel)
Specifies the level of caching allowed by the listener. Valid values are 0 through 3. The values map to the following: The default is CACHE_NONE.
This property only effects consumers whose listenerType property is set to default.

Parameters:
cacheLevel - the cacheLevel to set
See Also:
DefaultMessageListenerContainer.setCacheLevel(int)

getClientId

public java.lang.String getClientId()
Returns:
the clientId

setClientId

public void setClientId(java.lang.String clientId)
Specifies the JMS client id for a shared Connection created and used by this listener.

Parameters:
clientId - the clientId to set
See Also:
AbstractJmsListeningContainer.setClientId(String)

getConcurrentConsumers

public int getConcurrentConsumers()
Returns:
the concurrentConsumers

setConcurrentConsumers

public void setConcurrentConsumers(int concurrentConsumers)
Specifies the number of concurrent consumers created by the listener. This property is only used for consumers whose listenerType property is set to either simple or default.

Parameters:
concurrentConsumers - the number of concurrent consumers to create
See Also:
DefaultMessageListenerContainer.setConcurrentConsumers(int), SimpleMessageListenerContainer.setConcurrentConsumers(int)

getDestination

public javax.jms.Destination getDestination()
Returns:
the destination

setDestination

public void setDestination(javax.jms.Destination destination)
Specifies the JMS Destination used to receive messages.

Parameters:
destination - the JMS destination
See Also:
AbstractMessageListenerContainer.setDestination(Destination)

getDestinationName

public java.lang.String getDestinationName()
Returns:
the destinationName

setDestinationName

public void setDestinationName(java.lang.String destinationName)
Specifies a string identifying the JMS destination used to recieve messages. The destination is resolved using the DesitinationResolver.

Parameters:
destinationName - the destination name
See Also:
AbstractMessageListenerContainer.setDestinationName(String)

getDurableSubscriptionName

public java.lang.String getDurableSubscriptionName()
Returns:
the durableSubscriptionName

setDurableSubscriptionName

public void setDurableSubscriptionName(java.lang.String durableSubscriptionName)
Specifies the name used to register the durable subscription.

Parameters:
durableSubscriptionName - the registration name
See Also:
AbstractMessageListenerContainer.setDurableSubscriptionName(String)

getExceptionListener

public javax.jms.ExceptionListener getExceptionListener()
Returns:
the exceptionListener

setExceptionListener

public void setExceptionListener(javax.jms.ExceptionListener exceptionListener)
Specifies an ExceptionListener to notify in case of a JMSException is thrown by the registered message listener or the invocation infrastructure.

Parameters:
exceptionListener - the exception listener
See Also:
AbstractMessageListenerContainer.setExceptionListener(ExceptionListener)

getIdleTaskExecutionLimit

public int getIdleTaskExecutionLimit()
Returns:
the idleTaskExecutionLimit

setIdleTaskExecutionLimit

public void setIdleTaskExecutionLimit(int idleTaskExecutionLimit)
Specifies the limit for idle executions of a receive task, not having received any message within its execution. If this limit is reached, the task will shut down and leave receiving to other executing tasks (in case of dynamic scheduling; see the "maxConcurrentConsumers" setting). Within each task execution, a number of message reception attempts (according to the "maxMessagesPerTask" setting) will each wait for an incoming message (according to the "receiveTimeout" setting). If all of those receive attempts in a given task return without a message, the task is considered idle with respect to received messages. Such a task may still be rescheduled; however, once it reached the specified "idleTaskExecutionLimit", it will shut down (in case of dynamic scaling). Raise this limit if you encounter too frequent scaling up and down. With this limit being higher, an idle consumer will be kept around longer, avoiding the restart of a consumer once a new load of messages comes in. Alternatively, specify a higher "maxMessagePerTask" and/or "receiveTimeout" value, which will also lead to idle consumers being kept around for a longer time (while also increasing the average execution time of each scheduled task). This property is only used for consumers whose listenerType property is set to default.

Parameters:
idleTaskExecutionLimit - the number of concurrent consumers to create
See Also:
DefaultMessageListenerContainer.setIdleTaskExecutionLimit(int)

getListenerType

public java.lang.String getListenerType()
Returns:
the listenerType

setListenerType

public void setListenerType(java.lang.String listenerType)
Specifies the type of Spring JMS message listener to use. Valid values are: default, simple, and server.

Parameters:
listenerType - the listener type

getMaxConcurrentConsumers

public int getMaxConcurrentConsumers()
Returns:
the maxConcurrentConsumers

setMaxConcurrentConsumers

public void setMaxConcurrentConsumers(int maxConcurrentConsumers)
Specifies the maximum number of concurrent consumers created by the listener. If this setting is higher than "concurrentConsumers", the listener container will dynamically schedule new consumers at runtime, provided that enough incoming messages are encountered. Once the load goes down again, the number of consumers will be reduced to the standard level ("concurrentConsumers") again. This property is only used for consumers whose listenerType property is set to default.

Parameters:
maxConcurrentConsumers - the maximum number of concurrent consumers to create
See Also:
DefaultMessageListenerContainer.setMaxConcurrentConsumers(int)

getMaxMessagesPerTask

public int getMaxMessagesPerTask()
Returns:
the maxMessagesPerTask

setMaxMessagesPerTask

public void setMaxMessagesPerTask(int maxMessagesPerTask)
Specifies the number of attempts to receive messages per task. The default is -1 which specifies an unlimited number of attempts.
This property only effects consumers whose listenerType property is set to either default or simple.

Parameters:
maxMessagesPerTask - the number of attempts to make
See Also:
DefaultMessageListenerContainer.setMaxMessagesPerTask(int)

getMessageSelector

public java.lang.String getMessageSelector()
Returns:
the messageSelector

setMessageSelector

public void setMessageSelector(java.lang.String messageSelector)
Specifies the message selector string to use. The message selector string should conform to the descrition in the JMS spec.

Parameters:
messageSelector - the message selector string
See Also:
AbstractMessageListenerContainer.setMessageSelector(String)

isPubSubNoLocal

public boolean isPubSubNoLocal()
Returns:
the pubSubNoLocal

setPubSubNoLocal

public void setPubSubNoLocal(boolean pubSubNoLocal)
Specifies if messages published by the listener's Connection are suppressed. The default is false.
This property only effects consumers whose listenerType property is set to either default or simple.

Parameters:
pubSubNoLocal - messages are surpressed?
See Also:
AbstractPollingMessageListenerContainer.setPubSubNoLocal(boolean), SimpleMessageListenerContainer.setPubSubNoLocal(boolean)

getReceiveTimeout

public long getReceiveTimeout()
Returns:
the receiveTimeout

setReceiveTimeout

public void setReceiveTimeout(long receiveTimeout)
Specifies the timeout for receiving a message in milliseconds. Defaults to 1000.
This property only effects consumers whose listenerType property is set to default.

Parameters:
receiveTimeout - the number of milliseconds before timing out
See Also:
AbstractPollingMessageListenerContainer.setReceiveTimeout(long)

getRecoveryInterval

public long getRecoveryInterval()
Returns:
the recoveryInterval

setRecoveryInterval

public void setRecoveryInterval(long recoveryInterval)
Specifies the interval, in milliseconds, between attempts to recover after a failed listener set-up. Defaults to 5000.
This property only effects consumers whose listenerType property is set to default.

Parameters:
recoveryInterval - the number of milliseconds to wait
See Also:
DefaultMessageListenerContainer.setRecoveryInterval(long)

getSessionAcknowledgeMode

public int getSessionAcknowledgeMode()
Returns:
the sessionAcknowledgeMode

setSessionAcknowledgeMode

public void setSessionAcknowledgeMode(int sessionAcknowledgeMode)
Specifies the acknowledgment mode that is used when creating a Session to send a message. Deafults to Session.AUTO_ACKNOWLEDGE.

Parameters:
sessionAcknowledgeMode - the sessionAcknowledgeMode to set
See Also:
JmsAccessor.setSessionAcknowledgeMode(int)

isSubscriptionDurable

public boolean isSubscriptionDurable()
Returns:
the subscriptionDurable

setSubscriptionDurable

public void setSubscriptionDurable(boolean subscriptionDurable)
Specifies if the listener uses a durable subscription to listen for messages. Defaults to false.

Parameters:
subscriptionDurable - the listener uses a durable subscription?
See Also:
AbstractMessageListenerContainer.setSubscriptionDurable(boolean)

getLocationURI

public java.lang.String getLocationURI()
Overrides:
getLocationURI in class AbstractConsumerEndpoint

activate

public void activate()
              throws java.lang.Exception
Specified by:
activate in interface Endpoint
Overrides:
activate in class AbstractConsumerEndpoint
Throws:
java.lang.Exception

start

public void start()
           throws java.lang.Exception
Specified by:
start in interface Endpoint
Overrides:
start in class SimpleEndpoint
Throws:
java.lang.Exception

stop

public void stop()
          throws java.lang.Exception
Specified by:
stop in interface Endpoint
Overrides:
stop in class SimpleEndpoint
Throws:
java.lang.Exception

deactivate

public void deactivate()
                throws java.lang.Exception
Specified by:
deactivate in interface Endpoint
Overrides:
deactivate in class AbstractConsumerEndpoint
Throws:
java.lang.Exception

validate

public void validate()
              throws javax.jbi.management.DeploymentException
Specified by:
validate in interface Endpoint
Overrides:
validate in class ConsumerEndpoint
Throws:
javax.jbi.management.DeploymentException

createListenerContainer

protected org.springframework.jms.listener.AbstractMessageListenerContainer createListenerContainer()


Copyright © 2005-2014 FuseSource. All Rights Reserved.