3.2. Using the Generic Endpoint or the SOAP Endpoint
3.2.1. Basic Configuration
Procedure
- Decide what type of consumer endpoint to use.
- Specify the name of the service for which this endpoint is acting as a proxy.This is specified using the
service
attribute.TipIf you are using a SOAP consumer and your WSDL file only has one service defined, you do not need to specify the service name. - Specify the name of the endpoint for which this endpoint is acting as a proxy.This is specified using the
endpoint
attribute.TipIf you are using a SOAP consumer and your WSDL file only has one endpoint defined, you do not need to specify the endpoint name. - Specify the connection factory the endpoint will use.The endpoint's connection factory is configured using the endpoint's
connectionFactory
attribute. TheconnectionFactory
attribute's value is a reference to the bean that configures the connection factory. For example, if the connection factory configuration bean is namedwidgetConnectionFactory
, the value of theconnectionFactory
attribute would be#widgetConnectionFactory
.For information on configuring a connection factory see Chapter 2, Configuring the Connection Factory. - Specify the destination onto which the endpoint will place messages.For more information see the section called “Configuring a destination”.
- Specify the ESB endpoint to which incoming messages are targeted.For more information see the section called “Specifying the target endpoint”.
- If you are using a JMS SOAP consumer, specify the location of the WSDL defining the message exchange using the
wsdl
attribute. - If your JMS destination is a topic, set the
pubSubDomaim
attribute totrue
. - If your endpoint is interacting with a broker that only supports JMS 1.0.2, set the
jms102
attribute totrue
.
Configuring a destination
- The endpoint will check to see if you configured the destination explicitly.You configure a destination using a Spring bean. You can add the bean directly to the endpoint by wrapping it in a
jms:destination
child element. You can also configure the bean separately and refer the bean using the endpoint'sdestination
attribute as shown in Example 3.1, “Configuring a Consumer's Destination”.Example 3.1. Configuring a Consumer's Destination
<beans xmlns:jms="http://servicemix.apache.org/jms/1.0" ... > ... <jms:consumer service="my:widgetService" endpoint="jbiWidget" destination="#widgetQueue" ... /> ... <jee:jndi-lookup id="widgetQueue" jndi-name="my.widget.queue"> <jee:environment> java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory java.naming.provider.url=t3://localhost:7001 </jee:environment> </jee:jndi-lookup> ... </beans>
- If you did not explicitly configure a destination, the endpoint will use the value of the
destinationName
attribute to choose its destination.The value of thedestinationName
attribute is a string that will be used as the name for the JMS destination. The binding component's default behavior when you provide a destination name is to resolve the destination using the standard JMSSession.createTopic()
andSession.createQueue()
methods.NoteYou can override the binding component's default behavior by providing a customDestinationResolver
implementation. See Section 7.2, “Using a Custom Destination Resolver”.
Specifying the target endpoint
- If you explicitly specify an endpoint using both the
targetService
attribute and thetargetEndpoint
attribute, the ESB will use that endpoint.ThetargetService
attribute specifies the QName of a service deployed into the ESB. ThetargetEndpoint
attribute specifies the name of an endpoint deployed by the service specified by thetargetService
attribute. - If you only specify a value for the
targetService
attribute, the ESB will attempt to find an appropriate endpoint on the specified service. - If you do not specify a service name or an endpoint name, you must specify an the name of an interface that can accept the message using the
targetInterface
attribute. The ESB will attempt to locate an endpoint that implements the specified interface and direct the messages to it.Interface names are specified as QNames. They correspond to the value of thename
attribute of either a WSDL 1.1serviceType
element or a WSDL 2.0interface
element.
Examples
Example 3.2. Basic Configuration for a Generic Consumer Endpoint
<beans xmlns:jms="http://servicemix.apache.org/jms/1.0" ... > ... <jms:consumer service="my:widgetService" endpoint="jbiWidget" destinationName="widgetQueue" connectionFactory="#connectionFactory" targetService="my:targetService" /> ... </beans>
Example 3.3. Basic Configuration for a SOAP Consumer Endpoint
<beans xmlns:jms="http://servicemix.apache.org/jms/1.0" ... > ... <jms:soap-consumer wsdl="classpath:widgets.wsdl" destinationName="widgetQueue" connectionFactory="#connectionFactory" targetService="my:targetService" /> ... </beans>
3.2.2. Listener Containers
Overview
Types of listener containers
- Simple
- The simple listener container creates a fixed number of JMS sessions at startup and uses them throughout the lifespan of the container. It cannot dynamically adapt to runtime conditions nor participate in externally managed transactions.
- Default
- The default listener container provides the best balance between placing requirements on the JMS provider and features. Because of this, it is the default listerner container for Red Hat JBoss Fuse JMS consumer endpoints. The default listener container can adapt to changing runtime demands. It is also capable of participating in externally managed transactions.
- Server session
- The server session listener container leverages the JMS
ServerSessionPool
SPI to allow for dynamic management of JMS sessions. It provides the best runtime scaling and supports externally managed transactions. However, it requires that your JMS provider supports the JMSServerSessionPool
SPI.
Specifying an endpoint's listener container
listenerType
attribute. Table 3.1, “Values for Configuring a Consumer's Listener Container” lists the values for the listenerType
attribute.
Example 3.4. Configuring a SOAP Consumer to Use the Simple Listener Container
<beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
... >
...
<jms:soap-consumer wsdl="classpath:widgets.wsdl"
destinationName="widgetQueue"
connectionFactory="#connectionFactory"
listenerType="simple" />
...
</beans>
Performace tuning using the listener container
Example 3.5. Tuning a Generic Consumer Endpoint
<beans xmlns:jms="http://servicemix.apache.org/jms/1.0" ... > ... <jms:consumer service="my:widgetService" endpoint="jbiWidget" destinationName="widgetQueue" connectionFactory="#connectionFactory" cacheLevel="3" maxMessagesPerTask="1"/> ... </beans>
Configuring the server session listener container's session factory
ServerSessionPool
SPI to tune an endpoint's performance. In order for the listener container to function,k it uses a ServerSessionFactory
object. By default, the Red Hat JBoss Fuse JMS BC uses the Spring framework's SimpleServerSessionFactory
object. This server session factory creates a new JMS ServerSession
object with a new JMS session everytime it is called.
serverSessionFactory
attribute. This attribute provides a reference to the bean configuring the ServerSessionFactory
object.
ServerSessionFactory
object by adding a serverSessionFactory
child element to the endpoint's configuration. This element would wrap the ServerSessionFactory
object's configuration bean.
CommonsPoolServerSessionFactory
object as a session factory.
Example 3.6. Configuring a Consumer to Use a Pooled Session Factory
<beans xmlns:jms="http://servicemix.apache.org/jms/1.0" ... > ... <jms:consumer service="my:widgetService" endpoint="jbiWidget" destinationName="widgetQueue" connectionFactory="#connectionFactory" listenerType="server" serverSessionFactory="#pooledSessionFactory"/> <bean id="pooledSessionFactory" class="org.springframework.jms.listener.serversession.CommonsPoolServerSessionFactory" /> ... </beans>
3.2.3. Advanced Configuration
Using transactions
transacted
attribute to specify the type of transactions to use. Table 3.3, “Consumer Transaction Support” describes the possible values for the transacted
attribute.
Value | Description |
---|---|
none | Specifies that message exchanges are not wrapped in a transaction. This is the default setting. |
jms | Specifies that message exchanges are wrapped in local JMS transactions. |
xa | Specifies that message exchanges will be wrapped in an externally managed XA transaction. You must also provide a transaction manager when using XA transactions. |
Using message selectors
messageSelector
attribute. The value of the attribute is the string value of the selector. For more information on the syntax used to specify message selectors, see the JMS 1.1 specification.
Using durable subscriptions
subscriptionDurable
attribute to true
. You specify the name used to register the durable subscription using the durableSubscriberName
attribute.
Example 3.7. Consumer using a Durable Subscription
<beans xmlns:jms="http://servicemix.apache.org/jms/1.0" ... > ... <jms:soap-consumer wsdl="classpath:widgets.wsdl" destinationName="widgetQueue" connectionFactory="#connectionFactory" subscriptionDurable="true" durableSubscriberName="widgetSubscriber" /> ... </beans>
3.2.4. SOAP Specific Configuration
Overview
Using the JBI wrapper
useJbiWrapper
attribute to true
.
Example 3.8. Configuring a SOAP Consumer to Use the JBI Wrapper
<beans xmlns:jms="http://servicemix.apache.org/jms/1.0"
... >
...
<jms:soap-consumer wsdl="classpath:widgets.wsdl"
destinationName="widgetQueue"
connectionFactory="#connectionFactory"
useJbiWrapper="true" />
...
</beans>
WSDL verification
validateWsdl
attribute to false
.