on 04-27-2016 11:53 AM
Hi!
I have scenario with SOAP sender system and two receiver systems. Receiver system must be choosen by condition based on XI message size. (e.g. up to 100 MB - system A, else - system B).
Advise, please, how can I get message size?
Hi Evgeny,
Just one idea.
1. Do a java mapping to determine the size of the inputstream (Size of an InputStream (Java in General forum at Coderanch)). Store the size in a global variable or in a payload tag.
2. Second mapping to determine the receiver depending the last variable: Dynamic receiver determination through mapping - Process Integration - SCN Wiki
3. Third mapping to eliminate the new tag if you don't use a global variable.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Evgeniy, Iñaki,
As a derivative from the solution provided by Iñaki, we can simplify used mappings by introducing only one graphical mapping for extended receiver determination and using variable and a user defined function to retrieve message size.
Here is a sample mapping for extended receiver determination - note a variable SrcMsgSize that was introduced:
Root element of a source message is mapped here - note that we set to "Return as XML" for it so that we actually calculate size of the whole underlying XML message (otherwise, we end up with calculating size of a root element, which is not of any help here and will return zero):
Finally, here is an example of a user defined function that was used in a mapping rule above, to find out size of a message based on calculation of bytes array of corresponding XML document:
As a result, we don't need to adopt any message types and we get calculated message size stored in a (temporary dynamic) variable, which we can further use in mapping rules for Receiver and underlying elements in extended receiver determination mapping to figure out which receiver(s) shall be determined for that particular message.
I should make a remark here that determination of a message size is based on calculation of message's XML payload size, not the complete SOAP message that is sent by a sender system, so better to check if that fits your original requirements.
Regards,
Vadim
Evgeniy, if you implement a Java mapping program, then in the method transform(), you get input parameter of type TransformationInput, that you can use to convert it to InputStream:
TransformationInput.getInputPayload().getInputStream()
Then you can get byte array from there.
For example, assuming the TransformationInput variable named in is used in a mapping program, then you can obtain byte array into variable msgBytes for it using code similar to:
InputStream is = in.getInputPayload().getInputStream();
byte[] msgBytes = new byte[is.available()];
is.read(msgBytes);
Regards,
Vadim
User | Count |
---|---|
78 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.