3 Replies Latest reply on Aug 7, 2009 11:36 AM by igor.beslic

    Messaging with IBM Websphere MQ 7 JCA Adapter

    igor.beslic

      Hi I have followed JBoss and IBM instructions and succeeded to run MQ JCA with JBoss 5.0.1. I use MQ v7. Both JBossAS 5.0.1 and MQ 7 are installed on WinXP. I use AdminObject to publish topic:
      connectionFactory:
      Code:

      <tx-connection-factory>
       <jndi-name>wmq/myFC</jndi-name>
       <xa-transaction />
       <rar-name>wmq.jmsra.rar</rar-name>
       <connection-definition>javax.jms.ConnectionFactory</connection-definition>
       <config-property name="channel" type="java.lang.String">SYSTEM.DEF.SVRCONN</config-property>
       <config-property name="hostName" type="java.lang.String">localhost</config-property>
       <config-property name="port" type="java.lang.String">1414</config-property>
       <config-property name="queueManager" type="java.lang.String">QM_MYQM</config-property>
       <config-property name="transportType" type="java.lang.String">CLIENT</config-property>
       <config-property name="username" type="java.lang.String">me@MYDOMAIN</config-property>
       <security-domain-and-application>JmsXARealm</security-domain-and-application>
      </tx-connection-factory>




      admin obj:
      Code:

      <mbean code="org.jboss.resource.deployment.AdminObject" name="jca.wmq:name=myTopic">
      <!-- Bind this AdminObject with the JNDI name myTopic -->
      <attribute name="JNDIName">myTopic</attribute>
      <!-- this MBean depends on the WebSphere MQ resource adapter -->
      <depends optional-attribute-name="RARName">jboss.jca:service=RARDeployment,name='wmq.jmsra.rar'</depends>
      <!-- this admin object is a javax.jms.Topic -->
      <attribute name="Type">javax.jms.Topic</attribute>
      <attribute name="Properties">
       persistence=NON
       baseTopicName=myTopic
       brokerPubQueue=SYSTEM.BROKER.DEFAULT.STREAM
       CCSID=1208
      </attribute>
      </mbean>



      This is code in my servlet:
      Code:

      InitialContext ic = new InitialContext();
      
      ConnectionFactory cf = (javax.jms.ConnectionFactory) ic.lookup("java:wmq/myFC");
      Topic topic = (Topic) ic.lookup("myTopic");
      
      Connection conn = cf.createConnection();
      conn.start();
      
      Session sess = conn.createSession(true, Session.AUTO_ACKNOWLEDGE);
      MessageProducer mp = sess.createProducer(topic);
      mp.send(sess.createTextMessage("This is topic message at: " + (new Date())));
      conn.close();



      1. I have trouble that code executes without any exceptions but I still have no any messages in MQ. Does anybody has maybe expirience with topic publishing?
      2. What if I have 100 topics in my MQ. Is there way to programaticly create topic destination? When I use WS MQ API directly there is way to do that but I would like avoid including WSMQ libraries in my app because then using JCA wouldn't make sense.