|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Need a return code after putting the message on the Q |
« View previous topic :: View next topic » |
Author |
Message
|
Vishy |
Posted: Wed Sep 17, 2003 11:32 am Post subject: Need a return code after putting the message on the Q |
|
|
Novice
Joined: 30 Jul 2003 Posts: 21
|
Hi,
Q1: need a return code
I am successful in reading a string and put that on the Q. Now I need the method to give a return a code of ( say 0 or 1) meaning if it was successful in putting the message or not. Should I return a boolean value for my method. Any help in the code will be of greathelp.
Q2: Also I want to read an XML message as a string of close to 32k any special coding considerations required while reading into MQ?
Q3:Do I need to specify all the parameters while declaring the message?
I thought its more relavent in this section and hence posted here in addition to general discussion. sorry for inconvenience, if caused
Thanks
import com.ibm.mq.*;
import java.util.*;
import java.io.*;
public class CompleteMessage{
public static void main(String[] args) {
String m_msg = null;
if (args.length < 1) {
System.out.println("Must provide message data parm at least");
return;
}
f (args.length > 0) {
m_msg = args[0];
}
System.out.println("Sent Msg= " + m_msg);
try {
m_msg = sendMessage(m_msg);
return;
} catch (Exception e) {
System.out.println(e);
}
return;
}
public static String sendMessage(String m_msg) throws MQException, IOException{
MQQueueManager qMgr = null;
String qManager = "AMQSDF";
byte[] message_Id = null;
String msgData = null;
MQQueue system_default_local_queue = null;
try{
MQEnvironment.channel = "SYSTEM.DEF.SVRCONN";
MQEnvironment.hostname = "localhost";
MQEnvironment.port = 9050;
// Create a connection to QManager
qMgr = new MQQueueManager(qManager);
// Set up the options on the Q we wish to open
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
// Now specify the Q that we wish to open and the open options
system_default_local_queue = qMgr.accessQueue("SYSTEM.DEFAULT.LOCAL.QUEUE", openOptions);
// Define a simple message
MQMessage mqMsg = new MQMessage();
//mqMsg.messageType = MQC.MQMT_REQUEST;
mqMsg.format = MQC.MQFMT_STRING;
mqMsg.priority = MQC.MQPRI_PRIORITY_AS_Q_DEF;
mqMsg.expiry = 1200;
mqMsg.writeString(m_msg);
System.out.println("The message string is" + m_msg);
//mqMsg.replyToQueueName = "SYSTEM.DEFAULT.LOCAL.QUEUE";
// Specify the message options
MQPutMessageOptions mqPMO = new MQPutMessageOptions();
// Put the message on the Q
system_default_local_queue.put(mqMsg,mqPMO);
System.out.println( "The request message was put successfully on the queue");
message_Id = mqMsg.messageId;
System.out.println("The message Id is " + mqMsg.messageId);
}catch(MQException e){
System.out.println("MQException: in QManager,PMO " + e.reasonCode + " " + e.getMessage());
}
try{
// Close the Q
system_default_local_queue.close();
// Disconnect from QueueManager
qMgr.disconnect();
}catch (MQException ex) {
System.out.println("A WebSphere MQ error occurred : Completion code " + ex.completionCode + " Reason code " + ex.reasonCode);
} finally {
return msgData;
}
}
} |
|
Back to top |
|
 |
EddieA |
Posted: Wed Sep 17, 2003 12:21 pm Post subject: |
|
|
 Jedi
Joined: 28 Jun 2001 Posts: 2453 Location: Los Angeles
|
Q1. Look in your other thread. http://www.mqseries.net/phpBB2/viewtopic.php?t=10788
Q2. No.
Q3. Not quite sure what you mean. Are you talking about setting the Header fields when you put a message. If so, then you only need to set the values that you want different from the Default.
Cheers, _________________ Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0 |
|
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
|
|
|
|