Demystifying Direct Bound Ports – Part 5

Dynamic Direct Bound Ports


A dynamic port allows you to set the address of the logical port to a URI so that at runtime the message can be routed to the correct service to handle the request and the service can then send to the indicated endpoint.  In BizTalk Server 2006 the same can be done for direct bound ports. 


Setting the address of a port is done by assigning a URI to the Microsoft.XLANGs.BaseTypes.Address property of the port:


 


Port_1(Microsoft.XLANGs.BaseTypes.Address) = “http://contoso.com/myService”;


 


The general format of a port address is:


<adapterAlias><endpointAddress>


 


A port address is made up of the adapter alias that ultimately maps to a transport, and the actual endpoint as is meaningful to the adapter.  So an adapter alias of HTTP:// will have a URL and a FILE:// will have a URN or a reference to a local file on disk.


This of course begs the question of, “what does a direct bound port URI look like?” 


Direct bound port address’ have the following format:


 


msgbox:<PartnerService>#DirectPortFlavor#<port-type>


 


So for a direct bound port the transport, what would typically be the adapter alias, is the literal msgbox:. The rest is the endpoint address which, for direct bound ports, is a partner service and a port. The #DirectPortFlavor# indicates how the partner service will be interpreted.  Let’s look at the address of each flavor of a direct bound port.


Message Box Direct Bound Port Address


There is no address for a message box direct bound port as it doesn’t make sense since it is a pure publish or subscribe into the message bus (i.e. message box).


Partner Direct Bound Port Address


A partner direct bound port has the following format:


msgbox:<orchestration>#DirectPort#<port-type>


 


In this case the partner service is the orchestration the port is bound to.  The <orchestration> part is the strong name of the orchestration and has the format:


namespace.orchestrationTypeName, assemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9876543210abcdef


and <port-type> is the strong name of the port type and has the format:


namespace.portType, assemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9876543210abcdef.


 


The direct port flavor is the literal #DirectPort# and indicates that the partner service is an orchestration.


 


Here’s an example of what an address would look like:


msgbox:MyTests.TestOrchestration, MyTests.dll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9876543210abcdef#DirectPort#MyTests.SomeDirectBoundPortType, MyTests.dll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9876543210abcdef


 


Self-Correlating Direct Bound Port Address


A self-correlating direct bound port has the following format:


msgbox:<portServiceId>#selfCorrelated#<port-type>


 


In this case the partner service is the <portServiceId> which is the unique identifier, GUID, given to the port when the orchestration was instantiated and <port-type> is again the strong name of the port-type for this port and has the format:


 


namespace.portType, assemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9876543210abcdef.


 


The direct port flavor is the literal #selfCorrelated# and indicates that the partner service is a service instance identifier.


 


Here’s an example of what an address would look like:


msgbox:aabbccdd-0011223344-eeff-5566778899aa #selfCorrelated#MyTests.SomeSelfCorrelatingPortType, MyTests.dll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9876543210abcdef


 


Scenario for using a self-correlated dynamic direct bound port


When doing asynchronous inter-orchestration communication, the typical way of correlating a message to a particular instance of an orchestration is by creating a correlation-set, initializing it with particular property values received or sent in a message, then following that correlation-set on a receive shape.  This can make your orchestration more complex if the values of the properties that you need to correlate on are not in the message when it is originally received forcing you to construct a new message with the correlation properties properly set and sending that message somewhere (it has to be sent to be able to initialize the correlation-set but the destination can be some null orchestration (i.e. an orchestration with just a receive shape)[1]).  Another pattern for inter-orchestration communication correlation is when you have a send and receive on separate one-way ports in a loop and you are using the send port to initialize the correlation set and the receive port to follow.  In this case you must unwind the loop (the first send must be outside of the loop) because you cannot initialize a correlation-set inside of a loop (a correlation-set can only be initialized once) thus making your orchestration even more complex[2].  To get around this extra correlation complexity you can use a self-correlating port that under the covers will manage the responsibility of correlating a message back to the current instance of the orchestration.


In the past the only way we would be able to use a self-correlated direct bound port was by passing the port as a parameter to a ’started’ orchestration so that it can asynchronously send a message back to the instance of the orchestration that started it. 


Today in an expression shape you can save the port address of the self-correlated direct bound port in a message,


 


Msg1.ReturnAddress = SendPort1(Microsoft.XLANGs.BaseTypes.Address);


 


 send it to a partner orchestration and when the partner needs to communicate back to the instance of the orchestration that sent the original request it can set the address of a direct bound port to the port address that was saved in the message. 


 


ResponsePort1(Microsoft.XLANGs.BaseTypes.Address) = Msg1.ReturnAddress;


 


This really simplifies the design of the orchestration that is expecting asynchronous responses from its partner orchestrations.


When you create the send side port it doesn’t matter what type of direct bound port you create as you will be overriding its address.  I would recommend keeping each side as consistent direct bound flavors to make it easier to review the design.


 


Now that I have lifted the covers of how the dynamic direct bound ports work you can imagine many different scenarios and design patterns.  A few examples include, versioning, dynamic orchestration calling, and, of course, simplified correlation.


 






[1] When using this pattern of communication be careful as there can be a race condition where a message could be sent to the orchestration before the correlation initialization message is sent.  To avoid this ensure that messages that will follow this correlation are not sent until the correlation set is initialized.



[2] Another work around is to declare the correlation set within a scope within the loop so that on each iteration of the loop the correlation set falls out of scope and gets re-instantiated and then properly re-initialized.  This may not be a suitable option as there could already be transactional scopes within the loop and adding another transactional scope may cause extra persistence overhead.

Microsoft PacWest SharePoint Server Newsletter – July 2006

Microsoft PacWest SharePoint Server Newsletter – July 2006

Update on Download Availability of MOSS 2007 Beta 2

Just a bit of a heads up Microsoft is going to begin to charge $1.50 per download of the Beta 2 applications, perhaps as early as the end of July, so get your downloads now! J
Download here.

DevelopWithoutBorders.com

If you have a favorite charity, here’s a contest to help get your idea implemented. Build a demo and if you win, prizes are awarded to pay towards the implementation of your project. Check out the rules at http://www.developwithoutborders.com.

News Items

Article describing some specifics with Web Browser support in MOSS 2007.

To jumpstart your training with MOSS 2007, review the steps outlined in this article. SharePoint 2007 Technical Training.

This post references a Beta 2 Technical Resources DVD. I have copies of this DVD for those of you who haven’t received this yet. Let me know and I will send one out to you. It was printed in May, and includes a collection of all the documentation available, architecture diagrams, and even a configured Beta 2 installation of MOSS 2007 within a Virtual PC image. You can expand the compressed form of the Virtual Hard Disk to your machine and use Virtual PC or Virtual Server to start exploring MOSS 2007.

Why the New UI? If you’ve been asking yourself why did Microsoft change the Office User Interface *again*, and feel like you may become the brunt of company jokes when you start demonstrating it to your colleagues, here’s the information that you need. First, subscribe to Jensen Harris’ blog. Then, listen to the podcasts that he has produced so you can hear how he describes the changes to the interface. New Office User Interface Podcast – Part 1 [35:29], and New User Interface Podcast – Part 2 [39:43].

New File Formats. A good article by David Gainer that talks about some of the internals of the new file formats and presents some ideas about how to choose which file format to use. One more What are the Open XML File Formats, and How Do I Get Started?

What is Groove, and Isn’t It the Same as Windows SharePoint Services (WSS)? Here’s an article that describes Groove in relation to WSS. The level of integration between Groove and WSS is going to raise questions within your organization. Here’s a way to stay a step ahead. Call me if you’d like to see this integration work or if you’re not sure how to interpret this article for your organization, and we can chat about it.

Wall Posters (PDF files) describing the SharePoint Developer Map and the InfoPath Object Model. Display your SharePoint colors with pride!

Virtual PC 2004 SP1 is free and now available for download. If you don’t have any MOSS 2007 images to run with Virtual PC 2004, let me know, and I’ll supply you with a virtual image of a configured Beta 2 system

If you haven’t seen CodePlex, yet, check it out. It’s a new community and code-sharing site that includes SharePoint and WSS solutions, among others. One solution that you can explore is the SharePoint Learning Kit, which is similar to Class Server, if you’re familiar with that. It’s an e-learning delivery and tracking solution.

A second CodePlex project to check out is the SharePoint Community Kit, which is a starter site for creating a community-oriented SharePoint site.

Brian Jones is a program manager with Microsoft who works with the new file formats in MOSS 2007. I’ve linked to him before, but he has a recent article describing MSFT’s support for ODF.

Records Management is a new collection of functionality in MOSS 2007. The Records Management team has started a blog, the RecMan Blog. Check the archive of this blog for June for some training and detailed discussions about content types, the document information panel, and document policies.

A Workflow Developer Starter Kit is available for download. This includes Visual Studio project templates and a sample workflow for WSS v3 Beta 2.

“WinFX sounds great, but what happens to .NET?” Have you asked this question or have you been asked this question? Somesagar’s Weblog answers this.

Previous Items

Beta 2 is Available

The long awaited release of MOSS Beta 2 happened at the end of May. Please download responsibly! Here’s the link (http://www.microsoft.com/office/preview/beta/getthebeta.mspx) to download your copy. The SharePoint team has posted a “Please read this before installing” blog entry. I have a limited supply of already printed DVDs – I will share them with anyone who emails me, asking for a copy.

E-Learning for MOSS 2007

There is a collection of free E-Learning classes available for Microsoft Office 2007 and Microsoft Office SharePoint Server 2007. See the catalog at https://www.microsoftelearning.com/catalog/default.aspx.

SharePoint Server 2007 Skills Assessment

Now that you’ve got MOSS Beta 2 installed and you’re feeling pretty good about yourself, we’ve posted a self assessment site where you can prove your mad skillz. Let me know how you did. Here are the steps:

  1. Go to http://www.microsoft.com/learning/assessment/
  2. Click on the “Assess Yourself” link.
  3. Click on “I already know my topic area”, and login with your Passport account.
  4. Click on “2007 Microsoft Office System” and underneath Microsoft Office SharePoint Server 207, click on “Take the assessment”

Tech-Ed 2006 Information

Tech-Ed was last week in Boston, and while I wasn’t able to attend, I did hear that there was some great stuff handed out in relation to MOSS 2007. Check out these downloads.

A free book titled: 7 Development Projects for Microsoft Office SharePoint Server 2007 and Windows SharePoint Services 3.0. whew. That’s a long title. The link will take you to a downloadable .pdf version of the book.

Forrester report: Developers, Get Ready: 2007 Microsoft Office System Is A Serious Application Platform.

Customer Focused Task Force for BizTalk Server Documentation

We are forming a focus group to root out long standing or painful documenation deficits our customers are going through. My section (surprise, surprise) is adapters. I am thus solicting immediate feedback from any customer who has problems or suggested changes to any of the BizTalk Server documentation, general or specific in nature.


Here are some current requests I have received. Do you have any others or any comments on these?



  • How do you customize adapter property pages user interface
  • How do you define additional (property page) properties through an XML schema
  • Detailed documentation for changes between developing adapters for 2004 and 2006
  • Handling and tracking errors with endpoint issues (invalid endpoints,  error APIs, resumable vs non-resumable message)
  • Performance issues in adapter development (where and how to instrument code)

Thank you!

Demystifying Direct Bound Ports – Part 5

Dynamic Direct Bound Ports


A dynamic port allows you to set the address of the logical port to a URI so that at runtime the message can be routed to the correct service to handle the request and the service can then send to the indicated endpoint.  In BizTalk Server 2006 the same can be done for direct bound ports. 


Setting the address of a port is done by assigning a URI to the Microsoft.XLANGs.BaseTypes.Address property of the port:


 


Port_1(Microsoft.XLANGs.BaseTypes.Address) = “http://contoso.com/myService”;


 


The general format of a port address is:


<adapterAlias><endpointAddress>


 


A port address is made up of the adapter alias that ultimately maps to a transport, and the actual endpoint as is meaningful to the adapter.  So an adapter alias of HTTP:// will have a URL and a FILE:// will have a URN or a reference to a local file on disk.


This of course begs the question of, “what does a direct bound port URI look like?” 


Direct bound port address’ have the following format:


 


msgbox:<PartnerService>#DirectPortFlavor#<port-type>


 


So for a direct bound port the transport, what would typically be the adapter alias, is the literal msgbox:. The rest is the endpoint address which, for direct bound ports, is a partner service and a port. The #DirectPortFlavor# indicates how the partner service will be interpreted.  Let’s look at the address of each flavor of a direct bound port.


Message Box Direct Bound Port Address


There is no address for a message box direct bound port as it doesn’t make sense since it is a pure publish or subscribe into the message bus (i.e. message box).


Partner Direct Bound Port Address


A partner direct bound port has the following format:


msgbox:<orchestration>#DirectPort#<port-type>


 


In this case the partner service is the orchestration the port is bound to.  The <orchestration> part is the strong name of the orchestration and has the format:


namespace.orchestrationTypeName, assemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9876543210abcdef


and <port-type> is the strong name of the port type and has the format:


namespace.portType, assemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9876543210abcdef.


 


The direct port flavor is the literal #DirectPort# and indicates that the partner service is an orchestration.


 


Here’s an example of what an address would look like:


msgbox:MyTests.TestOrchestration, MyTests.dll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9876543210abcdef#DirectPort#MyTests.SomeDirectBoundPortType, MyTests.dll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9876543210abcdef


 


Self-Correlating Direct Bound Port Address


A self-correlating direct bound port has the following format:


msgbox:<portServiceId>#selfCorrelated#<port-type>


 


In this case the partner service is the <portServiceId> which is the unique identifier, GUID, given to the port when the orchestration was instantiated and <port-type> is again the strong name of the port-type for this port and has the format:


 


namespace.portType, assemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9876543210abcdef.


 


The direct port flavor is the literal #selfCorrelated# and indicates that the partner service is a service instance identifier.


 


Here’s an example of what an address would look like:


msgbox:aabbccdd-0011223344-eeff-5566778899aa #selfCorrelated#MyTests.SomeSelfCorrelatingPortType, MyTests.dll, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9876543210abcdef


 


Scenario for using a self-correlated dynamic direct bound port


When doing asynchronous inter-orchestration communication, the typical way of correlating a message to a particular instance of an orchestration is by creating a correlation-set, initializing it with particular property values received or sent in a message, then following that correlation-set on a receive shape.  This can make your orchestration more complex if the values of the properties that you need to correlate on are not in the message when it is originally received forcing you to construct a new message with the correlation properties properly set and sending that message somewhere (it has to be sent to be able to initialize the correlation-set but the destination can be some null orchestration (i.e. an orchestration with just a receive shape)[1]).  Another pattern for inter-orchestration communication correlation is when you have a send and receive on separate one-way ports in a loop and you are using the send port to initialize the correlation set and the receive port to follow.  In this case you must unwind the loop (the first send must be outside of the loop) because you cannot initialize a correlation-set inside of a loop (a correlation-set can only be initialized once) thus making your orchestration even more complex[2].  To get around this extra correlation complexity you can use a self-correlating port that under the covers will manage the responsibility of correlating a message back to the current instance of the orchestration.


In the past the only way we would be able to use a self-correlated direct bound port was by passing the port as a parameter to a ’started’ orchestration so that it can asynchronously send a message back to the instance of the orchestration that started it. 


Today in an expression shape you can save the port address of the self-correlated direct bound port in a message,


 


Msg1.ReturnAddress = SendPort1(Microsoft.XLANGs.BaseTypes.Address);


 


 send it to a partner orchestration and when the partner needs to communicate back to the instance of the orchestration that sent the original request it can set the address of a direct bound port to the port address that was saved in the message. 


 


ResponsePort1(Microsoft.XLANGs.BaseTypes.Address) = Msg1.ReturnAddress;


 


This really simplifies the design of the orchestration that is expecting asynchronous responses from its partner orchestrations.


When you create the send side port it doesn’t matter what type of direct bound port you create as you will be overriding its address.  I would recommend keeping each side as consistent direct bound flavors to make it easier to review the design.


 


Now that I have lifted the covers of how the dynamic direct bound ports work you can imagine many different scenarios and design patterns.  A few examples include, versioning, dynamic orchestration calling, and, of course, simplified correlation.


 






[1] When using this pattern of communication be careful as there can be a race condition where a message could be sent to the orchestration before the correlation initialization message is sent.  To avoid this ensure that messages that will follow this correlation are not sent until the correlation set is initialized.



[2] Another work around is to declare the correlation set within a scope within the loop so that on each iteration of the loop the correlation set falls out of scope and gets re-instantiated and then properly re-initialized.  This may not be a suitable option as there could already be transactional scopes within the loop and adding another transactional scope may cause extra persistence overhead.

Commerce Server 2007: Developer Edition Available and FREE!

Now this is very cool!


Microsoft has made the new Commerce Server 2007 Developer Edition available for immediate download in advance of the GA release and it’s FREE! Only registration is required.


http://www.microsoft.com/commerceserver/evaluation/software.mspx


Gentlemen, start your e-commerce engines!


Technorati Tags: Commerce Server

Share this post: Email it! | bookmark it! | digg it! | reddit!| kick it!

Using MOM 2005 to Recover ports on BizTalk 2006

This will be a semi-fictitious case study. In using MOM 2005 to recover an errant SQL port.  This scenario is common and I’ve been asked about it a lot.  This approach is the simple meat and potatoes process. There are lots of areas that could be polished up but that kind of thing can clutter up an article with too much detail.


The basic steps will be as follows:



  1. Define a rule to detect the error condition
  2. Define a script to correct the error condition
  3. Wire up the script to the rule so that the rule cant trigger it.

Define a rule to detect the error condition


For whatever reason (network down, SQL down) the port was unable to commmunicate with SQL and BizTalk shut it down. This will create an event log entry similar to the following


Type:Error
EventID:5649
Source: BizTalk Server 2004/2006


The receive location “SQL://<sql name/info>” is shutting down. Details:”The error threshold has been exceeded. The receive location is shutting down.”


You will setup a MOM Rule to detect this condtion. This is not a total MOM tutorial so I won’t go over the details here, but the basic process is to create a new rule and use the criteria tab to specify as many details as possible from the above event log entry. Be sure the rule is using the application event log as a source.


Define a script to correct the error condition


I would normally like to use managed code, but it is nice to remove dependencies from the .NET framework version (i.e. 2.0 might not be installed) and I also like being able to issue changes without having to recompile. This is good and bad for several reasons I don’t want to get into.  The script that I use targets a specific port and tries to enable it.  The script (written in vbscript) is the following: (it is bacially a lift from the BizTalk SDK)






‘————————————————————————-

‘ WMI script to enable/disable the receive locations

‘—————————————————


Option Explicit


EnableReceiveLocation “ReceivePort1”, “ReceiveLocation1”, “TRUE”


 


Sub EnableReceiveLocation(strReceivePortName, strReceiveLocationName, sEnable)
   
    ‘error handling is done by explicity checking the err object rather than using
    ‘the VB ON ERROR construct, so set to resume next on error.
    On Error Resume Next
   
   
    Dim objInstSet, objInst, strQuery
   
           
    ‘set up a WMI query to acquire a list of receive locations with the given Name and
    ‘ReceivePortName key values.  This should be a list of zero or one Receive Locations.
    strQuery = “SELECT * FROM MSBTS_ReceiveLocation WHERE  ReceivePortName =””” & strReceivePortName & “””AND Name =””” & strReceiveLocationName & “”””
    Set objInstSet = GetObject(“Winmgmts:!root\MicrosoftBizTalkServer”).ExecQuery(strQuery)
   
    ‘Check for error condition before continuing.
    If Err <> 0    Then
        PrintWMIErrorThenExit Err.Description, Err.Number
    End If


    ‘If Receive Location found, enable it, otherwise print error and end.
    If objInstSet.Count > 0 then
        For Each objInst in objInstSet
                       
            ‘Now enable /disable  receive location
            if sEnable= “TRUE” then
                objInst.Enable
            else
                objInst.Disable
            end if
            If Err <> 0    Then
                PrintWMIErrorThenExit Err.Description, Err.Number
            End If
            if sEnable = “TRUE” then
                 return 100
            else
                return 101
            end if
        Next
    Else
        WScript.Echo “No Receive Location was found matching that Name.”
    End If
           
End Sub


 


‘This subroutine deals with all errors using the WbemScripting object.  Error descriptions
‘are returned to the user by printing to the console.
Sub    PrintWMIErrorThenExit(strErrDesc, ErrNum)
    On Error Resume    Next
    Dim    objWMIError    : Set objWMIError =    CreateObject(“WbemScripting.SwbemLastError”)


    If ( TypeName(objWMIError) = “Empty” ) Then
        wscript.echo strErrDesc & ” (HRESULT: ”    & Hex(ErrNum) & “).”
    Else
        wscript.echo objWMIError.Description & “(HRESULT: ”    & Hex(ErrNum) & “).”
        Set objWMIError    = nothing
    End    If
   
    ‘bail out
    wscript.quit 0
End    Sub


Sub PrintUsage()
    WScript.Echo “Usage:” + Chr(10) + Chr(10) + _
                 “cscript enabledisableallrecloc [enable/disable]” + _
                 Chr(10) + ”       Example to enable all receive locations: enabledisableallreclo enable “+ Chr(10) + Chr(10)
               
End Sub


 


Wire the script to the rule


You have to go to the Response tab of the rule and u

BizTalk Server 2006 Tech Center and Developer Center are Live!!!

Loads of information on BizTalk Server 2006 are captured in the Tech and Developer Center Portals by Microsoft. C
Check the cool BizTalk Server 2006 Tutorials, Trial versions, Product Documentation, Newsgroups and morefrom the Tech Center URL
http://www.microsoft.com/technet/prodtechnol/biztalk/default.mspx
Check out the cool BizTalk Server 2006 Internals, Adapters, user guides, Code Samples, White papers, Utilities and more from the […]

Failed to load msxmlsql.dll

We had a power outage and our working BizTalk machines seemed to be unaffected. However when I tried to deploy any solution, I got the following error: ‘Failed to load msxmlsql.dll’
The only article I found was this.
I applied the fix to my BizTalk machine, which did not fix the issue. Before calling support, I decided […]