org.apache.servicemix.jms.endpoints
Class JmsProviderEndpoint

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.ProviderEndpoint
              extended by org.apache.servicemix.jms.endpoints.JmsProviderEndpoint
All Implemented Interfaces:
Endpoint, JmsEndpointType
Direct Known Subclasses:
JmsSoapProviderEndpoint

public class JmsProviderEndpoint
extends ProviderEndpoint
implements JmsEndpointType

A Spring-based JMS provider endpoint

Since:
3.2
Author:
gnodet

Nested Class Summary
 class JmsProviderEndpoint.JmsTemplate102Util
           
 class JmsProviderEndpoint.JmsTemplateUtil
           
 
Field Summary
 
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
JmsProviderEndpoint()
           
 
Method Summary
 void activate()
          Start this endpoint.
protected  javax.jms.Destination chooseDestination(javax.jbi.messaging.MessageExchange exchange, java.lang.Object message, javax.jms.Session session, DestinationChooser chooser, java.lang.Object defaultDestination)
          Choose a JMS destination given the chooser, a default destination and name
protected  void createAndStartListener()
           
protected  JmsProviderMarshaler createDefaultMarshaler()
          Creates the default marshaler for the endpoint if no custom marshaler has been set
protected  org.springframework.jms.listener.AbstractMessageListenerContainer createListenerContainer()
          Create the message listener container to receive response messages.
protected  JmsProviderEndpoint.JmsTemplateUtil createTemplate()
          Create the JMS template to be used to send the JMS messages.
 void deactivate()
          Stops this endpoint.
 javax.jms.ConnectionFactory getConnectionFactory()
           
 int getDeliveryMode()
           
 javax.jms.Destination getDestination()
           
protected  javax.jms.Destination getDestination(javax.jbi.messaging.MessageExchange exchange, java.lang.Object message, javax.jms.Session session)
          Retrieve the destination where the JMS message should be sent to.
 DestinationChooser getDestinationChooser()
           
 java.lang.String getDestinationName()
           
 org.springframework.jms.support.destination.DestinationResolver getDestinationResolver()
           
 JmsProviderMarshaler getMarshaler()
           
 int getPriority()
           
 long getReceiveTimeout()
           
 javax.jms.Destination getReplyDestination()
           
 DestinationChooser getReplyDestinationChooser()
           
 java.lang.String getReplyDestinationName()
           
 org.apache.servicemix.store.Store getStore()
           
 org.apache.servicemix.store.StoreFactory getStoreFactory()
           
 long getTimeToLive()
           
 boolean isExplicitQosEnabled()
           
 boolean isJms102()
          Determines if the provider used JMS 1.0.2 compliant APIs.
 boolean isMessageIdEnabled()
           
 boolean isMessageTimestampEnabled()
           
 boolean isPreserveMessageQos()
           
 boolean isPubSubDomain()
           
 boolean isPubSubNoLocal()
           
protected  void onMessage(javax.jms.Message message)
          Process a JMS response message.
 void process(javax.jbi.messaging.MessageExchange exchange)
          Process the incoming JBI exchange
protected  void processInOnly(javax.jbi.messaging.MessageExchange exchange, javax.jbi.messaging.NormalizedMessage in)
          Process an InOnly or RobustInOnly exchange.
protected  void processInOnlyInSession(javax.jbi.messaging.MessageExchange exchange, javax.jbi.messaging.NormalizedMessage in, javax.jms.Session session)
          Process an InOnly or RobustInOnly exchange inside a JMS session.
protected  void processInOut(javax.jbi.messaging.MessageExchange exchange, javax.jbi.messaging.NormalizedMessage in)
          Process an InOut or InOptionalOut exchange.
protected  void processInOutInSession(javax.jbi.messaging.MessageExchange exchange, javax.jbi.messaging.NormalizedMessage in, javax.jms.Session session)
          Process an InOnly or RobustInOnly exchange inside a JMS session.
 void setConnectionFactory(javax.jms.ConnectionFactory connectionFactory)
          Specifies the ConnectionFactory used by the endpoint.
 void setDeliveryMode(int deliveryMode)
          Specifies the JMS delivery mode used for the reply.
 void setDestination(javax.jms.Destination destination)
          Specifies the JMS Destination used to send messages.
 void setDestinationChooser(DestinationChooser destinationChooser)
          Specifies a class implementing logic for choosing the destination used to send messages.
 void setDestinationName(java.lang.String destinationName)
          Specifies a string identifying the JMS destination used to send messages.
 void setDestinationResolver(org.springframework.jms.support.destination.DestinationResolver destinationResolver)
          Specifies the class implementing logic for converting strings into destinations.
 void setExplicitQosEnabled(boolean explicitQosEnabled)
          Specifies if the QoS values specified for the endpoint are explicitly used when a messages is sent.
 void setJms102(boolean jms102)
          Specifies if the provider uses JMS 1.0.2 compliant APIs.
 void setMarshaler(JmsProviderMarshaler marshaler)
          Specifies the class implementing the message marshaler.
 void setMessageIdEnabled(boolean messageIdEnabled)
          Specifies if your endpoint requires JMS message IDs.
 void setMessageTimestampEnabled(boolean messageTimestampEnabled)
          Specifies if your endpoints requires time stamps on its messages.
 void setPreserveMessageQos(boolean preserveMessageQos)
          Specifies whether we want to send message using the QoS settings specified on the message instead in order to preserve message QoS.
 void setPriority(int priority)
          Specifies the priority assigned to the JMS messages.
 void setPubSubDomain(boolean pubSubDomain)
          Specifies if the destination is a topic.
 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 setReplyDestination(javax.jms.Destination replyDestination)
          Sets the reply destination.
 void setReplyDestinationChooser(DestinationChooser replyDestinationChooser)
          Specifies a class implementing logic for choosing the destination used to recieve replies.
 void setReplyDestinationName(java.lang.String replyDestinationName)
          Sets the name of the reply destination.
 void setStore(org.apache.servicemix.store.Store store)
          Sets the store used to store JBI exchanges that are waiting for a response JMS message.
 void setStoreFactory(org.apache.servicemix.store.StoreFactory storeFactory)
          Sets the store factory used to create the store.
 void setTimeToLive(long timeToLive)
          Specifies the number of milliseconds a message is valid.
 void validate()
          Validate this endpoint.
 
Methods inherited from class org.apache.servicemix.common.endpoints.ProviderEndpoint
getRole, processInOut
 
Methods inherited from class org.apache.servicemix.common.endpoints.SimpleEndpoint
done, fail, getChannel, getContext, getExchangeFactory, send, sendSync, start, stop
 
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
 

Constructor Detail

JmsProviderEndpoint

public JmsProviderEndpoint()
Method Detail

getDestination

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

setDestination

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

Parameters:
destination - the 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 send messages. The destination is resolved using the DesitinationResolver.

Parameters:
destinationName - the destination name

isJms102

public boolean isJms102()
Determines if the provider used JMS 1.0.2 compliant APIs.

Returns:
true if the provider is JMS 1.0.2 compliant

setJms102

public void setJms102(boolean jms102)
Specifies if the provider uses JMS 1.0.2 compliant APIs. Defaults to false.

Parameters:
jms102 - provider is JMS 1.0.2 compliant?

getConnectionFactory

public javax.jms.ConnectionFactory getConnectionFactory()
Returns:
the connectionFactory

setConnectionFactory

public void setConnectionFactory(javax.jms.ConnectionFactory connectionFactory)
Specifies the ConnectionFactory used by the endpoint.

Parameters:
connectionFactory - the connectionFactory to set

getDeliveryMode

public int getDeliveryMode()
Returns:
the deliveryMode

setDeliveryMode

public void setDeliveryMode(int deliveryMode)
Specifies the JMS delivery mode used for the reply. Defaults to (2)(PERSISTENT).

Parameters:
deliveryMode - the JMS delivery mode

getDestinationChooser

public DestinationChooser getDestinationChooser()
Returns:
the destinationChooser

setDestinationChooser

public void setDestinationChooser(DestinationChooser destinationChooser)
Specifies a class implementing logic for choosing the destination used to send messages.

Parameters:
destinationChooser - the destination chooser for sending messages

getReplyDestinationChooser

public DestinationChooser getReplyDestinationChooser()
Returns:
the destination chooser for the reply destination

setReplyDestinationChooser

public void setReplyDestinationChooser(DestinationChooser replyDestinationChooser)
Specifies a class implementing logic for choosing the destination used to recieve replies.

Parameters:
replyDestinationChooser - the destination chooser used for the reply destination

getDestinationResolver

public org.springframework.jms.support.destination.DestinationResolver getDestinationResolver()
Returns:
the destinationResolver

setDestinationResolver

public void setDestinationResolver(org.springframework.jms.support.destination.DestinationResolver destinationResolver)
Specifies the class implementing logic for converting strings into destinations. The default is DynamicDestinationResolver.

Parameters:
destinationResolver - the destination resolver implementation

isExplicitQosEnabled

public boolean isExplicitQosEnabled()
Returns:
the explicitQosEnabled

setExplicitQosEnabled

public void setExplicitQosEnabled(boolean explicitQosEnabled)
Specifies if the QoS values specified for the endpoint are explicitly used when a messages is sent. The default is false.

Parameters:
explicitQosEnabled - should the QoS values be sent?

getMarshaler

public JmsProviderMarshaler getMarshaler()
Returns:
the marshaler

setMarshaler

public void setMarshaler(JmsProviderMarshaler marshaler)
Specifies the class implementing the message marshaler. The message marshaller is responsible for marshalling and unmarshalling JMS messages. The default is DefaultProviderMarshaler.

Parameters:
marshaler - the marshaler implementation

isMessageIdEnabled

public boolean isMessageIdEnabled()
Returns:
the messageIdEnabled

setMessageIdEnabled

public void setMessageIdEnabled(boolean messageIdEnabled)
Specifies if your endpoint requires JMS message IDs. Setting the messageIdEnabled property to false causes the endpoint to call its message producer's setDisableMessageID() with a value of true. The JMS broker is then given a hint that it does not need to generate message IDs or add them to the messages from the endpoint. The JMS broker can choose to accept the hint or ignore it.

Parameters:
messageIdEnabled - the endpoint requires message IDs?

isMessageTimestampEnabled

public boolean isMessageTimestampEnabled()
Returns:
the messageTimestampEnabled

setMessageTimestampEnabled

public void setMessageTimestampEnabled(boolean messageTimestampEnabled)
Specifies if your endpoints requires time stamps on its messages. Setting the messageTimeStampEnabled property to false causes the endpoint to call its message producer's setDisableMessageTimestamp() method with a value of true. The JMS broker is then given a hint that it does not need to generate message IDs or add them to the messages from the endpoint. The JMS broker can choose to accept the hint or ignore it.

Parameters:
messageTimestampEnabled - the endpoint requires time stamps?

getPriority

public int getPriority()
Returns:
the priority

setPriority

public void setPriority(int priority)
Specifies the priority assigned to the JMS messages. Defaults to 4.

Parameters:
priority - the message priority

isPubSubDomain

public boolean isPubSubDomain()
Returns:
the pubSubDomain

setPubSubDomain

public void setPubSubDomain(boolean pubSubDomain)
Specifies if the destination is a topic. true means the destination is a topic. false means the destination is a queue.

Parameters:
pubSubDomain - the destination is a topic?

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.

Parameters:
pubSubNoLocal - messages are surpressed?

getReceiveTimeout

public long getReceiveTimeout()
Returns:
the receiveTimeout

setReceiveTimeout

public void setReceiveTimeout(long receiveTimeout)
Specifies the timeout for receiving a message in milliseconds.

Parameters:
receiveTimeout - milliseconds to wait

getTimeToLive

public long getTimeToLive()
Returns:
the timeToLive

setTimeToLive

public void setTimeToLive(long timeToLive)
Specifies the number of milliseconds a message is valid.

Parameters:
timeToLive - number of milliseonds a message lives

getStoreFactory

public org.apache.servicemix.store.StoreFactory getStoreFactory()

setStoreFactory

public void setStoreFactory(org.apache.servicemix.store.StoreFactory storeFactory)
Sets the store factory used to create the store. If none is set, a MemoryStoreFactory will be created and used instead.

Parameters:
storeFactory - the factory

getStore

public org.apache.servicemix.store.Store getStore()

setStore

public void setStore(org.apache.servicemix.store.Store store)
Sets the store used to store JBI exchanges that are waiting for a response JMS message. The store will be automatically created if not set.

Parameters:
store - the store

getReplyDestination

public javax.jms.Destination getReplyDestination()

setReplyDestination

public void setReplyDestination(javax.jms.Destination replyDestination)
Sets the reply destination. This JMS destination will be used as the default destination for the response messages when using an InOut JBI exchange. It will be used if the replyDestinationChooser does not return any value.

Parameters:
replyDestination -

getReplyDestinationName

public java.lang.String getReplyDestinationName()

setReplyDestinationName

public void setReplyDestinationName(java.lang.String replyDestinationName)
Sets the name of the reply destination. This property will be used to create the replyDestination using the destinationResolver when the endpoint starts if the replyDestination has not been set.

Parameters:
replyDestinationName -

isPreserveMessageQos

public boolean isPreserveMessageQos()
Returns:
the preserveMessageQos

setPreserveMessageQos

public void setPreserveMessageQos(boolean preserveMessageQos)
Specifies whether we want to send message using the QoS settings specified on the message instead in order to preserve message QoS. The default is false.

Parameters:
preserveMessageQos - should support per message QoS?

process

public void process(javax.jbi.messaging.MessageExchange exchange)
             throws java.lang.Exception
Process the incoming JBI exchange

Specified by:
process in interface Endpoint
Overrides:
process in class ProviderEndpoint
Parameters:
exchange -
Throws:
java.lang.Exception

processInOnly

protected void processInOnly(javax.jbi.messaging.MessageExchange exchange,
                             javax.jbi.messaging.NormalizedMessage in)
                      throws java.lang.Exception
Process an InOnly or RobustInOnly exchange. This method uses the JMS template to create a session and call the processInOnlyInSession(javax.jbi.messaging.MessageExchange, javax.jbi.messaging.NormalizedMessage, javax.jms.Session) method.

Overrides:
processInOnly in class ProviderEndpoint
Parameters:
exchange -
in -
Throws:
java.lang.Exception

processInOnlyInSession

protected void processInOnlyInSession(javax.jbi.messaging.MessageExchange exchange,
                                      javax.jbi.messaging.NormalizedMessage in,
                                      javax.jms.Session session)
                               throws java.lang.Exception
Process an InOnly or RobustInOnly exchange inside a JMS session. This method delegates the JMS message creation to the marshaler and uses the JMS template to send it.

Parameters:
exchange -
in -
session -
Throws:
java.lang.Exception

processInOut

protected void processInOut(javax.jbi.messaging.MessageExchange exchange,
                            javax.jbi.messaging.NormalizedMessage in)
                     throws java.lang.Exception
Process an InOut or InOptionalOut exchange. This method uses the JMS template to create a session and call the processInOutInSession(javax.jbi.messaging.MessageExchange, javax.jbi.messaging.NormalizedMessage, javax.jms.Session) method.

Parameters:
exchange -
in -
Throws:
java.lang.Exception

processInOutInSession

protected void processInOutInSession(javax.jbi.messaging.MessageExchange exchange,
                                     javax.jbi.messaging.NormalizedMessage in,
                                     javax.jms.Session session)
                              throws java.lang.Exception
Process an InOnly or RobustInOnly exchange inside a JMS session. This method delegates the JMS message creation to the marshaler and uses the JMS template to send it. If the JMS destination that was used to send the message is not the default one, it synchronously wait for the message to come back using a JMS selector. Else, it just returns and the response message will come back from the listener container.

Parameters:
exchange -
in -
session -
Throws:
java.lang.Exception

onMessage

protected void onMessage(javax.jms.Message message)
Process a JMS response message. This method delegates to the marshaler for the JBI out message creation and sends it in to the NMR.

Parameters:
message -

getDestination

protected javax.jms.Destination getDestination(javax.jbi.messaging.MessageExchange exchange,
                                               java.lang.Object message,
                                               javax.jms.Session session)
                                        throws javax.jms.JMSException
Retrieve the destination where the JMS message should be sent to.

Parameters:
exchange -
message -
session -
Returns:
Throws:
javax.jms.JMSException

chooseDestination

protected javax.jms.Destination chooseDestination(javax.jbi.messaging.MessageExchange exchange,
                                                  java.lang.Object message,
                                                  javax.jms.Session session,
                                                  DestinationChooser chooser,
                                                  java.lang.Object defaultDestination)
                                           throws javax.jms.JMSException
Choose a JMS destination given the chooser, a default destination and name

Parameters:
exchange -
message -
session -
chooser -
defaultDestination -
Returns:
Throws:
javax.jms.JMSException

activate

public void activate()
              throws java.lang.Exception
Start this endpoint.

Specified by:
activate in interface Endpoint
Overrides:
activate in class ProviderEndpoint
Throws:
java.lang.Exception

createAndStartListener

protected void createAndStartListener()
                               throws java.lang.Exception
Throws:
java.lang.Exception

deactivate

public void deactivate()
                throws java.lang.Exception
Stops this endpoint.

Specified by:
deactivate in interface Endpoint
Overrides:
deactivate in class ProviderEndpoint
Throws:
java.lang.Exception

validate

public void validate()
              throws javax.jbi.management.DeploymentException
Validate this endpoint.

Specified by:
validate in interface Endpoint
Overrides:
validate in class AbstractEndpoint
Throws:
javax.jbi.management.DeploymentException

createDefaultMarshaler

protected JmsProviderMarshaler createDefaultMarshaler()
Creates the default marshaler for the endpoint if no custom marshaler has been set

Returns:
the default marshaler implementation

createTemplate

protected JmsProviderEndpoint.JmsTemplateUtil createTemplate()
Create the JMS template to be used to send the JMS messages.

Returns:

createListenerContainer

protected org.springframework.jms.listener.AbstractMessageListenerContainer createListenerContainer()
Create the message listener container to receive response messages.

Returns:


Copyright © 2005-2014 FuseSource. All Rights Reserved.