Package org.apache.camel.component.sjms
Class SjmsEndpoint
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.support.DefaultEndpoint
-
- org.apache.camel.component.sjms.SjmsEndpoint
-
- All Implemented Interfaces:
AutoCloseable
,org.apache.camel.AsyncEndpoint
,org.apache.camel.CamelContextAware
,org.apache.camel.Endpoint
,org.apache.camel.IsSingleton
,org.apache.camel.MultipleConsumersSupport
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.spi.HasId
,org.apache.camel.spi.HeaderFilterStrategyAware
,org.apache.camel.StatefulService
,org.apache.camel.SuspendableService
@UriEndpoint(firstVersion="2.11.0", scheme="sjms", title="Simple JMS", syntax="sjms:destinationType:destinationName", category=MESSAGING) public class SjmsEndpoint extends org.apache.camel.support.DefaultEndpoint implements org.apache.camel.AsyncEndpoint, org.apache.camel.MultipleConsumersSupport, org.apache.camel.spi.HeaderFilterStrategyAware
Send and receive messages to/from a JMS Queue or Topic using plain JMS 1.x API. This component uses plain JMS API where as the jms component uses Spring JMS.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.Logger
logger
-
Constructor Summary
Constructors Constructor Description SjmsEndpoint()
SjmsEndpoint(String uri, org.apache.camel.Component component, String remaining)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected JmsBinding
createBinding()
Creates theJmsBinding
to use.protected ConnectionResource
createConnectionResource(Object source)
org.apache.camel.Consumer
createConsumer(org.apache.camel.Processor processor)
org.apache.camel.Exchange
createExchange(javax.jms.Message message, javax.jms.Session session)
org.apache.camel.Producer
createProducer()
protected void
doStart()
protected void
doStop()
SessionAcknowledgementType
getAcknowledgementMode()
JmsBinding
getBinding()
SjmsComponent
getComponent()
int
getConnectionCount()
javax.jms.ConnectionFactory
getConnectionFactory()
ConnectionResource
getConnectionResource()
int
getConsumerCount()
DestinationCreationStrategy
getDestinationCreationStrategy()
String
getDestinationName()
String
getDurableSubscriptionId()
org.apache.camel.LoggingLevel
getErrorHandlerLoggingLevel()
javax.jms.ExceptionListener
getExceptionListener()
org.apache.camel.spi.HeaderFilterStrategy
getHeaderFilterStrategy()
JmsKeyFormatStrategy
getJmsKeyFormatStrategy()
JmsObjectFactory
getJmsObjectFactory()
MessageCreatedStrategy
getMessageCreatedStrategy()
String
getMessageSelector()
String
getNamedReplyTo()
int
getProducerCount()
long
getReconnectBackOff()
long
getResponseTimeOut()
int
getSessionCount()
Deprecated.int
getTransactionBatchCount()
long
getTransactionBatchTimeout()
TransactionCommitStrategy
getTransactionCommitStrategy()
long
getTtl()
boolean
isAllowNullBody()
boolean
isAsyncStartListener()
boolean
isAsyncStopListener()
boolean
isErrorHandlerLogStackTrace()
boolean
isIncludeAllJMSXProperties()
boolean
isMapJmsMessage()
boolean
isMultipleConsumersSupported()
boolean
isPersistent()
boolean
isPrefillPool()
boolean
isReconnectOnError()
boolean
isSharedJMSSession()
boolean
isSynchronous()
boolean
isTopic()
Flag set by the endpoint used by consumers and producers to determine if the endpoint is a JMS Topic.boolean
isTransacted()
void
setAcknowledgementMode(SessionAcknowledgementType acknowledgementMode)
The JMS acknowledgement name, which is one of: SESSION_TRANSACTED, CLIENT_ACKNOWLEDGE, AUTO_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGEvoid
setAllowNullBody(boolean allowNullBody)
Whether to allow sending messages with no body.void
setAsyncStartListener(boolean asyncStartListener)
Whether to startup the consumer message listener asynchronously, when starting a route.void
setAsyncStopListener(boolean asyncStopListener)
Whether to stop the consumer message listener asynchronously, when stopping a route.void
setBinding(JmsBinding binding)
Sets the binding used to convert from a Camel message to and from a JMS messagevoid
setConnectionCount(Integer connectionCount)
The maximum number of connections available to this endpointvoid
setConnectionFactory(String connectionFactory)
void
setConnectionFactory(javax.jms.ConnectionFactory connectionFactory)
Initializes the connectionFactory for the endpoint, which takes precedence over the component's connectionFactory, if anyvoid
setConnectionResource(String connectionResource)
void
setConnectionResource(ConnectionResource connectionResource)
Initializes the connectionResource for the endpoint, which takes precedence over the component's connectionResource, if anyvoid
setConsumerCount(int consumerCount)
Sets the number of consumer listeners used for this endpoint.void
setDestinationCreationStrategy(DestinationCreationStrategy destinationCreationStrategy)
To use a custom DestinationCreationStrategy.void
setDestinationName(String destinationName)
DestinationName is a JMS queue or topic name.void
setDurableSubscriptionId(String durableSubscriptionId)
Sets the durable subscription Id required for durable topics.void
setErrorHandlerLoggingLevel(org.apache.camel.LoggingLevel errorHandlerLoggingLevel)
Allows to configure the default errorHandler logging level for logging uncaught exceptions.void
setErrorHandlerLogStackTrace(boolean errorHandlerLogStackTrace)
Allows to control whether stacktraces should be logged or not, by the default errorHandler.void
setExceptionListener(javax.jms.ExceptionListener exceptionListener)
Specifies the JMS Exception Listener that is to be notified of any underlying JMS exceptions.void
setHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy strategy)
To use a custom HeaderFilterStrategy to filter header to and from Camel message.void
setIncludeAllJMSXProperties(boolean includeAllJMSXProperties)
Whether to include all JMSXxxx properties when mapping from JMS to Camel Message.void
setJmsKeyFormatStrategy(JmsKeyFormatStrategy jmsKeyFormatStrategy)
Pluggable strategy for encoding and decoding JMS keys so they can be compliant with the JMS specification.void
setJmsObjectFactory(JmsObjectFactory jmsObjectFactory)
To use a custom Jms Object factoryvoid
setMapJmsMessage(boolean mapJmsMessage)
Specifies whether Camel should auto map the received JMS message to a suited payload type, such as javax.jms.TextMessage to a String etc.void
setMessageCreatedStrategy(MessageCreatedStrategy messageCreatedStrategy)
To use the given MessageCreatedStrategy which are invoked when Camel creates new instances of javax.jms.Message objects when Camel is sending a JMS message.void
setMessageSelector(String messageSelector)
Sets the JMS Message selector syntax.void
setNamedReplyTo(String namedReplyTo)
Sets the reply to destination name used for InOut producer endpoints.void
setPersistent(boolean persistent)
Flag used to enable/disable message persistence.void
setPrefillPool(boolean prefillPool)
Whether to prefill the producer connection pool on startup, or create connections lazy when needed.void
setProducerCount(int producerCount)
Sets the number of producers used for this endpoint.void
setReconnectBackOff(long reconnectBackOff)
Backoff in millis on consumer pool reconnection attemptsvoid
setReconnectOnError(boolean reconnectOnError)
Try to apply reconnection logic on consumer poolvoid
setResponseTimeOut(long responseTimeOut)
Sets the amount of time we should wait before timing out a InOut response.void
setSessionCount(int sessionCount)
Deprecated.void
setSharedJMSSession(boolean share)
Specifies whether to share JMS session with other SJMS endpoints.void
setSynchronous(boolean synchronous)
Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).void
setTransacted(boolean transacted)
Specifies whether to use transacted modevoid
setTransactionBatchCount(int transactionBatchCount)
If transacted sets the number of messages to process before committing a transaction.void
setTransactionBatchTimeout(long transactionBatchTimeout)
Sets timeout (in millis) for batch transactions, the value should be 1000 or higher.void
setTransactionCommitStrategy(TransactionCommitStrategy transactionCommitStrategy)
Sets the commit strategy.void
setTtl(long ttl)
Flag used to adjust the Time To Live value of produced messages.-
Methods inherited from class org.apache.camel.support.DefaultEndpoint
configureConsumer, configurePollingConsumer, configureProperties, createAsyncProducer, createEndpointUri, createExchange, createExchange, createPollingConsumer, doInit, equals, getCamelContext, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isBasicPropertyBinding, isBridgeErrorHandler, isLazyStartProducer, isLenientProperties, isPollingConsumerBlockWhenFull, isSingleton, setBasicPropertyBinding, setBridgeErrorHandler, setCamelContext, setComponent, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setLazyStartProducer, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerQueueSize, setProperties, toString
-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doSuspend, 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, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.camel.Endpoint
configureProperties, createAsyncProducer, createExchange, createExchange, createPollingConsumer, getCamelContext, getEndpointBaseUri, getEndpointKey, getEndpointUri, isLenientProperties, isSingletonProducer, setCamelContext
-
-
-
-
Method Detail
-
getComponent
public SjmsComponent getComponent()
- Overrides:
getComponent
in classorg.apache.camel.support.DefaultEndpoint
-
doStart
protected void doStart() throws Exception
- Overrides:
doStart
in classorg.apache.camel.support.DefaultEndpoint
- Throws:
Exception
-
doStop
protected void doStop() throws Exception
- Overrides:
doStop
in classorg.apache.camel.support.DefaultEndpoint
- Throws:
Exception
-
createProducer
public org.apache.camel.Producer createProducer() throws Exception
- Specified by:
createProducer
in interfaceorg.apache.camel.Endpoint
- Throws:
Exception
-
createConsumer
public org.apache.camel.Consumer createConsumer(org.apache.camel.Processor processor) throws Exception
- Specified by:
createConsumer
in interfaceorg.apache.camel.Endpoint
- Throws:
Exception
-
isMultipleConsumersSupported
public boolean isMultipleConsumersSupported()
- Specified by:
isMultipleConsumersSupported
in interfaceorg.apache.camel.MultipleConsumersSupport
-
createConnectionResource
protected ConnectionResource createConnectionResource(Object source)
-
createExchange
public org.apache.camel.Exchange createExchange(javax.jms.Message message, javax.jms.Session session)
-
getBinding
public JmsBinding getBinding()
-
createBinding
protected JmsBinding createBinding()
Creates theJmsBinding
to use.
-
setBinding
public void setBinding(JmsBinding binding)
Sets the binding used to convert from a Camel message to and from a JMS message
-
setDestinationName
public void setDestinationName(String destinationName)
DestinationName is a JMS queue or topic name. By default, the destinationName is interpreted as a queue name.
-
getDestinationName
public String getDestinationName()
-
getHeaderFilterStrategy
public org.apache.camel.spi.HeaderFilterStrategy getHeaderFilterStrategy()
- Specified by:
getHeaderFilterStrategy
in interfaceorg.apache.camel.spi.HeaderFilterStrategyAware
-
setHeaderFilterStrategy
public void setHeaderFilterStrategy(org.apache.camel.spi.HeaderFilterStrategy strategy)
To use a custom HeaderFilterStrategy to filter header to and from Camel message.- Specified by:
setHeaderFilterStrategy
in interfaceorg.apache.camel.spi.HeaderFilterStrategyAware
-
isIncludeAllJMSXProperties
public boolean isIncludeAllJMSXProperties()
-
setIncludeAllJMSXProperties
public void setIncludeAllJMSXProperties(boolean includeAllJMSXProperties)
Whether to include all JMSXxxx properties when mapping from JMS to Camel Message. Setting this to true will include properties such as JMSXAppID, and JMSXUserID etc. Note: If you are using a custom headerFilterStrategy then this option does not apply.
-
getConnectionResource
public ConnectionResource getConnectionResource()
-
setConnectionResource
public void setConnectionResource(ConnectionResource connectionResource)
Initializes the connectionResource for the endpoint, which takes precedence over the component's connectionResource, if any
-
setConnectionResource
public void setConnectionResource(String connectionResource)
-
isSynchronous
public boolean isSynchronous()
- Overrides:
isSynchronous
in classorg.apache.camel.support.DefaultEndpoint
-
setSynchronous
public void setSynchronous(boolean synchronous)
Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).- Overrides:
setSynchronous
in classorg.apache.camel.support.DefaultEndpoint
-
getAcknowledgementMode
public SessionAcknowledgementType getAcknowledgementMode()
-
setAcknowledgementMode
public void setAcknowledgementMode(SessionAcknowledgementType acknowledgementMode)
The JMS acknowledgement name, which is one of: SESSION_TRANSACTED, CLIENT_ACKNOWLEDGE, AUTO_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE
-
isTopic
public boolean isTopic()
Flag set by the endpoint used by consumers and producers to determine if the endpoint is a JMS Topic.
-
getSessionCount
@Deprecated public int getSessionCount()
Deprecated.Returns the number of Session instances expected on this endpoint.
-
setSessionCount
@Deprecated public void setSessionCount(int sessionCount)
Deprecated.Sets the number of Session instances used for this endpoint. Value is ignored for endpoints that require a dedicated session such as a transacted or InOut endpoint.- Parameters:
sessionCount
- the number of Session instances, default is 1
-
getProducerCount
public int getProducerCount()
-
setProducerCount
public void setProducerCount(int producerCount)
Sets the number of producers used for this endpoint.
-
getConsumerCount
public int getConsumerCount()
-
setConsumerCount
public void setConsumerCount(int consumerCount)
Sets the number of consumer listeners used for this endpoint.
-
getTtl
public long getTtl()
-
setTtl
public void setTtl(long ttl)
Flag used to adjust the Time To Live value of produced messages.
-
isPersistent
public boolean isPersistent()
-
setPersistent
public void setPersistent(boolean persistent)
Flag used to enable/disable message persistence.
-
getDurableSubscriptionId
public String getDurableSubscriptionId()
-
setDurableSubscriptionId
public void setDurableSubscriptionId(String durableSubscriptionId)
Sets the durable subscription Id required for durable topics.
-
getResponseTimeOut
public long getResponseTimeOut()
-
setResponseTimeOut
public void setResponseTimeOut(long responseTimeOut)
Sets the amount of time we should wait before timing out a InOut response.
-
getMessageSelector
public String getMessageSelector()
-
setMessageSelector
public void setMessageSelector(String messageSelector)
Sets the JMS Message selector syntax.
-
getTransactionBatchCount
public int getTransactionBatchCount()
-
setTransactionBatchCount
public void setTransactionBatchCount(int transactionBatchCount)
If transacted sets the number of messages to process before committing a transaction.
-
getTransactionBatchTimeout
public long getTransactionBatchTimeout()
-
setTransactionBatchTimeout
public void setTransactionBatchTimeout(long transactionBatchTimeout)
Sets timeout (in millis) for batch transactions, the value should be 1000 or higher.
-
getTransactionCommitStrategy
public TransactionCommitStrategy getTransactionCommitStrategy()
-
setTransactionCommitStrategy
public void setTransactionCommitStrategy(TransactionCommitStrategy transactionCommitStrategy)
Sets the commit strategy.
-
isTransacted
public boolean isTransacted()
-
setTransacted
public void setTransacted(boolean transacted)
Specifies whether to use transacted mode
-
isSharedJMSSession
public boolean isSharedJMSSession()
-
setSharedJMSSession
public void setSharedJMSSession(boolean share)
Specifies whether to share JMS session with other SJMS endpoints. Turn this off if your route is accessing to multiple JMS providers. If you need transaction against multiple JMS providers, use jms component to leverage XA transaction.
-
getNamedReplyTo
public String getNamedReplyTo()
-
setNamedReplyTo
public void setNamedReplyTo(String namedReplyTo)
Sets the reply to destination name used for InOut producer endpoints. The type of the reply to destination can be determined by the starting prefix (topic: or queue:) in its name.
-
setAsyncStartListener
public void setAsyncStartListener(boolean asyncStartListener)
Whether to startup the consumer message listener asynchronously, when starting a route. For example if a JmsConsumer cannot get a connection to a remote JMS broker, then it may block while retrying and/or failover. This will cause Camel to block while starting routes. By setting this option to true, you will let routes startup, while the JmsConsumer connects to the JMS broker using a dedicated thread in asynchronous mode. If this option is used, then beware that if the connection could not be established, then an exception is logged at WARN level, and the consumer will not be able to receive messages; You can then restart the route to retry.
-
setAsyncStopListener
public void setAsyncStopListener(boolean asyncStopListener)
Whether to stop the consumer message listener asynchronously, when stopping a route.
-
isAsyncStartListener
public boolean isAsyncStartListener()
-
isAsyncStopListener
public boolean isAsyncStopListener()
-
isPrefillPool
public boolean isPrefillPool()
-
setPrefillPool
public void setPrefillPool(boolean prefillPool)
Whether to prefill the producer connection pool on startup, or create connections lazy when needed.
-
getDestinationCreationStrategy
public DestinationCreationStrategy getDestinationCreationStrategy()
-
setDestinationCreationStrategy
public void setDestinationCreationStrategy(DestinationCreationStrategy destinationCreationStrategy)
To use a custom DestinationCreationStrategy.
-
isAllowNullBody
public boolean isAllowNullBody()
-
setAllowNullBody
public void setAllowNullBody(boolean allowNullBody)
Whether to allow sending messages with no body. If this option is false and the message body is null, then an JMSException is thrown.
-
isMapJmsMessage
public boolean isMapJmsMessage()
-
setMapJmsMessage
public void setMapJmsMessage(boolean mapJmsMessage)
Specifies whether Camel should auto map the received JMS message to a suited payload type, such as javax.jms.TextMessage to a String etc. See section about how mapping works below for more details.
-
getMessageCreatedStrategy
public MessageCreatedStrategy getMessageCreatedStrategy()
-
setMessageCreatedStrategy
public void setMessageCreatedStrategy(MessageCreatedStrategy messageCreatedStrategy)
To use the given MessageCreatedStrategy which are invoked when Camel creates new instances of javax.jms.Message objects when Camel is sending a JMS message.
-
getJmsKeyFormatStrategy
public JmsKeyFormatStrategy getJmsKeyFormatStrategy()
-
setJmsKeyFormatStrategy
public void setJmsKeyFormatStrategy(JmsKeyFormatStrategy jmsKeyFormatStrategy)
Pluggable strategy for encoding and decoding JMS keys so they can be compliant with the JMS specification. Camel provides two implementations out of the box: default and passthrough. The default strategy will safely marshal dots and hyphens (. and -). The passthrough strategy leaves the key as is. Can be used for JMS brokers which do not care whether JMS header keys contain illegal characters. You can provide your own implementation of the org.apache.camel.component.jms.JmsKeyFormatStrategy and refer to it using the # notation.
-
setConnectionFactory
public void setConnectionFactory(javax.jms.ConnectionFactory connectionFactory)
Initializes the connectionFactory for the endpoint, which takes precedence over the component's connectionFactory, if any
-
setConnectionFactory
public void setConnectionFactory(String connectionFactory)
-
getConnectionFactory
public javax.jms.ConnectionFactory getConnectionFactory()
-
getConnectionCount
public int getConnectionCount()
-
setConnectionCount
public void setConnectionCount(Integer connectionCount)
The maximum number of connections available to this endpoint
-
getExceptionListener
public javax.jms.ExceptionListener getExceptionListener()
-
setExceptionListener
public void setExceptionListener(javax.jms.ExceptionListener exceptionListener)
Specifies the JMS Exception Listener that is to be notified of any underlying JMS exceptions.
-
getErrorHandlerLoggingLevel
public org.apache.camel.LoggingLevel getErrorHandlerLoggingLevel()
-
setErrorHandlerLoggingLevel
public void setErrorHandlerLoggingLevel(org.apache.camel.LoggingLevel errorHandlerLoggingLevel)
Allows to configure the default errorHandler logging level for logging uncaught exceptions.
-
isErrorHandlerLogStackTrace
public boolean isErrorHandlerLogStackTrace()
-
setErrorHandlerLogStackTrace
public void setErrorHandlerLogStackTrace(boolean errorHandlerLogStackTrace)
Allows to control whether stacktraces should be logged or not, by the default errorHandler.
-
getJmsObjectFactory
public JmsObjectFactory getJmsObjectFactory()
-
setJmsObjectFactory
public void setJmsObjectFactory(JmsObjectFactory jmsObjectFactory)
To use a custom Jms Object factory
-
isReconnectOnError
public boolean isReconnectOnError()
-
setReconnectOnError
public void setReconnectOnError(boolean reconnectOnError)
Try to apply reconnection logic on consumer pool
-
getReconnectBackOff
public long getReconnectBackOff()
-
setReconnectBackOff
public void setReconnectBackOff(long reconnectBackOff)
Backoff in millis on consumer pool reconnection attempts
-
-