Message Archive Pipeline Component

Message Archive Pipeline Component

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:

BizTalk Server 2020 – 20 days, 20 posts: Local Archive Pipeline Component for BizTalk Server 2020

BizTalk Server 2020 – 20 days, 20 posts: Local Archive Pipeline Component for BizTalk Server 2020

BizTalk Server 2020 – 20 days, 20 posts – day 9. This week I decide to start migrating a project that I enjoy and use them in several of my clients: BizTalk Pipeline Components Extensions UtilityPack. And the first component that I choose was: Local Archive Pipeline Component.

Local Archive Pipeline
Component

BizTalk Server Local Archive pipeline component it’s a pipeline component that can be used for archiving incoming/outgoing message from any adapters. It will provide the following capabilities :

  • 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 in 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.

The component has two parameters:

  • PerformBackup: True/False value to enable or disable the archive functionality;
  • Folder: Local (or shared) folder for where you want to perform the archive of the message;

What is BizTalk Pipeline Components Extensions Utility Pack?

BizTalk Pipeline Components Extensions Utility Pack is a set of custom pipeline components (libraries) with several custom pipeline components that can be used in received and sent pipelines, which will provide an extension of BizTalk out-of-the-box pipeline capabilities.

The project is available on the BizTalk Server Open Source Community repository on GitHub (https://github.com/BizTalkCommunity), and everyone can contribute with new pipeline components that can be extended or improve the existing BizTalk Server capabilities.

BizTalk Pipeline Components Extensions Utility Pack: Local Archive Pipeline Component

At the moment this project is available for:

  • BizTalk Server 2020;
  • BizTalk Server 2016;
  • BizTalk Server 2010;
  • BizTalk Server 2006-2009

Where to download it?

You can download BizTalk Pipeline Components Extensions Utility Pack from GitHub here:

BizTalk Pipeline Components Extensions Utility Pack

The post BizTalk Server 2020 – 20 days, 20 posts: Local Archive Pipeline Component for BizTalk Server 2020 appeared first on SANDRO PEREIRA BIZTALK BLOG.

BizTalk Pipeline Components Extensions Utility Pack: Local Archive Pipeline Component

BizTalk Pipeline Components Extensions Utility Pack: Local Archive Pipeline Component

BizTalk Pipeline Components Extensions Utility Pack community project for BizTalk Server 2016, once again, got a new update and it now has a new component that you can use in your custom BizTalk Server pipelines: Local Archive Pipeline Component.

Local Archive Pipeline
Component

BizTalk Server Local Archive pipeline component it’s a
pipeline component that can be used for archiving incoming/outgoing message
from any adapters. It will provide the following capabilities:

  • 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 in 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.
public Microsoft.BizTalk.Message.Interop.IBaseMessage Execute(Microsoft.BizTalk.Component.Interop.IPipelineContext pc, Microsoft.BizTalk.Message.Interop.IBaseMessage inmsg)
{
	// 
	// TODO: implement component logic
	// 
	// this way, it's a passthrough pipeline component

	if (this.PerformBackup)
	{
		try
		{
			//Get Message Id
			Guid msgId = inmsg.MessageID;

			//Get Filename by FileAdapter NS
			string fileName = inmsg.Context.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/file-properties").ToString();
			if (string.IsNullOrEmpty(fileName))
			{
				fileName = inmsg.Context.Read("ReceivedFileName", "http://schemas.microsoft.com/BizTalk/2003/ftp-properties").ToString();
				if (string.IsNullOrEmpty(fileName))
				{
					fileName = msgId.ToString();
				}
			}

			if (!new DirectoryInfo(this.Folder).Exists)
			{
				try
				{
					Directory.CreateDirectory(this.Folder);
				}
				catch
				{
					throw;
				}
			}

			SaveStreamToFile(inmsg.BodyPart.Data, fileName, true);

			inmsg.BodyPart.Data.Position = 0;
		}
		catch
		{
			throw;
		}
	}

	return inmsg;
}

What is BizTalk Pipeline Components Extensions Utility
Pack?

BizTalk Pipeline Components Extensions Utility Pack is
a set of custom pipeline components (libraries) with several custom pipeline
components that can be used in received and sent pipelines, which will provide
an extension of BizTalk out-of-the-box pipeline capabilities.

The project is
available on the BizTalk Server Open Source Community repository on GitHub (https://github.com/BizTalkCommunity), and everyone can contribute with new
pipeline components that can be extended or improve the existing BizTalk Server
capabilities.

BizTalk Pipeline Components Extensions Utility Pack: Local Archive Pipeline Component

At the moment it is only available for BizTalk Server
2016, but it will soon be compiled and available for previous versions of the
product.

Where to download it?

You can download BizTalk Pipeline Components Extensions Utility Pack from
GitHub here:

BizTalk Pipeline Components Extensions Utility Pack
GitHub

The post BizTalk Pipeline Components Extensions Utility Pack: Local Archive Pipeline Component appeared first on SANDRO PEREIRA BIZTALK BLOG.