Logo
programming4us
programming4us
programming4us
programming4us
Home
programming4us
XP
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server
programming4us
Windows Phone
 
Windows Server

BizTalk 2009 : Dealing with Extremely Large Messages (part 2) - Large Message Encoding Component

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
6/11/2012 5:45:46 PM

3. Large Message Encoding Component (Send Side)

The large message encoding component is to be used on the send side when the large message is sent by BizTalk. You will need to create a custom send pipeline and add this pipeline component to the Encode stage. This component relies on a property schema being deployed that will be used to store the location to the file within the message context.

Imports System
Imports System.IO
Imports System.Text
Imports System.Drawing
Imports System.Resources
Imports System.Reflection
Imports System.Diagnostics
Imports System.Collections
Imports System.ComponentModel
Imports Microsoft.BizTalk.Message.Interop
Imports Microsoft.BizTalk.Component.Interop
Imports Microsoft.BizTalk.Component
Imports Microsoft.BizTalk.Messaging

Namespace Probiztalk.Samples.PipelinesComponents

    <ComponentCategory(CategoryTypes.CATID_PipelineComponent), _
     System.Runtime.InteropServices.Guid("4f1c7d50-e66f-451b-8e94-2f8d599cd013"), _
     ComponentCategory(CategoryTypes.CATID_Encoder)> _
    Public Class LargeFileEncodingComponent

        Implements IBaseComponent, IPersistPropertyBag, IComponentUI, _
         Global.Microsoft.BizTalk.Component.Interop.IComponent

        Private resourceManager As System.Resources.ResourceManager = New _
         System.Resources.ResourceManager( _
         "Probiztalk.Samples.PipelineComponents.LargeFileEncodingComponent", _
         [Assembly].GetExecutingAssembly)
        Private Const PROPERTY_SCHEMA_NAMESPACE = _
                "http://LargeFileHandler.Schemas.LargeFilePropertySchema"

					  

'<summary>
         'Name of the component
         '</summary>
         <Browsable(False)> _
         Public ReadOnly Property Name() As String Implements _
                 Global.Microsoft.BizTalk.Component.Interop.IBaseComponent.Name
             Get
                 Return resourceManager.GetString("COMPONENTNAME", _
                                 System.Globalization.CultureInfo.InvariantCulture)
             End Get
        End Property

        '<summary>
        'Version of the component
        '</summary>
        <Browsable(False)> _
        Public ReadOnly Property Version() As String Implements _
                Global.Microsoft.BizTalk.Component.Interop.IBaseComponent.Version
             Get
                Return resourceManager.GetString("COMPONENTVERSION", _
                         System.Globalization.CultureInfo.InvariantCulture)
             End Get
         End Property

         '<summary>
         'Description of the component
         '</summary>
         <Browsable(False)> _
         Public ReadOnly Property Description() As String Implements _
             Global.Microsoft.BizTalk.Component.Interop.IBaseComponent.Description
             Get
                 Return resourceManager.GetString("COMPONENTDESCRIPTION", _
                                 System.Globalization.CultureInfo.InvariantCulture)
             End Get
         End Property

         '<summary>
         'Component icon to use in BizTalk Editor
         '</summary>
         <Browsable(False)> _
         Public ReadOnly Property Icon() As IntPtr Implements _
                 Global.Microsoft.BizTalk.Component.Interop.IComponentUI.Icon
             Get
                 Return CType(Me.resourceManager.GetObject("COMPONENTICON", _
                             System.Globalization.CultureInfo.InvariantCulture), _
                             System.Drawing.Bitmap).GetHicon
             End Get
         End Property

					  

'<summary>
         'Gets class ID of component for usage from unmanaged code.
         '</summary>
         '<param name="classid">
         'Class ID of the component
         '</param>
         Public Sub GetClassID(ByRef classid As System.Guid) Implements _
         Global.Microsoft.BizTalk.Component.Interop.IPersistPropertyBag.GetClassID
             classid = New System.Guid("4f1c7d50-e66f-451b-8e94-2f8d599cd013")
         End Sub

         '<summary>
         'not implemented
         '</summary>
         Public Sub InitNew() Implements _
             Global.Microsoft.BizTalk.Component.Interop.IPersistPropertyBag.InitNew
         End Sub

         '<summary>
         'Loads configuration properties for the component
         '</summary>
         '<param name="pb">Configuration property bag"<\param>
         '<param name="errlog">Error status"<\param>
         Public Overridable Sub Load(ByVal pb As _
                         Global.Microsoft.BizTalk.Component.Interop.IPropertyBag, _
                         ByVal errlog As Integer) _
                         Implements Global.Microsoft.BizTalk.Component. _
                         Interop.IPersistPropertyBag.Load
         End Sub

         '<summary>
         'Saves the current component configuration into the property bag
         '</summary>
         '<param name="pb">Configuration property bag"<\param>
         '<param name="fClearDirty">not used"<\param>
         '<param name="fSaveAllProperties">not used"<\param>
         Public Overridable Sub Save _
             (ByVal pb As Global.Microsoft.BizTalk.Component.Interop.IPropertyBag, _
              ByVal fClearDirty As Boolean, ByVal fSaveAllProperties As Boolean) _
              Implements _
              Global.Microsoft.BizTalk.Component.Interop.IPersistPropertyBag.Save
         End Sub

         '<summary>
         'Reads property value from property bag
         '</summary>
         '<param name="pb">Property bag"<\param>

					  

'<param name="propName">Name of property"<\param>
         '<returns>Value of the property"<\returns>
         Private Function ReadPropertyBag( _
             ByVal pb As Global.Microsoft.BizTalk.Component.Interop.IPropertyBag, _
             ByVal propName As String) As Object
             Dim val As Object = Nothing
             Try
                 pb.Read(propName, val, 0)
             Catch e As System.ArgumentException
                 Return val
             Catch e As System.Exception
                 Throw New System.ApplicationException(e.Message)
             End Try
             Return val
         End Function

         '<summary>
         'Writes property values into a property bag.
         '</summary>
         '<param name="pb">Property bag."<\param>
         '<param name="propName">Name of property."<\param>
         '<param name="val">Value of property."<\param>
         Private Sub WritePropertyBag( _
             ByVal pb As Global.Microsoft.BizTalk.Component.Interop.IPropertyBag, _
             ByVal propName As String, ByVal val As Object)
             Try
                 pb.Write(propName, val)
             Catch e As System.Exception
                 Throw New System.ApplicationException(e.Message)
             End Try
         End Sub

         '<summary>
         'The Validate method is called by the BizTalk Editor during the build
         'of a BizTalk project.
         '</summary>
         '<param name="obj">An Object containing the
         'configuration properties."<\param>
         '<returns>The IEnumerator enables the caller
         'to enumerate through a collection of strings containing error messages.
         'These error messages appear as compiler error messages.
         'To report successful property validation,
         'the method should return an empty enumerator."<\returns>
         Public Function Validate( _
             ByVal obj As Object) As System.Collections.IEnumerator Implements _
             Global.Microsoft.BizTalk.Component.Interop.IComponentUI.Validate
             'example implementation:

					  

'ArrayList errorList = new ArrayList();
             'errorList.Add("This is a compiler error");
             'return errorList.GetEnumerator();
             Return Nothing
         End Function

         '<summary>
         'Implements IComponent.Execute method.
         '</summary>
         '<param name="pc">Pipeline context"<\param>
         '<param name="inmsg">Input message"<\param>
         '<returns>Original input message"<\returns>
         '<remarks>
         'IComponent.Execute method is used to initiate
         'the processing of the message in this pipeline component.
         '</remarks>
         Public Function Execute(ByVal pContext As IPipelineContext, _
                                 ByVal inmsg As IBaseMessage) As IBaseMessage _
                                 Implements Global.Microsoft.BizTalk.Component. _
                                 Interop.IComponent.Execute
             Dim isEncoded As Boolean = False

             Try
                 isEncoded = inmsg.Context.Read("IsEncoded", _
                     PROPERTY_SCHEMA_NAMESPACE)
             Catch ex As Exception
                 isEncoded = False
             End Try

             'Build the message that is to be sent out but only if it is encoded
             If isEncoded Then
                 BuildMessageData(pContext, inmsg)
             End If

             Return inmsg
         End Function

         '<summary>
         'Method used to assign the data to a stream.
         'Method reads path from promoted property
         '</summary>
         '<param name="pc">Pipeline context"<\param>
         '<param name="inmsg">Input message to be assigned"<\param>
         '<returns>Original input message by reference"<\returns>


'<remarks>
         'Receives the input message ByRef then assigns the file stream to
         ' the messageBody.Data property
         '</remarks>
         Private Sub BuildMessageData(ByVal pContext As IPipelineContext, _
                                      ByRef inMsg As IBaseMessage)

             Dim messageBody As IBaseMessagePart = pContext.GetMessageFactory(). _
             CreateMessagePart()
             Dim data As New FileStream(inMsg.Context.Read("LargeFileLocation", _
                         PROPERTY_SCHEMA_NAMESPACE), FileMode.Open, _
                         FileAccess.Read, FileShare.Read, 4 * 1024 * 1024)
             messageBody.Data = data
             If data.CanSeek Then
                 data.Position = 0
             End If

             inMsg.BodyPart.Data = data
         End Sub
     End Class
End Namespace				  
Other -----------------
- Microsoft SQL Server 2008 R2 : Client Setup and Configuration for Database Mirroring
- Microsoft SQL Server 2008 R2 : Testing Failover from the Principal to the Mirror
- System Center Configuration Manager 2007 : Site and SQL Server Backups (part 3) - Restoring ConfigMgr Backups - Performing a Site Reset
- System Center Configuration Manager 2007 : Site and SQL Server Backups (part 2) - Restoring ConfigMgr Backups - ConfigMgr Functional Crash
- System Center Configuration Manager 2007 : Site and SQL Server Backups (part 1) - Backing Up ConfigMgr
- Security and Delegation in Configuration Manager 2007 : Securing Configuration Manager Operations
- Security and Delegation in Configuration Manager 2007 : Securing the Configuration Manager Infrastructure (part 4) - Securing Service Dependencies for Configuration Manager
- Security and Delegation in Configuration Manager 2007 : Securing the Configuration Manager Infrastructure (part 3) - Securing Configuration Manager Accounts
- Security and Delegation in Configuration Manager 2007 : Securing the Configuration Manager Infrastructure (part 2) - Securing Configuration Manager Communications
- Security and Delegation in Configuration Manager 2007 : Securing the Configuration Manager Infrastructure (part 1) - Securing Site Systems
 
 
Top 10
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
 
programming4us
Windows Vista
programming4us
Windows 7
programming4us
Windows Azure
programming4us
Windows Server