javaibm-mqibm-integration-bus

How to parse String to MbMessageAssembly? In Java Compute node IIB


I am quite new to this, and I am struggling with one issue. In Java Compute Node, through IIB, I am checking if one field has one or more values, and for each additional value I am creating a new duplicate message, except for value, these additional values are overriding. This is working fine as a expect, see example:

Input :...

</leg_flight_no><lineNumber>2</lineNumber><shipper_name>BMW AG</shipper_name> <shipper_reference_hu>1111111;22222222;333333333</shipper_reference_hu></root>

Modified message 1:...

</leg_flight_no><lineNumber>2</lineNumber><shipper_name>BMW AG</shipper_name> <shipper_reference_hu>1111111</shipper_reference_hu></root>

Modified message 2:..

</leg_flight_no><lineNumber>2</lineNumber><shipper_name>BMW AG</shipper_name> <shipper_reference_hu>22222222</shipper_reference_hu></root>

Modified message3 :...

</leg_flight_no><lineNumber>2</lineNumber><shipper_name>BMW AG</shipper_name> <shipper_reference_hu>333333333</shipper_reference_hu></root>

But I am struggling to propagate this message out from the Java Compute node. I understand that I cant propagate messages of type String, so I am trying to parse this as a MbMessageAssemble outAssemble. This is my code:

String newMessage = inData.replace(wholeValues, outData); // replace one value with another
                                
MbMessage outMessage = new MbMessage();
MbMessageAssembly outAssembly = new MbMessageAssembly(inAssembly, outMessage);
copyMessageHeaders(inMessage, outMessage);
MbElement outRoot = outMessage.getRootElement();
MbElement outParser = outRoot.createElementAsLastChild(MbBLOB.PARSER_NAME);
MbElement outBodyEl2 = outParser.createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "BLOB", newMessage.getBytes());                                
alt.propagate(outAssembly);

But this is propagate an empty message, so the newMessage is not parsed to outAssembly. Can anybody with this experience help me with this?


Solution

  • I figured it out. For future, here is your answer

    String newMessage = "this is some test";
    MbMessage outMessage=new MbMessage();
    outMessage.getRootElement().createElementAsLastChild(MbBLOB.PARSER_NAME).createElementAsLastChild(MbElement.TYPE_NAME_VALUE, "BLOB", newMessage.getBytes());
    MbMessageAssembly outAssembly = new MbMessageAssembly(inAssembly, outMessage);
    out.propagate(outAssembly);