users@glassfish.java.net

Re: Glassfish v2 + Generic RA + JBoss Messaging

From: <glassfish_at_javadesktop.org>
Date: Mon, 29 Jun 2009 05:14:38 PDT

Great to hear from you ramesh,

Here I goooo, (Please don't "Turn the page") :)

My first attachment is the snapshot of the [b]asadmin[/b] commands(In windows).
All commands have been executed successfully. :)

[b]sun-ejb-jar.xml[/b]

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 8.1 EJB 2.1//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_2_1-1.dtd">
<sun-ejb-jar>
    <enterprise-beans>
        <ejb>
            <ejb-name>sunMDB</ejb-name>
            <jndi-name>sunMDB</jndi-name>
            <resource-ref>
                <res-ref-name>jms/MyQueueConnectionFactory</res-ref-name>
                <jndi-name>jms/MyQCF</jndi-name>
            </resource-ref>
            <resource-env-ref>
                <resource-env-ref-name>jms/OutQueue</resource-env-ref-name>
                <jndi-name>jms/OutQueue</jndi-name>
            </resource-env-ref>
            <bean-pool>
                <steady-pool-size>10</steady-pool-size>
                <resize-quantity>2</resize-quantity>
                <max-pool-size>30</max-pool-size>
                <pool-idle-timeout-in-seconds>60</pool-idle-timeout-in-seconds>
            </bean-pool>
            <mdb-resource-adapter>
                <resource-adapter-mid>genericra</resource-adapter-mid>
                <activation-config>
                    <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-property>
                        <activation-config-property-name>MaxPoolSize</activation-config-property-name>
                        <activation-config-property-value>30</activation-config-property-value>
                    </activation-config-property>
                    <activation-config-property>
                        <activation-config-property-name>RedeliveryAttempts</activation-config-property-name>
                        <activation-config-property-value>3</activation-config-property-value>
                    </activation-config-property>
                    <activation-config-property>
                        <activation-config-property-name>RedeliveryInterval</activation-config-property-name>
                        <activation-config-property-value>1</activation-config-property-value>
                    </activation-config-property>
                    <activation-config-property>
                        <activation-config-property-name>ReconnectAttempts</activation-config-property-name>
                        <activation-config-property-value>1000</activation-config-property-value>
                    </activation-config-property>
                    <activation-config-property>
                        <activation-config-property-name>ReconnectInterval</activation-config-property-name>
                        <activation-config-property-value>1</activation-config-property-value>
                    </activation-config-property>
                    <activation-config-property>
                        <activation-config-property-name>DestinationJndiName</activation-config-property-name>
                        <activation-config-property-value>/queue/A</activation-config-property-value>
                    </activation-config-property>
                    <activation-config-property>
                        <activation-config-property-name>ConnectionFactoryJndiName</activation-config-property-name>
                        <activation-config-property-value>java:/XAConnectionFactory</activation-config-property-value>
                    </activation-config-property>
                </activation-config>
            </mdb-resource-adapter>
        </ejb>
    </enterprise-beans>
</sun-ejb-jar>


[b]ejb-jar.xml[/b]

<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"
              version="2.1">

    <display-name>queue2queue</display-name>
    <enterprise-beans>
        <message-driven>
            <ejb-name>sunMDB</ejb-name>
            <ejb-class>ejb.NewMessageBean</ejb-class>
            <transaction-type>Container</transaction-type>
            <message-destination-type>javax.jms.Queue</message-destination-type>
            <message-destination-link>/queue/A</message-destination-link>
            <resource-ref>
                <description>
                    Queue Conn factory where the message will be placed having been consumed.
                </description>
                <res-ref-name>jms/MyQueueConnectionFactory</res-ref-name>
                <res-type>javax.jms.QueueConnectionFactory</res-type>
                <res-auth>Container</res-auth>
                <res-sharing-scope>Shareable</res-sharing-scope>
            </resource-ref>
            <resource-env-ref>
                <description>
The actual queue on the broker that the message is placed onto.
                </description>
                <resource-env-ref-name>jms/OutQueue</resource-env-ref-name>
                <resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
            </resource-env-ref>
        </message-driven>
    </enterprise-beans>
    <assembly-descriptor>
        <container-transaction>
            <description>This value was set as a default by Sun ONE Studio.</description>
            <method>
                <ejb-name>sunMDB</ejb-name>
                <method-name>*</method-name>
            </method>
            <trans-attribute>Required</trans-attribute>
        </container-transaction>
        <message-destination>
            <display-name>Destination for QueueConsumer</display-name>
            <message-destination-name>/queue/A</message-destination-name>
        </message-destination>
    </assembly-descriptor>
</ejb-jar>

[b]NewMessageBean.java (MDB)[/b]

package ejb;

import javax.ejb.MessageDrivenBean;
import javax.ejb.MessageDrivenContext;
import javax.naming.*;
import javax.jms.*;

public class NewMessageBean implements MessageDrivenBean,
        MessageListener {

    private transient MessageDrivenContext mdc = null;
    private Context context;
    Queue queue = null;
    QueueConnectionFactory queueConnectionFactory = null;

    public NewMessageBean() {
        System.out.println("In NewMessageBean.NewMessageBean()");
    }

    public void setMessageDrivenContext(MessageDrivenContext mdc) {
        System.out.println("In " + "NewMessageBean.setMessageDrivenContext()");
        this.mdc = mdc;
    }


    public void ejbCreate() {
        System.out.println("In NewMessageBean.ejbCreate()");
// try {
// Context jndiContext = new InitialContext();
// queueConnectionFactory = (QueueConnectionFactory) jndiContext.lookup("java:comp/env/jms/outboundXAQCF");
// queue = (Queue) jndiContext.lookup("jms/outqueue");
// } catch (Exception e) {
// System.out.println("MESSAGEBEAN.ejbcreate() got Exception " + e.getMessage());
// e.printStackTrace();
// }

    }

    public void onMessage(Message inMessage) {
        System.out.println("MESSAGE BEAN:");
    }


    public void ejbRemove() {
        System.out.println("In ActiveMQTestBean.remove()");
    }
} // class

Please find attached [b]server logs[/b].

I am able to run the "standalone application"(read from /queue/A and redirect to /queue/B) as well as a "synchronous receiver"(listens to /queue/A and sends messages to /queue/B via jms/OutQueue) with the same glassfish resource connectors. This error happens only while implementing a message driven bean.

Thanks Ramesh :)
[Message sent by forum member 'rubycube' (rubycube)]

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