|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Misbehaving Java Children |
« View previous topic :: View next topic » |
Author |
Message
|
sarel |
Posted: Tue Oct 09, 2007 11:43 pm Post subject: Misbehaving Java Children |
|
|
Newbie
Joined: 09 Oct 2007 Posts: 2
|
Got (I guess) a newbie problem - addAsLast/FirstChild works only once.
Here's the scenario...
FileInputNode reads 1Gb file (a POC) and processes it record for record
,filters them and (since I don't know any better) detaches the recurring MbElements and pops them on a static Collection
At the end of processing I want to collect them in one bunch and output them as a single XML
I create a new MbXML.ELEMENT in XML, pop the first saved MbElement in with an addAsFirst/LastChild but when adding the second one it bongs out with a ' it already has a parent - dummy ' exception.
Kind of weird since I checked the child and it was and orphan - unattached, no mommy, no daddy...
The error message also doesn't make sense... mentions the 'latter' being attached and indicates the parent as the latter...?
I think I am looking for a Java equivalent for a SHARED ROW of sorts (might be way off though)
Please help - loosing lots of sleep and beertime. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Oct 10, 2007 1:42 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
What's an MbXML.ELEMENT? Also - please don't use the XML domain, use XMLNS or XMLNSC.
A static Collection is the Java equivalent of a SHARED ROW...
Are all your MbElements associated with the same parser? (I guess so) Are they associated with the same parser that the tree you're trying to add them back to is associated with?
Are you working with an editable MbMessage? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
sarel |
Posted: Wed Oct 10, 2007 3:16 am Post subject: |
|
|
Newbie
Joined: 09 Oct 2007 Posts: 2
|
Thanks Jeff
MbXML.ELEMENT is a type - something I saw somewhere used like...
createElementAsFirstChild(MbXML.ELEMENT,"foo",null);
removed it now - trying to add it to MRM directly.
Yes it's a new MbMessage (editable)
To make sure the Message->Properties are the same - I also save that from the original
And the original is MRM - just for 'kicks' I tried XMLNSC and just plain XML - same results.
Adding a break in my loop works great and the resulting MRM child comes out lonely but good looking.
Here's the bit that does the adding and the error (still doesn't make sense that it complains about MRM) that it comes up with.
Running mb 6005 with mbt 602 ifix9 if it matters
-----------------------------------------------------------------------
MbMessage outMessage = new MbMessage();
outMessage.getRootElement().addAsFirstChild(TransactionSingleton.getProperties());
MbElement parser = outMessage.getRootElement().createElementAsLastChild("MRM");
MbElement li = parser;
MbMessage localEnv = new MbMessage(assembly.getLocalEnvironment());
localEnv.getRootElement().getFirstElementByPath("Variables").getFirstElementByPath("MBFEProperties").getFirstElementByPath("FileName").setValue("Out.xml");
localEnv.getRootElement().getFirstElementByPath("Variables").getFirstElementByPath("MBFEProperties").getFirstElementByPath("Encoding").setValue(new Integer(0));
localEnv.getRootElement().getFirstElementByPath("Variables").getFirstElementByPath("MBFEProperties").getFirstElementByPath("CodedCharSetId").setValue(new Integer(0));
Iterator i = TransactionSingleton.getList().iterator();
while (i.hasNext()) {
MbElement transaction = (MbElement) i.next();
li.addAsLastChild(transaction); // second iteration fails here...
// break;
}
MbMessageAssembly outAssembly = new MbMessageAssembly(assembly,localEnv,assembly.getGlobalEnvironment(),assembly.getExceptionList(),outMessage);
out.propagate(outAssembly);
----------------------------------------------------------------------
( BROKER1.default ) Error attaching field ''(0x01000000):transaction'' to field ''(0x01000021):MRM'' which already has a parent.
The message broker attempted to attach the field ''(0x01000000):transaction'' to the field ''(0x01000021):MRM'' but the latter field already has a parent field.
|
|
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
|
|
|
|