users@glassfish.java.net

MDB don't react to messages on its queue

From: <glassfish_at_javadesktop.org>
Date: Wed, 11 Mar 2009 07:34:33 PDT

Hi all,

I'm trying to develop a very simple MDB, for mocking purposes.

I've configure a ConnectionFactory (JNDI Name: "ConnectionFactory") and two queues ("elsagServices" and "printnetpa") in glassfish's admin console.

Then I've written this code:

---------------------------------------------------------------------------------------------------------------------
@MessageDriven(activationConfig = {
            @ActivationConfigProperty(propertyName="destinationType", propertyValue="javax.jms.Queue"),
            @ActivationConfigProperty(propertyName="destination", propertyValue="elsagServices")},
        mappedName="elsagServices")
public class AddressHygienizationService implements MessageListener {

        public AddressHygienizationService() {
                // do nothing
        }

       public void onMessage(Message message) {
                try {
                        System.out.println("Sono dentro!");
                        final InitialContext initialContext = new InitialContext();
                        final ConnectionFactory connectionFactory = (ConnectionFactory) initialContext
                                        .lookup("ConnectionFactory");

                        final Connection connection = connectionFactory.createConnection();
                        final Session session = connection.createSession(false,
                                        Session.AUTO_ACKNOWLEDGE);

                        final Destination printnetPaDestination = (Destination) initialContext
                                        .lookup("printnetpa");

                        connection.start();
                        final MessageProducer producer = session
                                        .createProducer(printnetPaDestination);
                        producer.send(session.createTextMessage("Tutto a posto"));

                        session.close();
                        connection.close();
                } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
        }
}
---------------------------------------------------------------------------------------------------------------------

at the same time, I've got the following sun-ejb.xml:

---------------------------------------------------------------------------------------------------------------------
<sun-ejb-jar>
        <enterprise-beans>
                <ejb>
                        <ejb-name>AddressHygienizationService</ejb-name>
                        <jndi-name>elsagServices</jndi-name>
                        <mdb-connection-factory>
                                <jndi-name>ConnectionFactory</jndi-name>
                        </mdb-connection-factory>
                </ejb>
        </enterprise-beans>
</sun-ejb-jar>
---------------------------------------------------------------------------------------------------------------------

Anyway, during deploy I got the following errror in server.log:

INFO: endpoint.determine.destinationtype
AVVERTENZA: java.lang.AssertionError
        at com.sun.messaging.jmq.jmsserver.service.imq.IMQDirectConnection.checkState(IMQDirectConnection.java:488)
        at com.sun.messaging.jmq.jmsserver.service.imq.IMQConnection.startConnection(IMQConnection.java:494)
        at com.sun.messaging.jmq.jmsserver.data.protocol.ProtocolImpl.resumeConnection(ProtocolImpl.java:432)
        at com.sun.messaging.jmq.jmsserver.service.imq.IMQDirectService.startConnection(IMQDirectService.java:658)
        at com.sun.messaging.jms.ra.DirectConnection.start(DirectConnection.java:421)
        at com.sun.messaging.jms.ra.EndpointConsumer.createDirectMessageConsumer(EndpointConsumer.java:955)
        at com.sun.messaging.jms.ra.EndpointConsumer._init(EndpointConsumer.java:305)
....
....
....
AVVERTENZA: ADM5603:Event listener error [null]

And the final result is that the MDB doesn't react to any message sent to the queue "elsagServices". I'm sure that JMS is fully configured and working, because I wrote a little java program to send and receive text messages and I can send and receive messages without any problem.

Can somebody help me?

Thanks in advance!
[Message sent by forum member 'beppegg' (beppegg)]

http://forums.java.net/jive/thread.jspa?messageID=336380