ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Set DestinationData.queueName using Java

Post new topic  Reply to topic
 Set DestinationData.queueName using Java « View previous topic :: View next topic » 
Author Message
elaforc
PostPosted: Fri Dec 04, 2009 7:55 am    Post subject: Set DestinationData.queueName using Java Reply with quote

Novice

Joined: 29 Sep 2009
Posts: 10

I am in the process of converting my companies message flows from ESQL to Java (some of you have seen my posts before I am sure). Currently I am working on one that does some very simple routing based on the message contents.

Right now I have an issue simply propagating a message to a dynamically set queue name. The ESQL code looks like:

Code:

SET OutputQueue = 'WMQI.MWMS.WMS.INTF.AL';
SET OutputLocalEnvironment.Destination.MQ.DestinationData[1].queueName = OutputQueue;


Pretty basic, now I cannot get the Java equivalent to work. The error I am seeing is :

Code:

BIP2623E: Unable to open queue '' on WebSphere MQ queue manager '': completion code 2; reason code 2085.


I have tried the following two scenarios, but they throw the same error.

Code:

MbMessage outLocalEnv = new MbMessage(assembly.getLocalEnvironment());
MbElement oLE = outLocalEnv.getRootElement();
MbMessageAssembly outAssembly = new MbMessageAssembly(assembly,
outLocalEnv, assembly.getExceptionList(), assembly.getMessage());
oLE.evaluateXPath("?Destination/?MQ/?DestinationData/?^queueName[set-value('" + "DRM.DRM.TEST.QL" +"')]");
out.propagate(outAssembly);


and

Code:

MbMessage outLocalEnv = new MbMessage(assembly.getLocalEnvironment());
MbElement oLE = outLocalEnv.getRootElement();
MbMessageAssembly outAssembly = new MbMessageAssembly(assembly,
outLocalEnv, assembly.getExceptionList(), assembly.getMessage());
MbElement queueName = (MbElement)((List)oLE.evaluateXPath("?Destination/?MQ/?DestinationData/?queueName")).get(0);
queueName.setValue(("DRM.DRM.TEST.QL"));
out.propagate(outAssembly);


Thanks for any advice or suggestions.
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Dec 04, 2009 8:15 am    Post subject: Re: Set DestinationData.queueName using Java Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

elaforc wrote:
I am in the process of converting my companies message flows from ESQL to Java


Somewhat off topic, and I apologise for having nothing relevant to add (you wouldn't want Java advice from me!) but what's the driver here for the conversion? There have been a number of discussions in here on the use of Java v ESQL (and I'm not keen to reignite the listing of pros & cons) but wondering what decided your site one way or the other?

Given that you (presumably) have a developed base of ESQL and (presumably) people to maintain it, why move to Java?

Again, apologies for the lack of actual advice.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
elaforc
PostPosted: Fri Dec 04, 2009 8:25 am    Post subject: Reply with quote

Novice

Joined: 29 Sep 2009
Posts: 10

My managers feel that Java will be an easier language to maintain over time and have decided it is for the best.

I did not actually develop this code base (but my predecessor did) so I am not familiar with all pros and cons of using one language versus the other. The only thing I have noticed is that ESQL has a lot more community documentation and there is a bit of a lack on the Java side (which makes sense).

I am not however in a position right now to push to keep the ESQL, sometimes you just have to keep your head down and move on.

Thanks for your concern, but as of now I will continue down the Java path.
Back to top
View user's profile Send private message
Vitor
PostPosted: Fri Dec 04, 2009 8:34 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

elaforc wrote:
Thanks for your concern, but as of now I will continue down the Java path.


Expressing concern was not my intent, and I apologise if I gave that impression. I was moved entirely by an interest in which of the points in the ESQL v Java debate had convinced you.

You do indeed sometimes have to shrug and move on. In my case, having had the decision (and my invoice) signed off! The customer is always right, even if the customer is barking mad.

To touch briefly on your other points, there is more discussion on ESQL because ESQL has been in WMB much longer than Java. ESQL runs in a smaller footprint (you don't need a JVM) and is generally held to run faster. I'm told by people I trust that you can do more, or the same in fewer lines of code, in ESQL than you can in Java but don't know myself.

The decision that Java will be easier (management code for cheaper) to maintain is one of the common ones. You're not alone.

I'm sure a more skilled person will be along in a minute with some actual advice.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Dec 04, 2009 3:14 pm    Post subject: Re: Set DestinationData.queueName using Java Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

elaforc wrote:
I am in the process of converting my companies message flows from ESQL to Java

Right now I have an issue simply propagating a message to a dynamically set queue name. The ESQL code looks like:

Code:

SET OutputQueue = 'WMQI.MWMS.WMS.INTF.AL';
SET OutputLocalEnvironment.Destination.MQ.DestinationData[1].queueName = OutputQueue;


Pretty basic, now I cannot get the Java equivalent to work. The error I am seeing is :

Code:

BIP2623E: Unable to open queue '' on WebSphere MQ queue manager '': completion code 2; reason code 2085.


I have tried the following two scenarios, but they throw the same error.

Code:

MbMessage outLocalEnv = new MbMessage(assembly.getLocalEnvironment());
MbElement oLE = outLocalEnv.getRootElement();
MbMessageAssembly outAssembly = new MbMessageAssembly(assembly,
outLocalEnv, assembly.getExceptionList(), assembly.getMessage());
oLE.evaluateXPath("?Destination/?MQ/?DestinationData/?^queueName[set-value('" + "DRM.DRM.TEST.QL" +"')]");
out.propagate(outAssembly);


and

Code:

MbMessage outLocalEnv = new MbMessage(assembly.getLocalEnvironment());
MbElement oLE = outLocalEnv.getRootElement();
MbMessageAssembly outAssembly = new MbMessageAssembly(assembly,
outLocalEnv, assembly.getExceptionList(), assembly.getMessage());
MbElement queueName = (MbElement)((List)oLE.evaluateXPath("?Destination/?MQ/?DestinationData/?queueName")).get(0);
queueName.setValue(("DRM.DRM.TEST.QL"));
out.propagate(outAssembly);


Thanks for any advice or suggestions.

Well I have no idea how you thought you were going to set the equivalent of
Code:

SET OutputQueue = 'WMQI.MWMS.WMS.INTF.AL';
SET OutputLocalEnvironment.Destination.MQ.DestinationData[1].queueName = OutputQueue;

because your java code certainly shows no inclination of you doing that...

First of all you may have the root of OutputLocalEnvironment, but there is no inclination that the rest of the path exists... so evaluate XPATH is no good there.

Best thing would be to check for the children and if Destionation then MQ then DestinationData[1] then queueName are not there you need to create them... You might want to just add some kind of a node (trace) between JCN and MQOutput to check that your OutputLocalEnvironment / LocalEnvironment looks like you would expect.

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
elaforc
PostPosted: Mon Dec 07, 2009 5:51 am    Post subject: Re: Set DestinationData.queueName using Java Reply with quote

Novice

Joined: 29 Sep 2009
Posts: 10

fjb_saper wrote:

First of all you may have the root of OutputLocalEnvironment, but there is no inclination that the rest of the path exists... so evaluate XPATH is no good there.


Maybe I am mistaken, but I thought by using the ? before the node name I was creating the child node if it did not exist yet? I am basing this assumption on the following link:

http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/index.jsp?topic=/com.ibm.etools.mft.doc/ac30390_.htm

So by doing

Code:
oLE.evaluateXPath("?Destination/?MQ/?DestinationData/?^queueName[set-value('" + "DRM.DRM.TEST.QL" +"')]");


I was doing the Java equivalent of the ESQL statement

Code:
OutputLocalEnvironment.Destination.MQ.DestinationData[1].queueName = OutputQueue;


regardless of the fact that
Quote:
there is no inclination that the rest of the path exists
Back to top
View user's profile Send private message
elaforc
PostPosted: Mon Dec 07, 2009 1:35 pm    Post subject: Reply with quote

Novice

Joined: 29 Sep 2009
Posts: 10

I determined the solution. There was not an issue with my code, but instead an issue with my MQOutput node configuration. I was reading about the LocalEnviroment struture on

http://publib.boulder.ibm.com/infocenter/wmbhelp/v6r0m0/index.jsp?topic=/com.ibm.etools.mft.doc/ac16870_.htm

and read that

Quote:

You can configure output nodes to examine the list of destinations and send the message to those destinations, by setting the property Destination Mode to Destination List.


Essentially I just forgot to tell the output node to use the DestinationData. So the code below does work as long as you set the MQOuput node DestinationMode property to Destination List.

Code:

localEnv.getRootElement().evaluateXPath("?Destination/?MQ/?DestinationData/?queueName[set-value('WMQI.MWMS.CME.INTF.AL')]");
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Dec 07, 2009 8:26 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Great! Happy you got it to work!
Looking at
Code:
localEnv.getRootElement().evaluateXPath("?Destination/?MQ/?DestinationData/?queueName[set-value('WMQI.MWMS.CME.INTF.AL')]");

It does not look to be quite the equivalent of
SET OutputLocalEnvironment.Destination.MQ.DestinationData[1].queueName = 'WMQI.MWMS.CME.INTF.AL';

Wheras it will correctly create the path if it is not present, how are you going to make sure you get DestinationData[1] ?

I would have expected it to be ?^DestinationData, but according to the doc it will always create it as the first.

?DestinationData will return the DestinationData array if it exists. If it does not it will append DestinationData at that point in the tree.
So if the DestinationData[1] exists how do you make sure you get the first occurrence in the XPath?

See
Quote:
select-or-create::name or ?name
?name is equivalent to select-or-create::name. If name is @name, an attribute is created or selected. This selects child nodes matching the specified name, or creates new nodes according to the following rules:

* ?name selects children called name if they exist. If a child called name does not exist, ?name creates it as the last child, then selects it.
* ?$name creates name as the last child, then selects it.
* ?^name creates name as the first child, then selects it.
* ?>name creates name as the next sibling, then selects it.
* ?<name creates name as the previous sibling, then selects it.



Don't get me wrong. I'm happy it works for you.

This is more to learn about the subtleties of XPath here. ..
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
rekarm01
PostPosted: Tue Dec 08, 2009 2:35 am    Post subject: Re: Set DestinationData.queueName using Java Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

fjb_saper wrote:
Looking at
Code:
localEnv.getRootElement().evaluateXPath("?Destination/?MQ/?DestinationData/?queueName[set-value('WMQI.MWMS.CME.INTF.AL')]");

It does not look to be quite the equivalent of
Code:
SET OutputLocalEnvironment.Destination.MQ.DestinationData[1].queueName = 'WMQI.MWMS.CME.INTF.AL';

Wheras it will correctly create the path if it is not present, how are you going to make sure you get DestinationData[1] ?

?DestinationData will return the DestinationData array if it exists. If it does not it will append DestinationData at that point in the tree.
So if the DestinationData[1] exists how do you make sure you get the first occurrence in the XPath?

The two statements are not equivalent. The XPath statement will set the value of all matching elements; the equivalent ESQL would look something like:
Code:
-- set up loops for w, x, y, z ...
SET OutputLocalEnvironment.Destination[w].MQ[x].DestinationData[y].queueName[z] = 'WMQI.MWMS.CME.INTF.AL';


For ESQL references, each Path element has either an implied subscript, or an explicit one. So these two ESQL statements are the same:
Code:
SET OutputLocalEnvironment.Destination.MQ.DestinationData[1].queueName = 'WMQI.MWMS.CME.INTF.AL';
SET OutputLocalEnvironment.Destination[1].MQ[1].DestinationData[1].queueName[1] = 'WMQI.MWMS.CME.INTF.AL';

... and the equivalent XPath expression looks like:
Code:
localEnv.getRootElement().evaluateXPath("?Destination[1]/?MQ[1]/?DestinationData[1]/?queueName[1][set-value('WMQI.MWMS.CME.INTF.AL')]");
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Dec 08, 2009 2:54 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Thanks rekarm01 for clearing that up for me.
I still learn new things every day...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Set DestinationData.queueName using Java
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.