1 Reply Latest reply on Aug 12, 2009 11:37 AM by Igor Beslic

    Messaging with IBM Websphere MQ 7 JCA Adapter - Multiple Top

    Igor Beslic Newbie

      Hi!
      refering to this http://www.jboss.org/index.html?module=bb&op=viewtopic&t=158262 and section related to defining adminObject for Topic:

      <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>

      I have new question.

      I want to publish messages to approximately 100 topics organized this way:
      CITY/NEWS/City_1
      CITY/NEWS/City_2
      ..
      CITY/NEWS/City_N
      ...
      CITY/WEATHER/City_1
      ...
      etc.
      Approach with defining Topic AdminObject in JNDI is OK if I had couple well known topics. But in this case where I need large number of topics and there is possibility some will be created during runtime (since I'm publisher) it is not appropriate.

      I'm not sure is there way to create topic manually? I even thought about using AdminObjectFactory to create Topics programmatic way but I'm concerned about system performance and not sure is it possible?

      Currently I dont use JCA adapter. I use WSMQ API to connect, publish messages to topics:
      ieg.
      mqQueueManager.put(CMQC.MQOT_TOPIC, "", queueManagerOut, topic, mqmessage, options);


      Can I get similar funcionality with Websphere MQ 7 JCA Adapter?


        • 1. Re: Messaging with IBM Websphere MQ 7 JCA Adapter - Multiple
          Igor Beslic Newbie

          Hi. I've solved this myself. Solution was easy:
          There is no need to configure topic destination. Once connection factory is obtained use session object to create Topic.
          Here is code:

          InitialContext ic = new InitialContext();
          
          ConnectionFactory cf = (javax.jms.ConnectionFactory) ic.lookup("java:wmq/myFC");
          
          Connection conn = cf.createConnection();
          conn.start();
          
          Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
          Topic topic = sess.createTopic("CITY/NEWS/City_1");
          MessageProducer mp = sess.createProducer(topic);
          mp.send(sess.createTextMessage("***This is topic message***" ));
          conn.close();//comment this if calling from MDB