Both the generic consumer endpoint and the SOAP consumer endpoint use Spring listener containers to handle incoming messages. The listener container handles the details of receiving messages from the destination, participating in transactions, and controlling the threads used to dispatch messages to the endpoint.
Fuse ESB's JMS consumer endpoints support three 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 Fuse ESB 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.
By default, consumer endpoints use the default listener container. If you want to configure the an endpoint to use a different listener container, you specify that using the endpoint's listenerType
attribute. Table 3.1 lists the values for the listenerType
attribute.
Example 3.4 shows configuration for SOAP consumer that uses the simple listener container.
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>
There are several ways of tuning the performance of a generic consumer endpoint or a SOAP consumer endpoint. They are all controlled by the listener container used by the endpoint.
Table 3.2 describes the attributes used to tune endpoint performance.
Table 3.2. Attributes Used to Performance Tune Standard JMS Consumers and SOAP JMS Consumers
Example 3.5 shows an example of a generic consumer that allows consumer level message caching and only tries once to receive a message.
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>
The server session listener container uses the JMS 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 Fuse ESB 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.
You can configure the endpoint to use a different server session factory using the serverSessionFactory
attribute. This attribute provides a reference to the bean configuring the ServerSessionFactory
object.
![]() | Note |
---|---|
You can also explicitly configure the endpoint's |
Example 3.6 shows an example of configuring an endpoint to use the Spring framework's 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>