This example will create a Topic Connection Factory and a Topic, and also includes a spring configuration example.
Add the following to your cargo configuration in pom.xml:
<cargo.resource.resource.jmsConnectionFactory> cargo.resource.name=jms/ConnectionFactory| cargo.resource.type=com.caucho.jms.JVMTopicConnectionFactory| </cargo.resource.resource.jmsConnectionFactory> <cargo.resource.resource.jmsMyTopic> cargo.resource.name=jms/myTopic| cargo.resource.type=javax.jms.Topic| cargo.resource.class=com.caucho.jms.memory.MemoryTopic| cargo.resource.parameters=topicName=myTopic </cargo.resource.resource.jmsMyTopic>
After you run 'mvn cargo:start', you can verify the config made it into your resin.conf with:
$> less target/resin3x/home/conf/resin.conf
....
<resource>
<jndi-name>jms/ConnectionFactory</jndi-name>
<type>com.caucho.jms.ConnectionFactoryImpl</type>
</resource>
<resource>
<jndi-name>jms/myTopic</jndi-name>
<type>com.caucho.jms.memory.MemoryTopic</type>
<init topicName="myTopic"/>
</resource>
In web.xml:
<resource-ref>
<res-ref-name>jms/ConnectionFactory</res-ref-name>
<res-type>javax.jms.ConnectionFactory</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
You can also add a resource-ref for the Topic, but that is not necessarily required.
A spring config might look like this:
<jee:jndi-lookup id="jmsConnectionFactory" jndi-name="jms/ConnectionFactory" proxy-interface="javax.jms.ConnectionFactory" lookup-on-startup="false" resource-ref="true"/>
<bean id="myTopicListener" class="foo.bar.MyTopicListenerBean"/>
<jms:listener-container connection-factory="jmsConnectionFactory" destination-type="topic">
<jms:listener destination="myTopic" ref="myTopicListener" method="receiveMessage" />
</jms:listener-container>