|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Publishing/Subscribing message using JMS with WMB |
« View previous topic :: View next topic » |
Author |
Message
|
rohittom |
Posted: Fri Oct 10, 2008 5:53 am Post subject: Publishing/Subscribing message using JMS with WMB |
|
|
Novice
Joined: 15 Apr 2008 Posts: 15
|
Hi,
I have working flows for publish/subscribe in WMB6.0 and am able to properly publish and subscribe through rfhutil.
I want to achieve this through JMS but facing the MQRC 2009 error
Using the following code
It works fine till getting the QCF,CONNECTION and TOPIC from JNDI(created in WAS6.0) but then gives this error by saying
javax.jms.JMSException: MQJMS3011: Failed to publish message to MQ queue
LinkedException: com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2009
Code:-
package com;
import javax.jms.*; // JMS interfaces
import javax.naming.*; // Used for JNDI lookup of
import javax.naming.directory.*; // administered objects
import com.ibm.mq.*;
public class PubSubExample {
// Pub/Sub objects used by this program
private static TopicConnectionFactory fact = null;
private static Topic topic = null;
//private static final Log logger = LogFactoryImpl.getLog(Sender.class);
public static void main(String[] args) throws NamingException {
Context ctx = null;
try {
System.out.print( "Initialising JNDI... " );
ctx = new InitialContext();
System.out.println( "Done!" );
} catch ( NamingException nx ) {
System.out.println( "ERROR: " + nx );
}
// LOOKUP TCF
try {
System.out.print( "Obtaining TCF from JNDI... " );
fact = (TopicConnectionFactory)ctx.lookup("jms/tcfLookup");
System.out.println( "Obtained TCF" );
} catch ( NamingException nx ) {
throw nx;
}
// LOOKUP TOPIC
try {
System.out.print( "Obtaining topic T from JNDI... " );
topic = (Topic)ctx.lookup("jms/tLookup");
System.out.println("Topic Obtained-->" + topic);
} catch ( NamingException nx ) {
System.out.println( "ERROR: " + nx );
}
try {
ctx.close();
} catch ( NamingException nx ) {
// Just ignore an exception on closing the context
}
try {
// create connection
TopicConnection conn = fact.createTopicConnection();
// start connection
conn.start();
System.out.println("Successfull topic connection");
// session
TopicSession sess = conn.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
// subscriber
/// TopicSubscriber sub = sess.createSubscriber(t);
// subscriber
//TopicSubscriber subA = sess.createSubscriber(topic);
//publisher
TopicPublisher pubA = sess.createPublisher(topic);
System.out.println("publisher created");
// publish "hello world"
TextMessage hello = sess.createTextMessage();
hello.setStringProperty("JMS_IBM_Format", "MQSTR");
// hello.setStringProperty("JMS_IBM_Report_PAN","MQRO_PAN");
// hello.setStringProperty("JMS_IBM_Report_NAN","MQRO_NAN");
//hello.setStringProperty("JMS_IBM_MsgType","MQMT_DATAGRAM");
hello.setText("<Payload>Hiiiii</Payload>");
pubA.publish(hello);
// hello.setJMSExpiration(-1);
// receive message
//TextMessage m = (TextMessage) sub.receive();
//=[ System.out.println("Message Text = " + m.getText());
// TextMessage m = (TextMessage) subA.receive();
// System.out.println("Message Text = " + m.getText());
// close publishers and subscribers
pubA.close();
// subA.close();
// close session and connection
sess.close();
conn.close();
}
catch ( JMSException je ) {
System.out.println("ERROR: " + je);
System.out.println("LinkedException: " +
je.getLinkedException());
}
}
}
Requires an URGENT HELP !!!!
Thanks in advance |
|
Back to top |
|
 |
fjb_saper |
Posted: Sat Oct 11, 2008 6:33 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
obviously from your post you know java. However it seems that you are quite a novice when it comes to JMS.
Don't get me wrong this is not a bad thing. You know the basis.
The setting of properties shows that you need to beef up on the API and the way some of those are set. Check out the examples and get back to the sun tutorial on JMS. Once you have upgraded your knowledge come back with a more pointed question.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|