Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

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 you don't need it for spring.

A spring config might look like this:

<jee:jndi-lookup id="jmsConnectionFactory" jndi-name="jms/ConnectionFactory"&nbsp; 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>
  • No labels