How do I capture the messages on the fly in IIB?

IBM has provided lot of ways to capture the messages flowing through our message flows. In this post, we are going to discuss about one of them and it is also one of the most unnoticed.

IIB allows you to capture the messages by enabling monitoring profile or by writing custom subflows or using trace nodes.

The most frequently used one is subflows and now a days people use monitoring profile too a lot. There are companies which do not have logs at all ( don’t know how they survive).

Have you ever used Record & Replay? If not, just google to get some basic idea on how that works.

This post is also utilizing the same Record & Replay concept but it does on the fly. I do not have any database setup to store the messages permanently. Just going with built-in capacity of the Integration node.

Let me put here the sequence of steps to achieve this

  1. Enable recording
  2. Enable Injection
  3. Retrieve Recorded Message

Let me put here the Java APIs used here

public void enableRecording(ExecutionGroupProxy proxy, boolean status) throws ConfigManagerProxyLoggedException, ConfigManagerProxyPropertyNotInitializedException {
		
		if (status) {
			proxy.setTestRecordMode(AttributeConstants.MODE_ENABLED);
		}else {
			// clear recorded data and reset server to turn off recording and injection
			proxy.clearRecordedTestData();
			proxy.setTestRecordMode(AttributeConstants.MODE_DISABLED);
		}
		
		enableInjection(proxy, status);
	}
	
	public void enableInjection(ExecutionGroupProxy proxy, boolean status) throws ConfigManagerProxyLoggedException, ConfigManagerProxyPropertyNotInitializedException {
		
		if (status) {
			proxy.setInjectionMode(AttributeConstants.MODE_ENABLED);
		}else {
			// clear recorded data and reset server to turn off recording and injection
			proxy.setInjectionMode(AttributeConstants.MODE_DISABLED);
		}
	}
public List<RecordedTestData> retreiveRecordedMessage(MessageFlowProxy mf) throws ConfigManagerProxyPropertyNotInitializedException, ConfigManagerProxyLoggedException {
		
		Properties filterProps = new Properties();
		String name = getApplication(mf).getName();
//		System.out.println(name);
		if (name != null) {
			filterProps.setProperty(Checkpoint.PROPERTY_APPLICATION_NAME,name);
		}else {
			name = getLibraryProxy(mf).getName();
			if (name != null) {
				filterProps.setProperty(Checkpoint.PROPERTY_LIBRARY_NAME,name);
			}
		}
//		System.out.println(mf.getName());
		filterProps.setProperty(Checkpoint.PROPERTY_MESSAGE_FLOW_NAME,mf.getName());
		
//		ExecutionGroupProxy egProxy = mf.getExecutionGroup();
//		List<RecordedTestData> dataList = egProxy.getRecordedTestData(filterProps);
		
		return mf.getExecutionGroup().getRecordedTestData(filterProps);
	}

That’s it. Once you enable recording, the message flow automatically turns into like this

The recorded message is here (I’ve a UI to make this easier to read)

Here is the local environment message

<localEnvironment xmlns:iib="http://com.ibm.iib/lt/1.0" iib:parser="MQROOT" iib:injectable="true">
   <MQTT>
      <Input>
         <Retained iib:valueType="BOOLEAN">FALSE</Retained>
         <QualityOfService iib:valueType="INTEGER">0</QualityOfService>
         <Topic iib:valueType="CHARACTER">IBM/IntegrationBus/default/Monitoring/Hello</Topic>
         <Duplicate iib:valueType="BOOLEAN">FALSE</Duplicate>
      </Input>
   </MQTT>
</localEnvironment>

And here is the payload

<message xmlns:iib="http://com.ibm.iib/lt/1.0" iib:parser="GENERICROOT" iib:injectable="true">
   <Properties iib:parser="GENERICPROPERTYPARSER">
      <MessageSet iib:valueType="CHARACTER" iib:elementType="0x03000000"></MessageSet>
      <MessageType iib:valueType="CHARACTER" iib:elementType="0x03000000"></MessageType>
      <MessageFormat iib:valueType="CHARACTER" iib:elementType="0x03000000"></MessageFormat>
      <Encoding iib:valueType="INTEGER">546</Encoding>
      <CodedCharSetId iib:valueType="INTEGER">5348</CodedCharSetId>
      <Transactional iib:valueType="BOOLEAN">TRUE</Transactional>
      <Persistence iib:valueType="BOOLEAN">FALSE</Persistence>
      <CreationTime iib:valueType="GMTTIMESTAMP">2021-04-13 16:54:58.451</CreationTime>
      <ExpirationTime iib:valueType="INTEGER">-1</ExpirationTime>
      <Priority iib:valueType="INTEGER">0</Priority>
      <ReplyIdentifier iib:valueType="BLOB"></ReplyIdentifier>
      <ReplyProtocol iib:valueType="CHARACTER">UNKNOWN</ReplyProtocol>
      <Topic iib:elementType="0x03000000"/>
      <ContentType iib:valueType="CHARACTER" iib:elementType="0x03000000"></ContentType>
      <IdentitySourceType iib:valueType="CHARACTER" iib:elementType="0x03000000"></IdentitySourceType>
      <IdentitySourceToken iib:valueType="CHARACTER" iib:elementType="0x03000000"></IdentitySourceToken>
      <IdentitySourcePassword iib:valueType="CHARACTER" iib:elementType="0x03000000"></IdentitySourcePassword>
      <IdentitySourceIssuedBy iib:valueType="CHARACTER" iib:elementType="0x03000000"></IdentitySourceIssuedBy>
      <IdentityMappedType iib:valueType="CHARACTER" iib:elementType="0x03000000"></IdentityMappedType>
      <IdentityMappedToken iib:valueType="CHARACTER" iib:elementType="0x03000000"></IdentityMappedToken>
      <IdentityMappedPassword iib:valueType="CHARACTER" iib:elementType="0x03000000"></IdentityMappedPassword>
      <IdentityMappedIssuedBy iib:valueType="CHARACTER" iib:elementType="0x03000000"></IdentityMappedIssuedBy>
   </Properties>
   <XMLNSC iib:parser="xmlnsc">
      <wmb:event xmlns:wmb="http://www.ibm.com/xmlns/prod/websphere/messagebroker/6.1.0/monitoring/event">
         <wmb:eventPointData>
            <wmb:eventData>
               <wmb:productVersion iib:valueType="CHARACTER" iib:elementType="0x03000100">100011</wmb:productVersion>
               <wmb:eventSchemaVersion iib:valueType="CHARACTER" iib:elementType="0x03000100">6.1.0.3</wmb:eventSchemaVersion>
               <wmb:eventSourceAddress iib:valueType="CHARACTER" iib:elementType="0x03000100">MQ Input.transaction.Start</wmb:eventSourceAddress>
               <wmb:eventIdentity>
                  <wmb:eventName iib:valueType="CHARACTER" iib:elementType="0x03000100">OrderReceived</wmb:eventName>
               </wmb:eventIdentity>
               <wmb:eventSequence>
                  <wmb:creationTime iib:valueType="CHARACTER" iib:elementType="0x03000100">2020-06-01T02:02:32.402892Z</wmb:creationTime>
                  <wmb:counter iib:valueType="CHARACTER" iib:elementType="0x03000100">1</wmb:counter>
               </wmb:eventSequence>
               <wmb:eventCorrelation>
                  <wmb:localTransactionId iib:valueType="CHARACTER" iib:elementType="0x03000100">f8a1af6d-013b-4420-9c1b-baf23d5e10a4-5</wmb:localTransactionId>
                  <wmb:parentTransactionId iib:valueType="CHARACTER" iib:elementType="0x03000100"></wmb:parentTransactionId>
                  <wmb:globalTransactionId iib:valueType="CHARACTER" iib:elementType="0x03000100"></wmb:globalTransactionId>
               </wmb:eventCorrelation>
            </wmb:eventData>
            <wmb:messageFlowData>
               <wmb:broker>
                  <wmb:name iib:valueType="CHARACTER" iib:elementType="0x03000100">IB10NODE</wmb:name>
                  <wmb:UUID iib:valueType="CHARACTER" iib:elementType="0x03000100">b7d2e6dd-0b36-4728-9015-818133dbeb14</wmb:UUID>
               </wmb:broker>
               <wmb:executionGroup>
                  <wmb:name iib:valueType="CHARACTER" iib:elementType="0x03000100">default</wmb:name>
                  <wmb:UUID iib:valueType="CHARACTER" iib:elementType="0x03000100">61704de3-b47c-4b23-b95f-0ffd934fdcb1</wmb:UUID>
               </wmb:executionGroup>
               <wmb:messageFlow>
                  <wmb:uniqueFlowName iib:valueType="CHARACTER" iib:elementType="0x03000100">IB10NODE.default.TestMon.TestMon</wmb:uniqueFlowName>
                  <wmb:name iib:valueType="CHARACTER" iib:elementType="0x03000100">TestMon</wmb:name>
                  <wmb:UUID iib:valueType="CHARACTER" iib:elementType="0x03000100">429ff9ef-1c8d-48c1-bf42-99ac3bd247fb</wmb:UUID>
                  <wmb:threadId iib:valueType="CHARACTER" iib:elementType="0x03000100">21980</wmb:threadId>
               </wmb:messageFlow>
               <wmb:node>
                  <wmb:nodeLabel iib:valueType="CHARACTER" iib:elementType="0x03000100">MQ Input</wmb:nodeLabel>
                  <wmb:nodeType iib:valueType="CHARACTER" iib:elementType="0x03000100">ComIbmMQInputNode</wmb:nodeType>
                  <wmb:detail iib:valueType="CHARACTER" iib:elementType="0x03000100">IN.Q</wmb:detail>
               </wmb:node>
            </wmb:messageFlowData>
         </wmb:eventPointData>
         <wmb:applicationData xmlns="">
            <wmb:complexContent>
               <wmb:elementName iib:valueType="CHARACTER" iib:elementType="0x03000100">MQMD</wmb:elementName>
               <MQMD>
                  <SourceQueue iib:valueType="CHARACTER">IN.Q</SourceQueue>
                  <Transactional iib:valueType="CHARACTER">true</Transactional>
                  <Encoding iib:valueType="CHARACTER">273</Encoding>
                  <CodedCharSetId iib:valueType="CHARACTER">1208</CodedCharSetId>
                  <Format iib:valueType="CHARACTER">MQSTR   </Format>
                  <Version iib:valueType="CHARACTER">2</Version>
                  <Report iib:valueType="CHARACTER">0</Report>
                  <MsgType iib:valueType="CHARACTER">8</MsgType>
                  <Expiry iib:valueType="CHARACTER">-1</Expiry>
                  <Feedback iib:valueType="CHARACTER">0</Feedback>
                  <Priority iib:valueType="CHARACTER">0</Priority>
                  <Persistence iib:valueType="CHARACTER">0</Persistence>
                  <MsgId iib:valueType="CHARACTER">414d5120494942763130514d475220204064d15e10000105</MsgId>
                  <CorrelId iib:valueType="CHARACTER">000000000000000000000000000000000000000000000000</CorrelId>
                  <BackoutCount iib:valueType="CHARACTER">0</BackoutCount>
                  <ReplyToQ iib:valueType="CHARACTER">                                                </ReplyToQ>
                  <ReplyToQMgr iib:valueType="CHARACTER">IIBv10QMGR                                      </ReplyToQMgr>
                  <UserIdentifier iib:valueType="CHARACTER">vaithu      </UserIdentifier>
                  <AccountingToken iib:valueType="CHARACTER">160105150000002d74cc5dfa721e73431607412b32030000000000000000000b</AccountingToken>
                  <ApplIdentityData iib:valueType="CHARACTER">                                </ApplIdentityData>
                  <PutApplType iib:valueType="CHARACTER">28</PutApplType>
                  <PutApplName iib:valueType="CHARACTER">vaithu</PutApplName>
                  <PutDate iib:valueType="CHARACTER">2020-06-01</PutDate>
                  <PutTime iib:valueType="CHARACTER">02:02:32.480</PutTime>
                  <ApplOriginData iib:valueType="CHARACTER">    </ApplOriginData>
                  <GroupId iib:valueType="CHARACTER">000000000000000000000000000000000000000000000000</GroupId>
                  <MsgSeqNumber iib:valueType="CHARACTER">1</MsgSeqNumber>
                  <Offset iib:valueType="CHARACTER">0</Offset>
                  <MsgFlags iib:valueType="CHARACTER">0</MsgFlags>
                  <OriginalLength iib:valueType="CHARACTER">-1</OriginalLength>
               </MQMD>
            </wmb:complexContent>
         </wmb:applicationData>
         <wmb:bitstreamData>
            <wmb:bitstream iib:valueType="CHARACTER">TUQgIAIAAAAAAAAACAAAAP////8AAAAAEQEAALgEAABNUVNUUiAgIAAAAAAAAAAAQU1RIElJQnYxMFFNR1IgIEBk0V4QAAEFAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIElJQnYxMFFNR1IgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN4cDI2NyAgICAgIBYBBRUAAAAtdMxd+nIec0MWB0ErMgMAAAAAAAAAAAALICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAcAAAAZ21haWwuc3Jpbml2YXNhLkFwcGxpY2F0aW9uIDIwMjAwNjAxMDIwMjMyNDggICAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAA/////zxPcmRlcnM+CiAgIDxPcmRlcj4KICAgICAgPEN1c3RvbWVySUQ+R1JFQUw8L0N1c3RvbWVySUQ+CiAgICAgIDxFbXBsb3llZUlEPjY8L0VtcGxveWVlSUQ+CiAgICAgIDxPcmRlckRhdGU+MTk5Ny0wNS0wNlQwMDowMDowMDwvT3JkZXJEYXRlPgogICAgICA8UmVxdWlyZWREYXRlPjE5OTctMDUtMjBUMDA6MDA6MDA8L1JlcXVpcmVkRGF0ZT4KICAgICAgPFNoaXBJbmZvIFNoaXBwZWREYXRlPSIxOTk3LTA1LTA5VDAwOjAwOjAwIj4KICAgICAgICAgPFNoaXBWaWE+MjwvU2hpcFZpYT4KICAgICAgICAgPEZyZWlnaHQ+My4zNTwvRnJlaWdodD4KICAgICAgICAgPFNoaXBOYW1lPkdyZWF0IExha2VzIEZvb2QgTWFya2V0PC9TaGlwTmFtZT4KICAgICAgICAgPFNoaXBBZGRyZXNzPjI3MzIgQmFrZXIgQmx2ZC48L1NoaXBBZGRyZXNzPgogICAgICAgICA8U2hpcENpdHk+RXVnZW5lPC9TaGlwQ2l0eT4KICAgICAgICAgPFNoaXBSZWdpb24+T1I8L1NoaXBSZWdpb24+CiAgICAgICAgIDxTaGlwUG9zdGFsQ29kZT45NzQwMzwvU2hpcFBvc3RhbENvZGU+CiAgICAgICAgIDxTaGlwQ291bnRyeT5VU0E8L1NoaXBDb3VudHJ5PgogICAgICA8L1NoaXBJbmZvPgogICA8L09yZGVyPgo8L09yZGVycz4=<wmb:encoding iib:valueType="CHARACTER" iib:elementType="0x03000100">base64Binary</wmb:encoding>
            </wmb:bitstream>
         </wmb:bitstreamData>
      </wmb:event>
   </XMLNSC>
</message>

By this way, if you’ve a need to immediately see what is flowing through your messages, simply implement this solution and see the messages on the fly. Once done, clear up the recordings.

If you’re interested to know more about this solution, feel free to contact us at support@vaithu.com. WhatsApp +1 6123058684.

One thought on “How do I capture the messages on the fly in IIB?

  • April 29, 2021 at 1:08 pm
    Permalink

    “..Activate service trace only when you receive an error message that instructs you to or when directed to do so by your IBM Support Center..” Which tells the IIB runtime to trace the message flow MF_PJB_SOAP that resides in the application AP_PJB_SOAP. If we ran the command omitting the -k AP_PJB_SOAP then the command will fail because it would not find MF_PJB_SOAP residing outside of an application or library. Specifying the -f flag without the -k or -y flags is there to allow debugging of message flows that were deployed outside of applications and libraries.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.