Author |
Message
|
siva1431202 |
Posted: Mon May 09, 2011 6:35 am Post subject: Use Java to move the tree to a collection |
|
|
Novice
Joined: 04 May 2011 Posts: 20
|
Use Java to move the tree to a collection, sort and move the result back to a tree.Do any one have an idea regarding this?
This i am trying in java compute node..so that it will be easier to sort and to remove duplicate. |
|
Back to top |
|
 |
Vitor |
Posted: Mon May 09, 2011 6:44 am Post subject: Re: Use Java to move the tree to a collection |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
siva1431202 wrote: |
This i am trying in java compute node..so that it will be easier to sort and to remove duplicate. |
Following on from the discussion here presumably? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Mon May 09, 2011 6:45 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
And of course here? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Mon May 09, 2011 6:50 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
As one of my most worth associates commented in an earlier post, the collections object doesn't have methods for a message tree. I would have thought your best bet would be to walk the tree and add the elements, de-duplicate and reassemble them.
Another poster suggested something similar when the talk of a collections object came up. My Java's really insufficient to comment further but I do wonder how this would leave you if you needed to preserve the order of the elements but remove duplicates. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Mon May 09, 2011 7:00 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
The suggestion given was to create a comparator method that understood how to access and evaluate the contents of an MbElement.
The difficulty is that you also might need something to allow the collection sort utility to walk the MbMessage tree.. and another something to allow the collection sort utility to exchange two elements in the message tree.
So the other notion is to walk the message tree and create an array that contains the relative key values and then a pointer to the relevant MbElement object, and then sort that.
Then you could detach/attach the elements in order to the new message.
Or you could do any number of other, more sensible, things. |
|
Back to top |
|
 |
siva1431202 |
Posted: Mon May 09, 2011 9:09 pm Post subject: |
|
|
Novice
Joined: 04 May 2011 Posts: 20
|
Thanks for all the replies i received
we can evaluate the contents of the of an MB element using
(String)inMessage.evaluateXPath("string(/Employee/Emp)");
I am able to put into the collection but based on some field it has to sort...
let us assume msg have three fields - EmpID,EmpFname ,EmpLname ..
Sorting should be based on EmpFname and remove duplicates based on EmpID.
So what is the next step that i can do. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue May 10, 2011 1:17 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
siva1431202 wrote: |
Thanks for all the replies i received
we can evaluate the contents of the of an MB element using
(String)inMessage.evaluateXPath("string(/Employee/Emp)");
I am able to put into the collection but based on some field it has to sort...
let us assume msg have three fields - EmpID,EmpFname ,EmpLname ..
Sorting should be based on EmpFname and remove duplicates based on EmpID.
So what is the next step that i can do. |
Good luck sorting on Fname. Do you consider M., Mik, Mike, Michael, Michel to be equivalent?
Why not sort on ID + Lname + Fname and dedup based on ID?
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
siva1431202 |
Posted: Tue May 10, 2011 4:47 am Post subject: |
|
|
Novice
Joined: 04 May 2011 Posts: 20
|
I will try it later. First i want to continue with one parameter.
I dont know whether which is the easies way. |
|
Back to top |
|
 |
|