Version 2

    Index

    1. Versions, Environment, and Assumptions

    2. High-Level Steps

    3. Resources

    Versions, Environment, and Assumptions

    Versions & Environment
    • JDK 1.6
    • JBss 5.0.0
    • WebSphere 7.0.1.0
    Assubptions
    • I assume you already have a maven project which can be deployed as a EJB3 project in to JBoss

     

    High-Level Steps

    1. Create Message Driven Bean to Receive Messages from the Queue
    2. Create Session Bean to Send Messages to the Queue
    3. Configure WebSphere MQ ActivationConfigProperty in ejb3-interceptors-aop.xml (Optional)

     

     

    1. Create Message Driven Bean to Receive Messages from the Queue

     

     

    WebSphereMQListenerMDB.java

     

    @MessageDriven(name = "webSphereMQListenerMDB",

            activationConfig = {

                    @ActivationConfigProperty(propertyName = "messagingType", propertyValue = "javax.jms.MessageListener"),

                    @ActivationConfigProperty(propertyName = "destination", propertyValue = "LIS.PRO.AMD.MSG.QDC.SVC"),

                    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),

                    @ActivationConfigProperty(propertyName = "channel", propertyValue = "PROQDIB.SVRCONN"),

                    @ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "false"),

                    @ActivationConfigProperty(propertyName="hostName", propertyValue="qdciad39.qdx.com"),

                    @ActivationConfigProperty(propertyName="port", propertyValue="1461"),

                    @ActivationConfigProperty(propertyName="queueManager", propertyValue="REFDMQ01"),

                    @ActivationConfigProperty(propertyName = "username", propertyValue = "proqdib"),

                    @ActivationConfigProperty(propertyName = "transportType", propertyValue = "CLIENT")

            })

    @ResourceAdapter(value = "wmq.jmsra.rar")

    @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)

    public class WebSphereMQListenerMDB implements MessageListener {

     

        public void onMessage(Message message) {

            try {

                if (message instanceof TextMessage) {

                    TextMessage txtMsg = (TextMessage) message;

                    logger.info("Received message");

                    logger.info("----------------");

                    logger.info(" >> " + txtMsg.getText());                   

                }

                else {

                    logger.error("Unknown message received. type of message is " + message.getClass());

                }

            }

            catch (Exception e) {

                logger.error("Exception occurred while processing the message", e);

            }

        }

    }

     

    2. Create Session Bean to Send Messages to the Queue

    Please refer to the attached source code.

     

    3. Configure WebSphere MQ ActivationConfigProperty in ejb3-interceptors-aop.xml (Optional)

     

    • Create the following configuration in ejb3-interceptors-aop.xml

     

    ejb3-interceptors-aop.xml

     

    <domain name="IBMMQ Message Driven Bean" extends="Message Driven Bean" inheritBindings="true">

          <annotation expr="!class(@org.jboss.ejb3.annotation.DefaultActivationSpecs)">

             @org.jboss.ejb3.annotation.DefaultActivationSpecs ({@javax.ejb.ActivationConfigProperty(propertyName = "channel", propertyValue = "PROQDIB.SVRCONN"),@javax.ejb.ActivationConfigProperty(propertyName = "hostName", propertyValue = "qdciad39.qdx.com"),@javax.ejb.ActivationConfigProperty(propertyName = "queueManager", propertyValue = "REFDMQ01"),@javax.ejb.ActivationConfigProperty(propertyName = "port", propertyValue = "1461"),@javax.ejb.ActivationConfigProperty(propertyName = "transportType", propertyValue = "CLIENT"),@javax.ejb.ActivationConfigProperty(propertyName = "destination", propertyValue = "LIS.PRO.AMD.MSG.QDC.SVC"),@javax.ejb.ActivationConfigProperty(propertyName = "username", propertyValue = "proqdib")})

          </annotation>

    </domain>

     

    • Update the MDB as bellow.

     

    WebSphereMQListenerMDB.java

     

    @MessageDriven(name = "webSphereMQListenerMDB",

            activationConfig = {

                    @ActivationConfigProperty(propertyName = "messagingType", propertyValue = "javax.jms.MessageListener"),

                    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),

                    @ActivationConfigProperty(propertyName = "useJNDI", propertyValue = "false"),

                    @ActivationConfigProperty(propertyName = "transportType", propertyValue = "CLIENT")

            })

    @ResourceAdapter(value = "wmq.jmsra.rar")

    @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)

    @AspectDomain("IBMMQ Message Driven Bean")

    public class WebSphereMQListenerMDB implements MessageListener {}