Message driven beans are clients of the Java Messaging Service (JMS).
Message driven beans require a JMS implementation in addition to
Resin-CMP. Resin-EJB provides a simple memory-based JMS implementation.
Message driven beans are used to receive message. Sending messages
uses the standard JMS API as described in
Resin JMS configuration.
Message-driven beans receive messages from JMS
queues and topics. The topics and queues are configured in JNDI as
well as the queue-connection-factory.
<ejb-jar>
<enterprise-beans>
<message-driven>
<ejb-name>foo-message</ejb-name>
<ejb-class>test.cmp_msg.TestBean</ejb-class>
<message-driven-destination>
<jndi-name>jms/topic</jndi-name>
</message-driven-destination>
</message-driven>
</enterprise-beans>
</ejb-jar>
|
| Message Bean Configuration |
ejb-class
Defines the bean's implementation class.
Each message bean must specify an implementation class
which implements the doMessage methods and implements both
javax.ejb.MessageDrivenBean and javax.jms.MessageListener.
Resin will call the bean when a new message is available.
ejb-name
The name of the bean. The value of ejb-name is used to find
the bean in JNDI.
message-driven-destination
Specifies the Queue or Topic the bean will receive messages
from.
message-driven-destination attributes
| Attribute | Meaning
|
| destination-type | either javax.jms.Queue or javax.jms.Topic
|
| jndi-name | JNDI name of the queue or topic for the bean.
|
| subscription-durability | For topics, 'Durable' means the
topic is durable across server restarts.
|
| durable-subscription-name | The subscription name of a
durable topic.
|
message-selector
Defines a query to select only messages matching the selector.
SwiftMQ
The SwiftMQ client is configured
by adding a jndi-link to the web.xml
or resin.conf.
Resin needs the swiftmq.jar from the SwiftMQ distribution in the
classpath, either in resin/lib/swiftmq.jar or in WEB-INF/lib.
web.xml
<web-app>
<jndi-link>
<jndi-name>java:comp/env/jms</jndi-name>
<jndi-factory>com.swiftmq.jndi.InitialContextFactoryImpl</jndi-factory>
<init-param java.naming.provider.url="smqp://localhost:4001/timeout=10000"/>
</jndi-link>
<resource-ref>
<res-ref-name>java:comp/env/cmp</res-ref-name>
<class-name>com.caucho.ejb.EJBServer</class-name>
<init-param queue-connection-factory="java:comp/env/jms/QueueConnectionFactory"/>
</resource-ref>
</web-app>
|
The msg.ejb will contain the queue's name:
msg.ejb
<ejb-jar>
<enterprise-beans>
<message-driven>
<ejb-name>foo</ejb-name>
<ejb-class>test.MyMessageBean</ejb-class>
<message-driven-destination>
<jndi-name>jms/testqueue@router1</jndi-name>
</message-driven-destination>
</message-driven>
</enterprise-beans>
</ejb-jar>
|
The SwiftMQ router will need to be started as a separate process.
Copyright © 1998-2006 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark,
and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc. | ![]() |
|