Author |
Message
|
DevNYC1 |
Posted: Tue Apr 25, 2017 7:13 am Post subject: Best way to discard messages in Java Compute Node post parse |
|
|
Apprentice
Joined: 22 Aug 2012 Posts: 32
|
So my JCN is reading and parsing XML messages off the queue.
Only about 10% of the messages are the ones I care about. Once I parse a certain ID element of each message with XPath I know whether this is the message I need to process further, or just ignore and move to the next message.
In terms of numbers, about 27K messages hit that queue, and I am interested in about 2.5K messages that I further process.
Question: what is the best way from design/Good Practices point of view to discard the messages I don't need to take any further action on?
Seems that I can just add a return statement in my evaluate() once I know that this message can be discard. Since my MQInput is not transactional, that message will be discarded by default.
Is that the right way, though?
Let's assume I don't need to store, back up/archive these messages I am about to discard. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Apr 25, 2017 7:42 am Post subject: Re: Best way to discard messages in Java Compute Node post p |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
DevNYC1 wrote: |
So my JCN is reading and parsing XML messages off the queue. |
I do hope you don't mean you're parsing the XML with a JCN; rather, that you're examining the message tree produced by the in-built parser associated with the very expensive IBM software you're using.
If you just want to parse XML with Java, you can do it in WAS for a fraction of the price.....
DevNYC1 wrote: |
Seems that I can just add a return statement in my evaluate() once I know that this message can be discard. Since my MQInput is not transactional, that message will be discarded by default.
Is that the right way, though? |
Why wouldn't it be? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
zpat |
Posted: Tue Apr 25, 2017 7:42 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Are you using a MQGET node to read the queue?
How do you "move to the next message"?
If you are terminating the message transaction without reaching an output node for unwanted messages - that should work fine if transaction mode is NO. _________________ Well, I don't think there is any question about it. It can only be attributable to human error. This sort of thing has cropped up before, and it has always been due to human error. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Apr 25, 2017 7:47 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
zpat wrote: |
Are you using a MQGET node to read the queue? |
We can, I think, assume this is not the case based on the OP's reference to an MQInput node. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
DevNYC1 |
Posted: Tue Apr 25, 2017 9:15 am Post subject: |
|
|
Apprentice
Joined: 22 Aug 2012 Posts: 32
|
Let me provide some additional details about this flow.
MQInput node ---> JNC ---> MQOutput
MQInput node's catch is connected to the Error Flow (logs/captures errors)
MQInput's Domain is set to XMLNCS
Inside JCN I do the usual XML XPath parsing:
Code: |
MbElement body = root.getLastChild();
...
String msgIdValue = body.getFirstElementByPath(expressionPath).getValueAsString();
.... check if this is the message we need
..... here various logic, calls to some existing Java APIs, database calls, etc.
out.propagate(outAssembly);
|
|
|
Back to top |
|
 |
DevNYC1 |
Posted: Tue Apr 25, 2017 9:18 am Post subject: Re: Best way to discard messages in Java Compute Node post p |
|
|
Apprentice
Joined: 22 Aug 2012 Posts: 32
|
Vitor wrote: |
If you just want to parse XML with Java, you can do it in WAS for a fraction of the price..... |
Perhaps. But I work in a large enterprise, and this flow includes calls to a bunch of Java libraries and APIs and is running in the message broker env maintained by another enterprise team. In a large company it takes time to build the non-PROD and prod environments, DR regions, replication, etc. I need to make a change to the existing flow that includes JCN, so this is what I need to deal with.
Will pay close attention to performance for sure. The cost of software is not something I need to worry about in this case. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Apr 25, 2017 9:22 am Post subject: Re: Best way to discard messages in Java Compute Node post p |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
DevNYC1 wrote: |
Vitor wrote: |
If you just want to parse XML with Java, you can do it in WAS for a fraction of the price..... |
Perhaps. But I work in a large enterprise, and this flow includes calls to a bunch of Java libraries and APIs and is running in the message broker env maintained by another enterprise team. In a large company it takes time to build the non-PROD and prod environments, DR regions, replication, etc. I need to make a change to the existing flow that includes JCN, so this is what I need to deal with.
Will pay close attention to performance for sure. The cost of software is not something I need to worry about in this case. |
I was more concerned that you were using BLOB in the MQInput node and parsing within the JCN. I'm less concerned about navigating the message tree with XPath. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Apr 25, 2017 9:25 am Post subject: Re: Best way to discard messages in Java Compute Node post p |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
DevNYC1 wrote: |
I work in a large enterprise, and this flow includes calls to a bunch of Java libraries and APIs and is running in the message broker env maintained by another enterprise team. |
So do I.
DevNYC1 wrote: |
In a large company it takes time to build the non-PROD and prod environments, DR regions, replication, etc. |
Not in these enlightened days, and I bet a large organization not only has a build procedure, it also has an existing WAS estate.
DevNYC1 wrote: |
I need to make a change to the existing flow that includes JCN, so this is what I need to deal with. |
Which is fair. I was (if only for the benefit of future readers) ensuring that using an XML parser on an input stream within a JCN was highlighted as a bad move. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|