1. Problem
You want to send messages from within a BizTalk orchestration for processing by other orchestrations.
2. Solution
Within a BizTalk orchestration, messages are sent using the Send shape. To use the Send shape, follow these steps:
Open
the BizTalk project that contains the orchestration with the messages
you want to send. For this exercise, it is assumed that the
orchestration is already configured to receive a message.
Drag a Send shape from the toolbox. Place the shape underneath the orchestration Receive shape.
In the Orchestration View window, expand the top node of the tree view so that the Messages folder is visible.
Right-click the Messages folder, and select New Message, which creates a message.
Click the new message, and give it a descriptive name in the Properties window (msgCustomer in our example).
Click the Message Type property in the Properties window, select the Schema node, and select the appropriate schema. In this example, it uses the Customer.xsd schema.
Select the Send shape, and in the Properties window, assign the message to msgCustomer.
NOTE
The type of port you are
creating is not a physical BizTalk port. This is an orchestration port
that will be bound later to the physical port.
To
configure a port and port type for the orchestration to use to send a
message, right-click Port Surface, and click New Port, as shown in Figure 1.
Click the exclamation mark (tool tip), and select "No port type has been specified." This starts the Port Configuration Wizard.
On the Select a Port Type page, name the port oprtSendCustomer, and click Next.
On the Configure Port page, enter the following details, as shown in Figure 2, and then click Next:
Select the "Create a new Port Type" radio button.
Name the port type oprtTypeSendCustomer.
Select the One-Way radio button under Communication Pattern.
Select the "Internal - limited to this project" radio button under Access Restrictions.
On
the Port Binding page, select "I'll always be sending messages on this
port" for the port direction of communication. For port binding, select
Direct, and select the first radio button. Routing between ports will be
defined by filter expressions on incoming messages in the MessageBox
database. Click Finish after making your selections.
NOTE
In this example, we
are implementing a standard publish/subscribe model; that is, the
message implementation does not need to be physically specified. The
BizTalk MessageBox database will be responsible for initializing one or
more downstream messaging subscriptions.
From
the port on the Port Surface area, click the green square, and drag it
to the Send shape on the orchestration design surface, as shown in Figure 3.
3. How It Works
In this recipe's
solution, we demonstrated how to send messages out of an orchestration
to BizTalk messaging and downstream BizTalk endpoints. To review, the
following are the key steps to perform to send a message:
Identify a message to send. This can be a .NET class, multipart message, web reference message, or schema.
Create an orchestration port. Specify the port type and access restrictions.
Se et the port direction and binding (dynamic or direct) to BizTalk messaging artifacts.
When sending messages
out of an orchestration, it is also important to consider the type of
request you would like to implement. Should the message not be returned
(one-way), or should the orchestration wait for a response
(request/response)? In essence, the port choice should support the type
of communication being implemented.
Another important
consideration is the message context. Within the orchestration, is the
message its own instance, or should it be aware of correlation
implications? Within the Send shape, you have the ability to address
correlation message context by setting the Following Correlation Sets or Initializing Correlation Sets property.