Correlating an Incoming Transaction Set with an Outgoing Batch
BizTalk Server enables you to correlate an EDI transaction set submitted to the Batching Orchestration with an outgoing batch. You do so by correlating a status reporting entry for the transaction set submitted to the Batching Orchestration (the BTSInterchangeID) to a status reporting entry for the orchestration (ActivityID). This correlation is performed using entries in the BusinessMessageJournal BAM activity. These entries are created by the Batching Orchestration when a batch element is received.
Important
BizTalk Server will make entries in the BusinessMessageJournal activity only if EDI status reporting and Transaction Set tracking is enabled for the agreement.
The sections below describe the following:
How BizTalk Server saves tracking data
How you can create a custom pipeline component to enable correlation
How you can correlate an incoming transaction set with an outgoing batch.
How you can query the BusinessMessageJournal activity to determine the BTSInterchangeID of the batch if you know the BTSInterchangeID of the transaction set contained in the batch.
Prerequisites
You must be logged on as a member of the BizTalk Server Administrators or BizTalk Server B2B Operators group.
Changes to the Activities
The Batching Orchestration makes entries in the BatchingActivity, TransactionSetActivity, and BusinessMessageJournal BAM activities. As a transaction set moves through BizTalk Server, BizTalk Server will make the following entries in these activity tables for the transaction set and the batch that includes it:
When the EDI disassembler processes an incoming EDI interchange, it creates entries in the InterchangeStatusActivity and the TransactionSetActivity tables.
Note
For more information about the BAM activities, see BAM Activities Created to Track EDI-AS2 Messages.
When the Batching Orchestration is instantiated, the orchestration creates an entry in the BatchingActivity. The BAM subsystem creates a value for the ActivityID.
After the batching orchestration has picked up the transaction set, it creates an entry for the transaction set in the TransactionSetActivity table.
The orchestration creates an entry in the BusinessMessageJournal activity. It sets the MessageTrackingID field of this activity to the value of the ActivityID field of the entry that the orchestration created in TransactionSetActivity table. It also sets the BTSInterchangeID field to the BTS.InterchangeID context property for the transaction set and the BTSMessageID field to the BTS.MessageID context property for the transaction set.
The orchestration creates a second entry in the BusinessMessageJournal activity. It sets the MessageTrackingID field to the ActivityID field of the entry that the orchestration created in TransactionSetActivity table. It sets the BTSInterchangeID field to the BTS.InterchangeID context property for the batch. It does not set the BTSMessageID. It sets the ContainerActivityID to the value of the ActivityID in the BatchingActivity.
Creating a Custom Pipeline Component for Enabling Correlation
To set up correlation of an incoming transaction set with an outgoing batch that contains that transaction set, you need to create a custom pipeline component. This pipeline component should come after the EDI Disassembler and before the BatchMarker component of the EDIReceive pipeline. This pipeline component needs to create an entry in the BusinessMessageJournal activity. In this entry, the BTSInterchangeID field should be set to the BTS.InterchangeID context property and the BTSMessageID field should be set to the BTS.MessageID context property.
Looking Up the InterchangeID for a Transaction Set in a Batch
You correlate a received interchange, and the batch that contains the transaction set from the interchange, by using the entries in the BatchingActivity table and the BusinessMessageJournal activity, as described below.
To correlate an incoming transaction set with an outgoing batch that contains that transaction set
Determine the value of ActivityID for the batch in the BatchingActivity table.
Search for the ActivityID value in the ContainerActivityID field of the BusinessMessageJournal activity table.
In the record identified by the ContainerActivityID, look up the value of the MessageTrackingID field, which is associated with the batch.
Using the value of the MessageTrackingID field associated with the batch in the BusinessMessageJournal activity table, search for the same value in the MessageTrackingID field of other records in the BusinessMessageJournal activity table. Any records found are associated with transaction sets in the batch, as recorded by the Batching Orchestration.
In a record associated with a transaction set in the BusinessMessageJournal activity table, look up the value of the BTSInterchangeID field.
Using the value of the BTSInterchangeID, you can look up a record for the transaction set that was created in the BusinessMessageJournal activity table, as recorded by the custom pipeline component. You can also look up a record for the transaction set in the TransactionSetActivity table.
Querying BusinessMessageJournal
If transaction set reporting is enabled, and you know the BTSInterchangeID of the received interchange, you can use the following SQL Query to find out the BTSInterchangeID of the batch that contains the transaction set submitted to the Batching Orchestration. With this code, you can create a custom application to gain visibility into the messages in a batch.
Important
BizTalk Server will make entries in the BusinessMessageJournal activity only if EDI status reporting and Transaction Set tracking is enabled for the agreement.
Select MessageTrackingID
From BusinessMessageJournal
Where BTSInterchangeID = <given InterchangeID of the receive interchange>
Select BTSInterchangeID
From BusinessMessageJournal
Where MessageTrackingID = <MessageTrackingID from the previous query> and BTSInterchangeID = <given InterchangeID>
See Also
BAM Activities Created to Track EDI-AS2 Messages
Enabling EDI and AS2 Status Reports