ejb@glassfish.java.net

Re: How to set up a message destination?

From: Cheng Fang <Cheng.Fang_at_Sun.COM>
Date: Fri, 04 Jan 2008 15:18:18 -0500
Hi Abhijit,

I don't see anything wrong with message-destination-ref.  Why do you want to inject the topic into the mdb, which already consumes messages from that topic?

Can you attach a complete project to reproduce the error? 

-cheng

Abhijit Sarkar wrote:
Hi,
I'm trying to set up a messaging system where a stateless bean is the
producer and a MDB is the consumer. I want to keep it portable and thus not
using "mappedName" attribute in EJB. I've been unable to do it-either I get
a deployment exception or a runtime exception regarding unresolved message
destination. Follows my DDs-pls. help.

ejb.jar.xml

<session>
            <ejb-name>UserServiceBean</ejb-name>
            <ejb-class>in.abhi.trackit.user.UserServiceBean</ejb-class>
            <resource-ref>
                <res-ref-name>jms/ConFactory</res-ref-name>
                <res-type>javax.jms.ConnectionFactory</res-type>
                <injection-target>
                    <injection-target-class>
                        in.abhi.trackit.user.UserServiceBean
                    </injection-target-class>
 
<injection-target-name>conFactory</injection-target-name>
                </injection-target>
            </resource-ref>
            <message-destination-ref>
                <message-destination-ref-name>
                    jms/UserMsgTopic
                </message-destination-ref-name>
 
<message-destination-type>javax.jms.Topic</message-destination-type>
 
<message-destination-usage>Produces</message-destination-usage>
 
<message-destination-link>jms/MsgTopic</message-destination-link>
                <mapped-name>jms/TrackITMsgTopic</mapped-name>
                <injection-target>
                    <injection-target-class>
                        in.abhi.trackit.user.UserServiceBean
                    </injection-target-class>
                    <injection-target-name>topic</injection-target-name>
                </injection-target>
            </message-destination-ref>
        </session>
        
        <message-driven>
            <ejb-name>MessageDistributor</ejb-name>
            <ejb-class>in.abhi.trackit.org.MessageDistributor</ejb-class>
            <messaging-type>javax.jms.MessageListener</messaging-type>
            <transaction-type>Container</transaction-type>
            <message-destination-type>
                javax.jms.Topic
            </message-destination-type>            
            <resource-ref>
                <res-ref-name>jms/ConFactory</res-ref-name>
                <res-type>javax.jms.ConnectionFactory</res-type>
                <injection-target>
                    <injection-target-class>
                        in.abhi.trackit.org.MessageDistributor
                    </injection-target-class>
 
<injection-target-name>conFactory</injection-target-name>
                </injection-target>
            </resource-ref>
            <message-destination-ref>
                <message-destination-ref-name>
                    jms/DistributorMsgTopic
                </message-destination-ref-name>
 
<message-destination-type>javax.jms.Topic</message-destination-type>

 
<message-destination-usage>Consumes</message-destination-usage>    
 
<message-destination-link>jms/MsgTopic</message-destination-link>
                <injection-target>
                    <injection-target-class>
                        in.abhi.trackit.org.MessageDistributor
                    </injection-target-class>
                    <injection-target-name>topic</injection-target-name>
                </injection-target>
            </message-destination-ref>
        </message-driven>
    </enterprise-beans>  
    <interceptors>
        <interceptor>
 
<interceptor-class>in.abhi.trackit.org.TrackITInterceptor</interceptor-class
  
        </interceptor>
        <interceptor>
 
<interceptor-class>in.abhi.trackit.user.UserInterceptor</interceptor-class> 
        </interceptor>
    </interceptors>
    <assembly-descriptor>   
        <interceptor-binding>
            <ejb-name>*</ejb-name> 
 
<interceptor-class>in.abhi.trackit.org.TrackITInterceptor</interceptor-class
  
        </interceptor-binding> 
        <interceptor-binding>
            <ejb-name>UserServiceBean</ejb-name> 
 
<interceptor-class>in.abhi.trackit.user.UserInterceptor</interceptor-class>

        </interceptor-binding> 
        <interceptor-binding>
            <ejb-name>UserServiceBean</ejb-name> 
 
<interceptor-class>in.abhi.trackit.user.UserInterceptor</interceptor-class> 
            <method>
                <method-name>createUser</method-name>                 
            </method>             
        </interceptor-binding> 
        <message-destination>
 
<message-destination-name>jms/MsgTopic</message-destination-name>
        </message-destination>
        <application-exception>
 
<exception-class>java.lang.IllegalArgumentException</exception-class>
            <rollback>true</rollback>
        </application-exception>
    </assembly-descriptor>


sun-ejb.jar.xml
<enterprise-beans>
        <ejb>
            <ejb-name>OrgServiceBean</ejb-name>
            <jndi-name>ejb/OrgService</jndi-name>            
        </ejb>
        <ejb>
            <ejb-name>UserServiceBean</ejb-name>
            <jndi-name>ejb/UserService</jndi-name>
            <resource-ref>
                <res-ref-name>jms/ConFactory</res-ref-name>
                <jndi-name>jms/TrackITConFactory</jndi-name>
            </resource-ref>
            <ior-security-config>
                <transport-config>
                    <integrity>SUPPORTED</integrity>
                    <confidentiality>SUPPORTED</confidentiality>
 
<establish-trust-in-target>SUPPORTED</establish-trust-in-target>
 
<establish-trust-in-client>SUPPORTED</establish-trust-in-client>
                </transport-config>
                <as-context>
                    <auth-method>USERNAME_PASSWORD</auth-method>
                    <realm>default</realm>
                    <required>true</required>
                </as-context>
                <sas-context>
                    <caller-propagation>SUPPORTED</caller-propagation>
                </sas-context>
            </ior-security-config>
        </ejb>
        <ejb>
            <ejb-name>ProjectServiceBean</ejb-name>
            <jndi-name>ejb/ProjectService</jndi-name>
            <ior-security-config>
                <transport-config>
                    <integrity>SUPPORTED</integrity>
                    <confidentiality>SUPPORTED</confidentiality>
 
<establish-trust-in-target>SUPPORTED</establish-trust-in-target>
 
<establish-trust-in-client>SUPPORTED</establish-trust-in-client>
                </transport-config>
                <as-context>
                    <auth-method>USERNAME_PASSWORD</auth-method>
                    <realm>default</realm>
                    <required>true</required>
                </as-context>
                <sas-context>
                    <caller-propagation>SUPPORTED</caller-propagation>
                </sas-context>
            </ior-security-config>
        </ejb>
        <ejb>
            <ejb-name>ModuleServiceBean</ejb-name>
            <jndi-name>ejb/ModuleService</jndi-name>
            <ior-security-config>
                <transport-config>
                    <integrity>SUPPORTED</integrity>
                    <confidentiality>SUPPORTED</confidentiality>
 
<establish-trust-in-target>SUPPORTED</establish-trust-in-target>
 
<establish-trust-in-client>SUPPORTED</establish-trust-in-client>
                </transport-config>
                <as-context>
                    <auth-method>USERNAME_PASSWORD</auth-method>
                    <realm>default</realm>
                    <required>true</required>
                </as-context>
                <sas-context>
                    <caller-propagation>SUPPORTED</caller-propagation>
                </sas-context>
            </ior-security-config>
        </ejb>  
        <ejb>
            <ejb-name>MessageDistributor</ejb-name>
            <jndi-name>jms/TrackITMsgTopic</jndi-name>
            <mdb-connection-factory>                
                <jndi-name>jms/TrackITConFactory</jndi-name>
            </mdb-connection-factory>
        </ejb>
        <message-destination>
 
<message-destination-name>jms/MsgTopic</message-destination-name>
            <jndi-name>jms/TrackITMsgTopic</jndi-name>
        </message-destination>        
    </enterprise-beans>

Regards,
Abhijit

---------------------------------------------------------------------
To unsubscribe, e-mail: ejb-unsubscribe@glassfish.dev.java.net
For additional commands, e-mail: ejb-help@glassfish.dev.java.net