on 11-05-2019 7:39 PM
Hello Experts,
Requirement is to split message and batch the records(id) with max_count '5'.
For example: from source, 'key' occurs multiple times(say 25 times) and same should be split into 5 different messages with each message holding 5 records(id's). If 'key' is holding 26 ids the 6th message should hold one record extra.
Source:
<messagetype>
<refs/> 1...1
<key/> 0...unbounded
<id/>.... 1.1
Expected target:
<messagetype1>
<refs/> 1...1
<key/> 0...unbounded
<id/><id/><id/><id/><id/>...
Hello,
I used the below user defined function to partition a list containing with partition size of 5 yields i.e. outer list containing 5 records, all in the original order.
UDF:
public void SplitMessage(String[] id, ResultList result, Container container) throws StreamTransformationException{
AbstractTrace trace;
trace = container.getTrace();
int k=0; trace.addWarning("ID Length" + id.length);
for(int i=0;i<id.length;i++)
{
if(k<5)
{
result.addValue(id[i]);
}
else
{
k=0;
result.addContextChange();
result.addValue(id[i]);
}
k++;
}
Thanks - Rajesh PS
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rajesh can you share a sample source and expected target XML ?
is ID a child node of Key?
I think you can do that using Multimapping. But the interface has to be async one.
Thanks
Sugata
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Below is the structure:
screenshot-2019-11-06-at-125918-pm-1.png
Yes 'id' is the child node of 'key' and this is an async scenario wherein I'm carrying out the multimapping and sending to BPM process with split message of batched records.
Thanks and Regards,
Rajesh PS
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.