|
|||||
|
|||||
Outbound JMS
Jencks supports both Inbound JMS messaging as well as outbound messaging. Outbound messaging (or message outflow to use JCA speak) allows you to pool and reuse JMS sessions and connections when sending messages. In addition JCA takes care of associating inbound and outbound messaging with the same local transaction or XA. This is very useful if you are inside either a Servlet or EJB type environemnt where you want to send messages from different threads, but don't want to create & close a connection, session, producer for each send.
ExampleThe following example shows how to configure the JCA container, a JMS broker, the pool & connection manager, the JMS Resource Adaptor and the JMS ConnectionFactory. The main bean you'd actually use as an end user is right near the bottom, the jmsConnectionFactory. <beans> <!-- ###### ActiveMQ Configuration ###### --> <bean id="broker" class="org.apache.activemq.xbean.BrokerFactoryBean"> <property name="config" value="classpath:org/jencks/samples/outbound/broker.xml"/> </bean> <bean id="jmsResourceAdapter" class="org.apache.activemq.ra.ActiveMQResourceAdapter"> <property name="serverUrl" value="vm://localhost"/> </bean> <bean id="jmsQueue" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="queue"/> <property name="jndiEnvironment"> <props> <prop key="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</prop> <prop key="java.naming.provider.url">tcp://localhost:51616</prop> <prop key="queue.queue">example.MyQueue</prop> </props> </property> </bean> <!-- ###### Transaction manager ###### --> <bean id="transactionManager" class="org.jencks.factory.TransactionManagerFactoryBean"/> <!-- ###### Connection Manager ###### --> <bean id="connectionManager" class="org.jencks.factory.ConnectionManagerFactoryBean"> <property name="transactionManager" ref="transactionManager"/> </bean> <!-- ###### JMS Managed Connection Factory ###### --> <bean id="jmsManagedConnectionFactory" class="org.apache.activemq.ra.ActiveMQManagedConnectionFactory"> <property name="resourceAdapter" ref="jmsResourceAdapter"/> </bean> <!-- ###### JMS Connection Factory ###### --> <bean id="jmsConnectionFactory" class="org.jencks.factory.ConnectionFactoryFactoryBean"> <property name="managedConnectionFactory" ref="jmsManagedConnectionFactory"/> <property name="connectionManager" ref="connectionManager"/> </bean> </beans> IMPORTANT: The inbound and outbound config MUST match up. <bean id="jmsResourceAdapter" class="org.activemq.ra.ActiveMQResourceAdapter"> <property name="serverUrl"> <value>vm://localhost</value> </property> <!--property name="useEmbeddedBroker"> <value>true</value> </property> <property name="brokerXmlConfig"> <value>org/jencks/broker.xml</value> </property--> </bean> instead use: <bean id="jmsResourceAdapter" class="org.activemq.ra.ActiveMQResourceAdapter"> <property name="serverUrl" value="tcp://localhost:51616"/> </bean> if working from the example online. In any case, make sure they match. Hopefully this uh, 'documentation issue', will be fixed/changed at some point in the future (right now the main XML is just a link to a file in the CVS repository so I can't just update it and a new test case would have to be made to fix/explain this more clearly). |
|||||
|
Copyright 2003-2006 - The Codehaus. All rights reserved unless otherwise noted.
Powered by Atlassian Confluence
|
|||||