Hi,

I have tried to setup it following the examples, but just not working for me.
Here are some codes:

1)     No annotation in mdb , just a onMessage method. The ejb-jar.xml:


  <enterprise-beans>

    <message-driven>

      <ejb-name>StandardReportsBean</ejb-name>
      
<ejb-class>se.it.newjena.reports.bean.receivers.StandardReportsBean</ejb-class>

      <messaging-type>javax.jms.MessageListener</messaging-type>

      <activation-config>
        <activation-config-property>
          
<activation-config-property-name>destination</activation-config-property-name>
          
<activation-config-property-value>ReportStandardJMSQueue</activation-config-property-value>
        </activation-config-property>
        <activation-config-property>
          
<activation-config-property-name>destinationType</activation-config-property-name>
          
<activation-config-property-value>javax.jms.Queue</activation-config-property-value>
        </activation-config-property>
      </activation-config>

      <resource-ref>
        
<res-ref-name>jms/tdm-newjena/ReportStandardJMSConnFactory</res-ref-name>
        <res-type>javax.jms.ConnectionFactory</res-type>
      </resource-ref>

      <resource-ref>
        <res-ref-name>ReportStandardJMSQueue</res-ref-name>
        <res-type>javax.jms.Queue</res-type>
      </resource-ref>
    </message-driven>

  </enterprise-beans>

2)     The resources in the server.xml for tomcat in Eclipse:

<Resource auth="Container" description="Report Standard JMSQueue" 
factory="org.apache.activemq.jndi.JNDIReferenceFactory" 
name="ReportStandardJMSQueue"  physicalName="ReportStandardJMSQueue" 
type="org.apache.activemq.command.ActiveMQQueue"/>
           <Resource auth="Container" brokerName="LocalActiveMQBroker" 
brokerURL="tcp://localhost:61616" description="Report Standard JMS Connection 
Factory"    factory="org.apache.activemq.jndi.JNDIReferenceFactory" 
name="jms/tdm-newjena/ReportStandardJMSConnFactory" 
type="org.apache.activemq.ActiveMQConnectionFactory"/>

<Context docBase="C:\JavaDev\tools\apache-tomcat-6.0.29\webapps\openejb" 
path="/openejb" reloadable="true"/>

3)     The code to send message:
                QueueConnection queueConnection = null;
        QueueSession queueSession = null;
        Queue queue = null;
        QueueSender queueSender = null;
        ObjectMessage message = null;

        try {
            // check if jndiContext and queueConnectionFactory are set if not
            // throw an exception

            if (jndiContext == null || queueConnectionFactory == null)
                throw new Exception("InitialContext or QueueConnectionFactory 
is not set");

            /*
             * Look up queue.
             */
            queue = (Queue) jndiContext.lookup("ReportStandardJMSQueue");
            queueConnection = queueConnectionFactory.createQueueConnection();
            queueSession = queueConnection.createQueueSession(false, 
Session.AUTO_ACKNOWLEDGE);
            queueSender = queueSession.createSender(queue);


            /*
             * Send message
             */
            message = queueSession.createObjectMessage();
            message.setObject(wrapper);
            queueSender.send(message);

            logger.info("Jena reports - a message has been sent");

        }

      I also tried the below in ejb-jar.xml, but it will say the queue has 
binded to context, and if I removed the resource for this queue in server.xml, 
then it can't find the queue for sending messages.
      <resource-env-ref>
        <resource-env-ref-name>ReportStandardJMSQueue</resource-env-ref-name>
        <resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
      </resource-env-ref>



--
View this message in context: 
http://openejb.979440.n4.nabble.com/MDB-not-invoked-tp4548110p4550743.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to