Author |
Message
|
mvs |
Posted: Sat Dec 29, 2007 12:45 pm Post subject: Message Flow names using JavaCompute Node |
|
|
Voyager
Joined: 06 Jul 2007 Posts: 85
|
Hi All,
I am using JavaCompute Node to get names of the message Flow under particular execution group.
I am using ConfigurationManagerProxy package.
my JCN code looks like below
Code: |
----------------------------------------
import com.ibm.broker.javacompute.MbJavaComputeNode;
import com.ibm.broker.plugin.*;
import com.ibm.broker.config.proxy.*;
import java.util.ArrayList;
import java.util.ListIterator;
import java.util.jar.*;
import java.util.Enumeration;
import java.util.Iterator;
/*
* Created on 2007/12/28
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
/**
* @author VZM1203
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class ListFlows extends MbJavaComputeNode {
public void evaluate(MbMessageAssembly contact admin) throws MbException {
MbOutputTerminal out = getOutputTerminal("out");
MbOutputTerminal alt = getOutputTerminal("alternate");
MbMessage inMessage = contact admin.getMessage();
// create new message
MbMessage outMessage = new MbMessage();
MbMessageAssembly outAssembly = new MbMessageAssembly(contact admin,
outMessage);
MbMessage message = contact admin.getMessage();
String b = (String) message.evaluateXPath("string(//BrokerName)");
String e = (String) message.evaluateXPath("string(//ExecutionGroupName)");
//String m = (String) message.evaluateXPath("string(//MessageFlowName)");
copyMessageHeaders(inMessage, outMessage);
MQConfigManagerConnectionParameters conParams = new MQConfigManagerConnectionParameters ("lib-mqsi-04",1415,"LMD6NMQI");
try {
// optionally copy message headers
ConfigManagerProxy cmp = ConfigManagerProxy.getInstance(conParams);
TopologyProxy tp = cmp.getTopology();
BrokerProxy bp = tp.getBrokerByName(b);
ExecutionGroupProxy egp = bp.getExecutionGroupByName(e);
Enumeration AllmsgFlows = egp.getMessageFlows(null);
ArrayList L1 = new ArrayList(2);
String a[] = new String[10];
int I = 1;
while (AllmsgFlows.hasMoreElements()){
MessageFlowProxy mp = (MessageFlowProxy) AllmsgFlows.nextElement();
L1.add(mp);
a[I] = mp.toString();
I = I+1;
}
cmp.disconnect();
MbElement outRoot = outMessage.getRootElement();
MbElement outBody = outRoot.getLastChild().getFirstChild();
MbElement messageB = outBody.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,"MESSAGE_BODY","TESTING");
messageB.createElementAsLastChild(MbElement.TYPE_VALUE,null,"First");
Iterator N = L1.iterator();
int K =1;
while(K<I){
messageB.createElementAsLastChild(MbElement.TYPE_VALUE,null,a[K]);
K = K + 1;
}
/* while(N.hasNext()){
String MFN = N.toString();
messageB.createElementAsLastChild(MbElement.TYPE_VALUE,null,MFN);
}
*/
// ----------------------------------------------------------
// Add user code below
// End of user code
// ----------------------------------------------------------
// The following should only be changed
// if not propagating message to the 'out' terminal
out.propagate(outAssembly);
} catch (ConfigManagerProxyLoggedException e1) {
e1.printStackTrace();
} catch (ConfigManagerProxyPropertyNotInitializedException e1) {
e1.printStackTrace();
}catch (MbException e1){
e1.printStackTrace();
}
}
public void copyMessageHeaders(MbMessage inMessage, MbMessage outMessage)
throws MbException {
MbElement outRoot = outMessage.getRootElement();
// iterate though the headers starting with the first child of the root
// element
MbElement header = inMessage.getRootElement().getFirstChild();
while (header != null && header.getNextSibling() != null) // stop before
// the last
// child
// (body)
{
// copy the header and add it to the out message
outRoot.addAsLastChild(header.copy());
// move along to next header
header = header.getNextSibling();
}
}
}
----------------------------------------
|
I am getting the result with Flow id not the name.
------------------------------
(0x02000000): = 'MessageProcessingNodeType/cc47fbcb-1501-0000-0080-cd5c8cc6ba23'
(0x02000000): = 'MessageProcessingNodeType/db47fbcb-1501-0000-0080-cd5c8cc6ba23'
------------------------------------
is anything i need to change to get names of the flows instead of id's
Regards
mvs |
|
Back to top |
|
 |
jefflowrey |
Posted: Sat Dec 29, 2007 6:09 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
...
Why are you trying to use CMP from inside a Broker flow? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
fjb_saper |
Posted: Sat Dec 29, 2007 6:16 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
jefflowrey wrote: |
...
Why are you trying to use CMP from inside a Broker flow? |
He did not say but I suspect he would like to either issue a start flow (for a different flow) or a stop flow command...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
mvs |
Posted: Sun Dec 30, 2007 12:41 am Post subject: Message Flow names using JavaCompute node |
|
|
Voyager
Joined: 06 Jul 2007 Posts: 85
|
Yes, I am using this for stop and start the flow. I checked in the CMP document and given some examples.
I am not sure is there any other way to do that (to get the status/names of the message flows and execution groups in the broker without using CMP).
I did the stop/start flows using timoutControl and TimeoutNotification node.
This project is mainly to display the status of the flows to the user and if he wants to start/stop the flow, he can do that. for this we are using JSP as front end.
Please help me in this |
|
Back to top |
|
 |
jefflowrey |
Posted: Sun Dec 30, 2007 3:13 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
|
Back to top |
|
 |
fjb_saper |
Posted: Sun Dec 30, 2007 7:23 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
And BTW you should not hard code the config manager's connection parms but make them deployable properties so that you don't have to change the flow between dev and prod when you change configmgr.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
mvs |
Posted: Wed Jan 02, 2008 1:16 am Post subject: |
|
|
Voyager
Joined: 06 Jul 2007 Posts: 85
|
Thanks Jeff and Saper.
Now am able to get the names of the flows.
I changed my JCN code to like below
Code: |
while (AllmsgFlows.hasMoreElements()){
MessageFlowProxy mp1 = (MessageFlowProxy) AllmsgFlows.nextElement();
String mp = mp1.getName();
L1.add(mp);
a[I] = mp.toString();
I = I+1;
}
|
Thanks and Regards
MVS |
|
Back to top |
|
 |
|