users@glassfish.java.net

Re: Problem with ActivationConfigProperties of JMS

From: <glassfish_at_javadesktop.org>
Date: Thu, 29 Oct 2009 05:53:58 PDT

hi nigeldeakin,

 I have deployed generic jmsra(genericra 2.0) in glassfish as you suggested and configured the properties with reference of the following link.
"https://genericjmsra.dev.java.net/docs/userguide/userguide.html". i could able to deploy the application successfully. but the MDB is not listening the Queue. i pasted code below please tell me what was the wrong.
 
    [b] deployment descriptor:[/b]

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 EJB 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-ejb-jar_3_0-0.dtd">
<sun-ejb-jar>
    <enterprise-beans>
        <ejb>
            <ejb-name>NewWebService</ejb-name>
            <resource-ref>
                <res-ref-name>jms/QCFactory</res-ref-name>
                <jndi-name>jms/QCFactory</jndi-name>
            </resource-ref>
            <message-destination-ref>
                <message-destination-ref-name>jms/clientQueue</message-destination-ref-name>
                <jndi-name>jms/clientQueue</jndi-name>
            </message-destination-ref>
        </ejb>

        <ejb>
            
            <ejb-name>NewMessageBean</ejb-name>
            <jndi-name>jms/clientQueue</jndi-name>
            

            <mdb-resource-adapter>
                <resource-adapter-mid>genericra</resource-adapter-mid>

                <activation-config>

                    <activation-config-property>
                        <activation-config-property-name>DestinationJndiName</activation-config-property-name>
                        <activation-config-property-value>jms/clientQueue</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-property>
                        <activation-config-property-name>acknowledgeMode</activation-config-property-name>
                        <activation-config-property-value>Auto-acknowledge</activation-config-property-value>
                    </activation-config-property>
                </activation-config>
            </mdb-resource-adapter>
        </ejb>

    </enterprise-beans>
</sun-ejb-jar>

[b]JMS Client[/b]
 
public class NewWebService {
    @Resource(name = "jms/clientQueue")
    private Queue clientQueue;
    @Resource(name = "jms/QCFactory")
    private ConnectionFactory qCFactory;

    /**
     * Web service operation
     */
    @WebMethod(operationName = "operation")
    public String operation(@WebParam(name = "parameter")
    String parameter) {
        try {
            sendJMSMessageToClientQueue(parameter);
            return "Success";
        } catch (JMSException ex) {
            Logger.getLogger(NewWebService.class.getName()).log(Level.SEVERE, null, ex);
            return ex.toString();
        }
    }

    private Message createJMSMessageForjmsClientQueue(Session session, Object messageData) throws JMSException {
        // TODO create and populate message to send
        TextMessage tm = session.createTextMessage();
        tm.setText(messageData.toString());
        return tm;
    }

    private void sendJMSMessageToClientQueue(Object messageData) throws JMSException {
        Connection connection = null;
        Session session = null;
        try {
            connection = qCFactory.createConnection();
            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            MessageProducer messageProducer = session.createProducer(clientQueue);
            messageProducer.send(createJMSMessageForjmsClientQueue(session, messageData));
        } finally {
            if (session != null) {
                try {
                    session.close();
                } catch (JMSException e) {
                    Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Cannot close session", e);
                }
            }
            if (connection != null) {
                connection.close();
            }
        }
    }

}

[b] Message Driven bean[/b]

@MessageDriven(name= "NewMessageBean", activationConfig = {
        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
    })
public class NewMessageBean implements MessageListener {
    
    public NewMessageBean() {
    }

    public void onMessage(Message message) {
        try {
            TextMessage msg = (TextMessage) message;
            System.out.println("####################" + msg.getText());
        } catch (JMSException ex) {
            Logger.getLogger(NewMessageBean.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
}



[b] ra.xml[/b]

Applications> Connector Modules> genericra
 
   

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

<!--
 * Copyright 2004-2005 Sun Microsystems, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
-->


<connector 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/connector_1_5.xsd"
    version="1.5">
    
    <description>Generic JMS Resource Adapter</description>
    <display-name>Generic J2EE Resource Adapter for JMS</display-name>
    <icon></icon>
    <vendor-name>Sun Microsystems, Inc.</vendor-name>
    <eis-type>Java Message Service v 1.1</eis-type>
    <resourceadapter-version>2.0</resourceadapter-version>
    <license>
        <description>Licensed</description>
        <license-required>false</license-required>
    </license>
    <resourceadapter>
        <resourceadapter-class>
            com.sun.genericra.GenericJMSRA
        </resourceadapter-class>
        <config-property>
            <config-property-name>UserName</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
            <config-property-name>Password</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
            <config-property-name>ProviderIntegrationMode</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
            <config-property-name>ConnectionFactoryClassName</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
            <config-property-name>QueueConnectionFactoryClassName</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
            <config-property-name>TopicConnectionFactoryClassName</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
            <config-property-name>XAConnectionFactoryClassName</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
            <config-property-name>XAQueueConnectionFactoryClassName</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
            <config-property-name>XATopicConnectionFactoryClassName</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
            <config-property-name>UnifiedDestinationClassName</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
            <config-property-name>TopicClassName</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
            <config-property-name>QueueClassName</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
            <config-property-name>SupportsXA</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
            <config-property-name>ConnectionFactoryProperties</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
            <config-property-name>JndiProperties</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
            <config-property-name>CommonSetterMethodName</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
            <config-property-name>RMPolicy</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
            <config-property-name>LogLevel</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
            <config-property-name>DeliveryType</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
        </config-property>
        <config-property>
            <config-property-name>UseFirstXAForRedelivery</config-property-name>
            <config-property-type>java.lang.String</config-property-type>
        </config-property>
        
        <!-- @todo: check if all MCF props are listed correctly -->
        <outbound-resourceadapter>
            <connection-definition>
                <managedconnectionfactory-class>
                    com.sun.genericra.outbound.ManagedQueueConnectionFactory
                </managedconnectionfactory-class>
                <config-property>
                    <config-property-name>ConnectionFactoryJndiName</config-property-name>
                    <config-property-type>java.lang.String</config-property-type>
                </config-property>
                <config-property>
                    <config-property-name>ClientId</config-property-name>
                    <config-property-type>java.lang.String</config-property-type>
                </config-property>
                <config-property>
                    <config-property-name>ConnectionValidationEnabled</config-property-name>
                    <config-property-type>java.lang.Boolean</config-property-type>
                </config-property>
                
                <connectionfactory-interface>
                    javax.jms.QueueConnectionFactory
                </connectionfactory-interface>
                <connectionfactory-impl-class>
                    com.sun.genericra.outbound.ConnectionFactory
                </connectionfactory-impl-class>
                <connection-interface>
                    javax.jms.QueueConnection
                </connection-interface>
                <connection-impl-class>
                    com.sun.genericra.outbound.ConnectionHandle
                </connection-impl-class>
            </connection-definition>
            
            <connection-definition>
                <managedconnectionfactory-class>
                    com.sun.genericra.outbound.ManagedTopicConnectionFactory
                </managedconnectionfactory-class>
                <config-property>
                    <config-property-name>ConnectionFactoryJndiName</config-property-name>
                    <config-property-type>java.lang.String</config-property-type>
                </config-property>
                <config-property>
                    <config-property-name>ClientId</config-property-name>
                    <config-property-type>java.lang.String</config-property-type>
                </config-property>
                <config-property>
                    <config-property-name>ConnectionValidationEnabled</config-property-name>
                    <config-property-type>java.lang.Boolean</config-property-type>
                </config-property>
                
                <connectionfactory-interface>
                    javax.jms.TopicConnectionFactory
                </connectionfactory-interface>
                <connectionfactory-impl-class>
                    com.sun.genericra.outbound.ConnectionFactory
                </connectionfactory-impl-class>
                <connection-interface>
                    javax.jms.TopicConnection
                </connection-interface>
                <connection-impl-class>
                    com.sun.genericra.outbound.ConnectionHandle
                </connection-impl-class>
            </connection-definition>
            
            <connection-definition>
                <managedconnectionfactory-class>
                    com.sun.genericra.outbound.ManagedJMSConnectionFactory
                </managedconnectionfactory-class>
                <config-property>
                    <config-property-name>ConnectionFactoryJndiName</config-property-name>
                    <config-property-type>java.lang.String</config-property-type>
                </config-property>
                <config-property>
                    <config-property-name>ClientId</config-property-name>
                    <config-property-type>java.lang.String</config-property-type>
                </config-property>
                <config-property>
                    <config-property-name>ConnectionValidationEnabled</config-property-name>
                    <config-property-type>java.lang.Boolean</config-property-type>
                </config-property>
                
                <connectionfactory-interface>
                    javax.jms.ConnectionFactory
                </connectionfactory-interface>
                <connectionfactory-impl-class>
                    com.sun.genericra.outbound.ConnectionFactory
                </connectionfactory-impl-class>
                <connection-interface>
                    javax.jms.Connection
                </connection-interface>
                <connection-impl-class>
                    com.sun.genericra.outbound.ConnectionHandle
                </connection-impl-class>
            </connection-definition>
            
            <transaction-support>
                XATransaction
            </transaction-support>
            <authentication-mechanism>
                <authentication-mechanism-type>
                    BasicPassword
                </authentication-mechanism-type>
                <credential-interface>
                    javax.resource.spi.security.PasswordCredential
                </credential-interface>
            </authentication-mechanism>
            <reauthentication-support>
                false
            </reauthentication-support>
        </outbound-resourceadapter>
        
        <inbound-resourceadapter>
            <messageadapter>
                <messagelistener>
                    <messagelistener-type>
                        javax.jms.MessageListener
                    </messagelistener-type>
                    <activationspec>
                        <activationspec-class>
                            com.sun.genericra.inbound.ActivationSpec
                        </activationspec-class>
                    </activationspec>
                </messagelistener>
            </messageadapter>
        </inbound-resourceadapter>
        
        <adminobject>
            <adminobject-interface>javax.jms.Queue
            </adminobject-interface>
            <adminobject-class>
                com.sun.genericra.outbound.QueueProxy
            </adminobject-class>
            <config-property>
                <config-property-name>
                    DestinationJndiName
                </config-property-name>
                <config-property-type>
                    java.lang.String
                </config-property-type>
                <config-property-value>
                </config-property-value>
            </config-property>
            <config-property>
                <config-property-name>
                    DestinationProperties
                </config-property-name>
                <config-property-type>
                    java.lang.String
                </config-property-type>
                <config-property-value>
                </config-property-value>
            </config-property>
        </adminobject>
        <adminobject>
            <adminobject-interface>
                javax.jms.Topic
            </adminobject-interface>
            <adminobject-class>
                com.sun.genericra.outbound.TopicProxy
            </adminobject-class>
            <config-property>
                <config-property-name>
                    DestinationJndiName
                </config-property-name>
                <config-property-type>
                    java.lang.String
                </config-property-type>
                <config-property-value>
                </config-property-value>
            </config-property>
            <config-property>
                <config-property-name>
                    DestinationProperties
                </config-property-name>
                <config-property-type>
                    java.lang.String
                </config-property-type>
                <config-property-value>
                </config-property-value>
            </config-property>
        </adminobject>
    </resourceadapter>
</connector>
[Message sent by forum member 'guruvulubojja' (guruvulubojja_at_gmail.com)]

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