cancel
Showing results for 
Search instead for 
Did you mean: 

Receiver system by message size

former_member190293
Active Contributor
0 Kudos

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?

Accepted Solutions (1)

Accepted Solutions (1)

iaki_vila
Active Contributor
0 Kudos

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.

former_member190293
Active Contributor
0 Kudos

Hi Inaki!

Thanks for your answer! I've just thought about it 🙂

vadimklimov
Active Contributor
0 Kudos

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

former_member190293
Active Contributor
0 Kudos

Hi Vadim!

Thanks for your answer. I'll try that.

By the way, can I use message.getMainPayload().getContent() in pure java mapping?

This will return byte array and its length will be payload size. Am I right?

vadimklimov
Active Contributor
0 Kudos

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

engswee
Active Contributor
0 Kudos

Nice one Vadim, this is a very clever approach - definitely out-of-the-box thinking

vadimklimov
Active Contributor
0 Kudos

Thank you, Eng Swee, for your positive feedback and encouragement!

Was trying to suggest an option with maximum reusability of standard functionality, with minor custom development efforts.

Regards,

Vadim

former_member190293
Active Contributor
0 Kudos

Thank you very much for your help, Vadim!

Regards, Eugene

vadimklimov
Active Contributor
0 Kudos

You are welcome, Evgeniy. Glad if that solution helped and fulfilled your requirements.

Regards,

Vadim

Answers (0)