This post was originally published here

Indeed, another message archive pipeline component on my BizTalk Pipeline Components Extensions Utility Pack project is available on GitHub!

This time I decided to create a brand new component called the Message Archive Pipeline Component.

For those who aren’t familiar with it, the BizTalk Pipeline Components Extensions Utility Pack project is a set of custom pipeline components (libraries) with several custom pipeline components that can be used in receive and sent pipelines. Those pipeline components provide extensions of BizTalk’s out-of-the-box pipeline capabilities.

Message Archive Pipeline Component

The Message Archive Pipeline Component is a pipeline component that can be used to arch incoming/outgoing messages from any adapters into a local or shared folder. It is very identical and provides the same capabilities as the already existing BizTalk Server Local Archive pipeline component:

  • It can be used in any stage of a receive pipeline or send pipeline;
  • It can be used in multiple stages of a receive pipeline or send pipeline;
  • It provides an option for you to specify the location path for where you want to save the message: local folder, shared folder, network folder.
  • It can be used from any adapter:
    • If the adapter provides the ReceivedFileName property promoted like the File adapter or FTP adapter the component will take this value into consideration and save the message with the same name;
    • Otherwise, it will use the MessageID, saving the file with the MessageID has its name without extension.

So what are the differences between them?

The significant differences between these two components are that the Message Archive Pipeline Component allows you to:

  • Set the filename using macros like %datetime%, %ReceivePort%, %Day%, etc.
    • For example, %ReceivePort%_%MessageID%.xml
  • Set the archive file path once again using macros:
    • for example C:BizTalkPortsArchiveARCHIVE%Year%%Month%%Day%
  • If you don’t want to overwrite existing files, you can specify an additional Macro to distinguish them.
    • For example _%time%
  • You can set up this component for high performance using forward-only streaming best practices.
    • In short, this means developing your pipeline components so that they do their logic either as a custom stream implementation or by reacting to the events available to you through the Microsoft.BizTalk.Streaming.dll stream classes. Without ever keeping anything except the small stream buffer in Memory and without ever seeking the original stream. This is best practice from the perspective of resource utilization, both memory and processor cycles.

This is the list of properties that you can set up on the archive pipeline component:

Property Name Description Sample Values
OverwriteExistingFile Define if the archive file is to be overwritten if already exists true/false
ArchivingEnabled Define if the archive capabilities are enabled or disabled true/false
ArchiveFilePath Archive folder path. You can use macros to dynamically define the path. C:Archive%Year%%Month%%Day%
ArchiveFilenameMacro File name template. If empty the source file name or MessageId will be used. You can use macros to dynamically define the filename. %ReceivePort%_%MessageID%.xml
AdditionalMacroIfExists If a file already exists and OverwriteExistingFile is set to false, a suffix can be added. If empty the MessageId will be used. You can use macros to dynamically define this suffix. _%time%
OptimizeForPerformance Setting to apply high performance on the archive true/false

Available macros

This is the list of macros that you use on the archive pipeline component:

Property Name Description
%datetime% Coordinated Universal Time (UTC) date time in the format YYYY-MM-DDThhmmss (for example, 1997-07-12T103508).
%MessageID% Globally unique identifier (GUID) of the message in BizTalk Server. The value comes directly from the message context property BTS.MessageID.
%FileName% Name of the file from which the File adapter read the message. The file name includes the extension and excludes the file path, for example, Sample.xml. When substituting this property, the File adapter extracts the file name from the absolute file path stored in the FILE.ReceivedFileName context property. If the context property does not have a value the MessageId will be used.
%FileNameWithoutExtension% Same of the %FileName% but without extension.
%FileNameExtension% Same of the %FileName% but in this case only the extension with a dot: .xml
%Day% UTC Current day.
%Month% UTC Current month.
%Year% UTC Current year.
%time% UTC time in the format hhmmss.
%ReceivePort% Receive port name.
%ReceiveLocation% Receive location name.
%SendPort% Send port name.
%InboundTransportType% Inbound Transport Type.
%InterchangeID% InterchangeID.

How to install it

As always, you just need to add these DLLs on the Pipeline Components folder that in BizTalk Server 2020 is by default:

  • C:Program Files (x86)Microsoft BizTalk ServerPipeline Components

In this particular component, we need to have this  DLL:

  • BizTalk.PipelineComponents.MessageArchive.dll

How to use it

Like all previous, to use the pipeline component, I recommend you to create a generic or several generic pipelines that can be reused by all your applications and add the Message Archive Pipeline Component in the stage you desire. The component can be used in a stage of the receive and send pipelines.

Download

THIS COMPONENT IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND.

You can download Message Archive Pipeline Component from GitHub here: