geronimo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rsumner <r...@sumnerfamily.com>
Subject Re: JMS ConnectionFactory Resource injection into a Session Bean
Date Sun, 25 Jan 2009 02:51:01 GMT

David,

I appreciate the response.  Here is a little more information explaining
what I needed to do to make the session bean work:

in the ejb-jar.xml:
  <enterprise-beans>
 	<session>
 		<ejb-name>MySessionBean</ejb-name>
 		<ejb-class>my.MySessionBean</ejb-class>
 		<session-type>Stateless</session-type>
 		<resource-ref> 		
 			<res-ref-name>DefaultActiveMQConnectionFactory</res-ref-name>
 			<res-type>javax.jms.ConnectionFactory</res-type>
 			<res-auth>Container</res-auth>
 			<res-sharing-scope>Shareable</res-sharing-scope>
 		</resource-ref>
	  <message-destination-ref>
	    <message-destination-ref-name>
	      SendReceiveQueue
	    </message-destination-ref-name>
	    <message-destination-type>
	      javax.jms.Queue
	    </message-destination-type>
	    <message-destination-usage>
	      Produces
	    </message-destination-usage>
	    <message-destination-link>SendReceiveQueue</message-destination-link>
	  </message-destination-ref>
 	</session>
  </enterprise-beans>

In the openejb-jar.xml:
    <ejb:enterprise-beans>
        <ejb:message-driven>
            <ejb:ejb-name>MyMDB</ejb:ejb-name>
            <name:resource-adapter>
                <name:resource-link>ActiveMQ RA</name:resource-link>
            </name:resource-adapter>
        </ejb:message-driven>
        <ejb:session>
            <ejb:ejb-name>MySessionBean</ejb:ejb-name>
            <name:resource-ref>
               
<name:ref-name>DefaultActiveMQConnectionFactory</name:ref-name>
               
<name:resource-link>DefaultActiveMQConnectionFactory</name:resource-link>
            </name:resource-ref>           
        </ejb:session>
    </ejb:enterprise-beans>

Lastly, in the Session Bean, I did have to use name rather than mappedName.
	@Resource(name="DefaultActiveMQConnectionFactory")
	protected ConnectionFactory jmsFactory;
	
	@Resource(name="SendReceiveQueue")
	protected Queue jmsQueue;


djencks wrote:
> 
> use name-"foo" not mappedName="foo" in your annotations.
> 
> Annotations work the same in servlets and ejbs.  We have a sample that  
> has an mdb and a servlet that sends messages to the servlet.  See the  
> jms-mdb sample described under
> http://cwiki.apache.org/GMOxDOC21/sample-applications.html
> 
> thanksd
> david jencks
> 
> 
-- 
View this message in context: http://www.nabble.com/JMS-ConnectionFactory-Resource-injection-into-a-Session-Bean-tp21644793s134p21648020.html
Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.


Mime
View raw message