Author |
Message
|
kotha |
Posted: Sat Apr 16, 2005 4:05 pm Post subject: [SOLVED]getting message from UPES |
|
|
Partisan
Joined: 12 Mar 2005 Posts: 333
|
I have developed UPES for an activity which puts a message into a queue from a activity. Now this message is in XML format. My questions are:
1. How to get a message. (I think writing a java program but where it resides and how it works?)
2. After receiving the data from queue from above program, How can we implement next activity?
Bit hazy for me..
Can you give some clear picture of whats all about UPES and why we use it?
the buildtime manual and BPMworkflow manual have discussed about developing UPES. is there any support pack to learn more about it
your help greatly appriciated.
thanx in advance
Last edited by kotha on Thu May 19, 2005 3:47 pm; edited 1 time in total |
|
Back to top |
|
 |
jmac |
Posted: Sat Apr 16, 2005 5:21 pm Post subject: |
|
|
 Jedi Knight
Joined: 27 Jun 2001 Posts: 3081 Location: EmeriCon, LLC
|
Have a look at Chapter 33 in the V3.5 Programming Guide. _________________ John McDonald
RETIRED |
|
Back to top |
|
 |
mca |
Posted: Fri Apr 29, 2005 10:49 am Post subject: |
|
|
Disciple
Joined: 09 Mar 2005 Posts: 196
|
Hi kotha
I have little bit experience with UPES and i had the similar question earlier. Now i think i am able to answer ur question.
When the activity puts a message onto the UPES Q, it will be in XML format. Now u can call an MQGet.java program by either triggering or writing a listener. If you have a look at MQGet program
Code: |
public class MQGet {
public static void main (String args[]) {
try {
String QM = "QM"; //CHANGE THE NAME OF THE UPES QM HERE
String QUEUE = "Q";// CHANGE THE NAME OF UPES Q HERE
MQQueueManager qmgr = new MQQueueManager(QM ) ;
System.out.println("Connected to QMGR " + QM);
int openOptionsForGet = MQC.MQOO_INPUT_SHARED ;
MQQueue OutQueue = qmgr.accessQueue(QUEUE , openOptionsForGet, null, null, null);
MQGetMessageOptions gmo = new MQGetMessageOptions() ;
MQMessage outMessage = new MQMessage();
gmo.matchOptions = MQC.MQMO_MATCH_MSG_ID;
OutQueue.get(outMessage, gmo);
String msgTxt = outMessage.readString(outMessage.getMessageLength());
System.out.println (" The message is \n" + msgTxt);
OutQueue.close();
qmgr.disconnect() ;
}
catch(MQException ex){
System.out.println("MQ Error - Reason code :" + ex.reasonCode);
}
catch (Exception e){
System.out.println("Error : " + e);
}
}
}
|
and if u print "msgtxt" u will find the XML message here. Now if u wanna parse the values out of XML string u need to write a parser. I advice u to go with DOM parser. If u haven't written a parser earlier, PM me i will send u the code for that. Its easy. In this way u take the XML message out of the Q.
Also u were asking how to implement it. Ur java program can reside anywhere in the UNIX box, but see that u have java accessibility from there. Compile the java program and see no errors. Then if u are using UNIX or its flavor write a shell script that has the library path and class path specified and give the name of the compiled MQGet class and make sure u specify its path. Then create a trigger monitor in the QM properties and specify the absolute path of the "shell script" in APPLICID section and it will take care of the rest like picking up the message and getting disconnected later.
I am also new to this forum. Actually it is helping me a lot. So, trying to help with my half-knowledge. Some one plzz correct me if i am wrong
MCA |
|
Back to top |
|
 |
kotha |
Posted: Fri Apr 29, 2005 1:00 pm Post subject: |
|
|
Partisan
Joined: 12 Mar 2005 Posts: 333
|
Thats great!!. This info is useful to get started. Thanx for your message. |
|
Back to top |
|
 |
vennela |
Posted: Fri Apr 29, 2005 1:15 pm Post subject: |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
|
Back to top |
|
 |
kotha |
Posted: Thu May 12, 2005 11:26 am Post subject: |
|
|
Partisan
Joined: 12 Mar 2005 Posts: 333
|
I can display messages in my command prompt by running the provided code(MQGet.java). Now I need to send some of the fields as a Mail. For that I need to parse the XML code and send mail.
Issue: I want to save the XML code that I get from a QUEUE to a file so that I can parse it by a parser.java and then send a mail with needed fields.
Question: How to save the XML code into a file, say message.xml??
It is more of a programming question. I think some of you have done it.
Any help? |
|
Back to top |
|
 |
mca |
Posted: Thu May 12, 2005 12:04 pm Post subject: |
|
|
Disciple
Joined: 09 Mar 2005 Posts: 196
|
hi kotha,
If i understand your question, you may not need a file to store the XML message u got from the Q. After getting the message, u can have that in a STRING msgTxt(variable) and send this as parameter/argument to the MessageParser.java program where u can parse the XML and take the values you need out of them and the way i suggested looks like this:
Code: |
public static void main (String args[]) {
try {
String QM = "QM"; // UR Queue Manager Name
String QUEUE = "Q"; // UR Local Queue Name
// Getting connected to QM
MQQueueManager qmgr = new MQQueueManager(QM ) ;
// Getting message out of Queue
int openOptionsForGet = MQC.MQOO_INPUT_SHARED ;
MQQueue OutQueue = qmgr.accessQueue(QUEUE,openOptionsForGet, null, null, null);
MQGetMessageOptions gmo = new MQGetMessageOptions() ;
MQMessage outMessage = new MQMessage();
gmo.matchOptions = MQC.MQMO_MATCH_MSG_ID;
OutQueue.get(outMessage, gmo);
// Getting the XML message into "msgTxt" variable of type string
String msgTxt = outMessage.readString(outMessage.getMessageLength());
System.out.println (" The message is \n" + msgTxt);
// Sending the XML message as argument to MessageParser Program to get parsed
MessageParser msgParser=new MessageParser(msgTxt);
// Creating a new object for SendMail Class
SendMail sMail= new SendMail();
// Sending the parsed values to SendMail program as arguments
sMail.sendMail(msgParser.getAllDetails());
// Closing and disconnecting Queue and Queue Manager
OutQueue.close();
qmgr.disconnect() ;
|
|
|
Back to top |
|
 |
|