This post was originally published here

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.