BizTalk: Internals: the Partner Direct Ports and the Orchestration Chains

Partner Direct Port is one of the BizTalk hidden gems. It opens simple ways to the several messaging patterns.

This article based on the Kevin Lam’s blog article. The article is pretty detailed but it still leaves several unclear pieces. So I have created a sample and will show how it works from different perspectives.

Requirements

We should create an orchestration chain where the messages should be routed from the first stage to the second stage. The messages should not be modified. All messages has the same message type.

Common artifacts

Source code can be downloaded here.

It is interesting but all orchestrations use only one port type.Schema1PortType

It is possible because all ports are one-way ports and use only one operation.

I have added a B orchestration. It helps to test the sample, showing all test messages in channel.

Orch.B

The Receive shape Filter is empty. A Receive Port (R_Shema1Direct) is a plain Direct Port. As you can see, a subscriptionB.Subscription expression of this direct port has only one part, the MessageType for our test schema: A Filer is empty but, as you know, a link from the Receive shape to the Port creates this MessageType expression.

I use only one Physical Receive File port to send a message to all processes.

Each orchestration outputs a Trace.WriteLine(“<Orchestration Name>”).

Forward Binding

This sample has three orchestrations: A_1, A_21 and A_22.

A_1 is a sender, A_21 and A_22 are receivers.

Here is a subscription of the A_1 orchestration:A_1.Subscription

It has two parts

  • A MessageType. The same was for the B orchestration.
  • A ReceivePortID. There was no such parameter for the B orchestration. It was created because I have bound the orchestration port with Physical Receive File port. This binding means the PortID parameter is added to the subscription.

All

How to set up the ports?

  1. All ports involved in the message exchange should be the same port type. It forces us to use the same operation and the same message type for the bound ports.
  2. This step as absolutely contra-intuitive. Ninja We have to choose a Partner Orchestration parameter for the sending orchestration, A_1. The first strange thing is it is not a partner orchestration we have to choose but an orchestration port. But the most strange thing is we have to choose exactly this orchestration and exactly this port.It is not a port from the partner, receive orchestrations, A_21 or A_22, but it is A_1 orchestration and S_SentFromA_1 port. Surprised smile
  3. Now we have to choose a Partner Orchestration parameter for the received orchestrations, A_21 and A_22. Nothing strange is here except a parameter name. We choose the port of the sender, A_1 orchestration and S_SentFromA_1 port.

As you can see the Partner Orchestration parameter for the sender and receiver orchestrations is the same.

Testing

I dropped a test file in a file folder. There we go: DebugView.Forward

  1. A dropped file was received by B and by A_1
  2. A_1 sent a message forward.
  3. A message was received by B, A_21, A_22

Let’s look at a context of a message sent by A_1 on the second step:

  • A MessageType part. It is quite expected.
  • A PartnerService, a ParnerPort, an Operation. All those parameters were set up in the Partner Orchestration parameter on both bound A-1.MessageSent.Contextports.

 

 

Now let’s see a subscription of the A_21 and A_22 orchestrations. A_2x.Subscription

Now it makes sense. That’s why we have chosen such a strange value for the Partner Orchestration parameter of the sending orchestration.

Inverse Binding

This sample has three orchestrations: A_11, A_12 and A_2.

A_11 and A_12 are senders, A_2 is receiver.

All

How to set up the ports?

  1. All ports involved in the message exchange should be the same port type. It forces us to use the same operation and the same message type for the bound ports.
  2. This step as absolutely contra-intuitive. Ninja We have to choose a Partner Orchestration parameter for a receiving orchestration, A_2. The first strange thing is it is not a partner orchestration we have to choose but an orchestration port. But the most strange thing is we have to choose exactly this orchestration and exactly this port.It is not a port from the partner, sent orchestrations, A_11 or A_12, but it is A_2 orchestration and R_SentToA_2 port. Surprised smile
  3. Now we have to choose a Partner Orchestration parameter for the sending orchestrations, A_11 and A_12. Nothing strange is here except a parameter name. We choose the port of the sender, A_2 orchestration and R_SentToA_2 port.

Testing

    I dropped a test file in a file folder. There we go: DebugView.Inverse

    1. A dropped file was received by B, A_11 and by A_12
    2. A_11 and A_12 sent two messages forward.
    3. The messages were received by B, A_2

Let’s see what was a context of a message sent by A_1 on the second step:

  • A MessageType part. It is quite expected.
  • A PartnerService, a ParnerPort, an Operation. All those parameters were set up in the Partner Orchestration parameter on both bound ports.A-1x.MessageSent.Context

Here is a subscription of the A_2 orchestration.

A-2.Subscription

Models

I had a hard time trying to explain the Partner Direct Ports in simple terms. I have finished with this model:

Forward Binding

Publisher/Sender doesn't know Subscribers/Receivers. Subscribers/Receivers know a Publisher/Sender.
1 Publisher –> M Subscribers

Inverse Binding

Publishers/Senders know a Subscriber/Receiver. Subscriber/Receiver doesn't know Publishers/Senders.
M Publishers –> 1 Subscriber

Notes

 

Orchestration chain

It’s worth to note, the Partner Direct Port Binding creates a chain opened from one side and closed from another.

The Forward Binding: A new Receiver can be added at run-time. The Sender can not be changed without design-time changes in Receivers.

The Inverse Binding: A new Sender can be added at run-time. The Receiver can not be changed without design-time changes in Senders.

Print | posted on Friday, December 7, 2012 9:59 PM

Feedback

No comments posted yet.
Post A Comment
Title:
Name:
Email:
Comment:
Verification: