Alrighty I am stumped with the issue here...I have a normal java class as a 
MessageProducer which sends messages to a Queue and I have an MDB as the 
message consumer which is listening to the above Queue.

The Producer successfully sends messages to this Queue..but the MDB isn't 
consuming them. The most strangest part is I have a System println set in the 
MDB's constructor and that is not being printed on the Jboss server console.  
The funny part is the console shows the MDB to be deployed but doesn't show the 
System println's either in the constructor or the ejbCreate methods. I am 
practically stumped by this. The messages can be seen on the testQueue via the 
jmx-console but the messages are not getting consumed. Any help here would be 
appreciated.

I am using JBoss-4.0.2 and here's a piece of the Snippet of the MDB code and 
the associated xml files and yes i have set the 
jbossmq-destinations-service.xml too

//MDB Code
public class MessageConsumerBean implements MessageDrivenBean, MessageListener {

    /**
     * 
     * Constructor
     *
     */
    public MessageConsumerBean() {  
        System.out.println("The MessageConsumerBean is : " + hashCode());
    }    
    
    
    
    /**
     * 
     * @param ctx
     * @throws javax.ejb.EJBException
     * 
     */
    public void setMessageDrivenContext(MessageDrivenContext ctx)
            throws EJBException {
        this.ctx = ctx;
    }
    
    //ejb create method
    public void ejbCreate() {
        System.out.println("The MDB MessageConsumerBean instantiated.....");
        setPTP();
    }


    private void setPTP() {
        
        
        try {
            connection = getConnection();
        } catch(SystemException sysEx) {
            logger.error("Exception occured while getting the QueueConnection", 
sysEx);
        }
        
        //create a queue session
        try {
            session = connection.createQueueSession(false, 
Session.AUTO_ACKNOWLEDGE);
        } catch(JMSException jmsEx) {
            logger.error("JMSException occured while creating a queue 
receiver.", jmsEx);
        }

        //starts the JMS connection.
        try {
            connection.start();
        } catch(JMSException jmsEx) {
            logger.error("JMSException occured while starting a JMS 
Connection.", jmsEx);
        }

        
    }


     //onMessage
    public void onMessage(Message message) {
        System.out.println("Executing the onMessage method....." + message);
        //--- etc
    }

    //getting the connection
    //Returns a JMS QueueConnection object
    private QueueConnection getConnection() throws SystemException {
        Context ctx = null;
        
        try {
            ctx = new InitialContext();
            factory = 
(QueueConnectionFactory)ctx.lookup(CONNECTION_FACTORY_REF);
            connection = factory.createQueueConnection();
            System.out.println("The queue connection is.... " + connection);
        } catch(NamingException nameEx) {
            throw new SystemException("NamingException occured in getting a 
QueueConnection", nameEx);
        } catch(JMSException jmsEx) {
            throw new SystemException("JMSException occured in getting a 
QueueConnection", jmsEx);
        }
        
        return connection;
    }

    public void ejbRemove()  {
        System.out.println("The MessageConsumerBean ejbRemove...");
        ctx = null;
        
        //closing the QueueSession
        if (session != null) {
            try {
                session.close();
            } catch(Exception ex) {
                logger.error("Exception while closing the session");
            }
        }
        
        //closing the QueueConnection
        if (connection != null) {
            try {
                connection.close();
            } catch(Exception ex) {
                logger.error("Exception while closing the connection");
            }
        }
    }
}

//ejb-xml

<?xml version="1.0" encoding="UTF-8"?>

<ejb-jar xmlns="http://java.sun.com/xml/ns/j2ee"; 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd";>
        
        <display-name>JMS Message Driven Bean</display-name>
         
         <enterprise-beans>
                <message-driven>
                                <ejb-name>JMSMessageConsumerEJB</ejb-name>
                                
<ejb-class>com.test.messaging.MessageConsumerBean</ejb-class>
                                <transaction-type>Container</transaction-type>
                                <message-selector>MessageFormat = 'Version 
3.4'</message-selector>
                                
<acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
                                <message-driven-destination>
                                        
<destination-type>javax.jms.Queue</destination-type>
                                </message-driven-destination>
                                <resource-ref>
                                        <res-ref-name>java:JmsXA</res-ref-name>
                                        
<res-type>javax.jms.QueueConnectionFactory</res-type>
                                        <res-auth>Container</res-auth>
                                </resource-ref>
                        </message-driven>
                </enterprise-beans>
</ejb-jar>


//jboss.xml
<!DOCTYPE jboss PUBLIC
          "-//JBoss//DTD JBOSS 4.0//EN"
          "http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd";>

    <enterprise-beans>
        <message-driven>
            <ejb-name>JMSMessageConsumerEJB</ejb-name>
            
<destination-jndi-name>queue/java.jms.TestQueue</destination-jndi-name>
            <resource-ref>
                <res-ref-name>java:JmsXA</res-ref-name>
                <jndi-name>java:/ConnectionFactory</jndi-name>
            </resource-ref>
        </message-driven>
    </enterprise-beans>



//entry in the jbossmq-destinations-service.xml

----

  <!-- Test JMS Queues -->
  
    <depends 
optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager
  

//Console output for ejb deployment is 
02:51:15,845 INFO  [EjbModule] Deploying JMSMessageConsumerEJB
02:51:21,002 INFO  [EJBDeployer] Deployed: file:/C:/jboss-4.0.2/server/default/d
eploy/test.ear/testmdb.jar


View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3889053#3889053

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3889053


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to