220 likes | 331 Views
Module 15: Implementing Messaging Patterns. Overview. Lesson 1: Creating Adaptable Orchestration Ports Lesson 2: Receiving Multiple Related Messages. Lesson 1: Creating Adaptable Orchestration Ports. Configuring Port Properties at Runtime Communicating between Orchestrations
E N D
Overview • Lesson 1: Creating Adaptable Orchestration Ports • Lesson 2: Receiving Multiple Related Messages
Lesson 1: Creating Adaptable Orchestration Ports • Configuring Port Properties at Runtime • Communicating between Orchestrations • Assigning Ports to Trading Partners • Demonstration: Configuring Dynamic Ports • Dynamic Binding Options
Configuring Port Properties at Runtime Dynamic Binding Orchestration code sets the port address at runtime Address includes prefix which indicates the adapter and address (e.g. FTP://somehost:21/drop) • Other information can be dynamically set in the context • User name and password • Configuration data for pipeline components • All properties depend on the adapter being used
Communicating between Orchestrations Direct Binding Options and Benefits Provides a means to pass messages between orchestrations Three options for implementation Option 1: MessageBox Orchestration is bound to the MessageBox instead of bound to ports Provides for loosely coupling orchstrations and systems Option 2: Self Correlating Relies on a shared port instance Useful for receiving messages back from a related process Option 3: Shared Port Allows for starting a partner orchestration with a message
Direct Binding with the Message Box Sending Orchestration Direct bound send is published in the message box and routed 2 Direct bound receiver creates subscriptions based on filters 1 Receiving Orchestration MessageBox Orchestration is bound to MessageBox instead of to ports Use correlation and message context properties No subscribers results in an exception in the orchestration Offers the benefits of loosely coupled design
Direct Binding with Self Correlation Caller passes an instance of a port into another orchestration Sending Orchestration Receiving Orchestration 1 Port Port Orchestration responds by sending messages to the port instance 2 Ports rely on a shared instance Useful for receiving messages back from a related process Can be used to send more data/messages to running process BizTalk infrastructure handles the correlation with token
Direct Binding with Shared Ports Ordering Orchestration Shipping Orchestration Shipping Port Allows for starting partner orchestration with a message Similar to the Start Orchestration shape Use single port type and define port in each orchestration Use the same port to define the binding in both orchestrations Reference can be from sender to receiver or vice versa
Assigning Ports to Trading Partners Ordering Orchestration Look up party 2 Get party bound port 3 ShipperRole Send the message 4 ?? Shipper SpeedyExpress Port Set party on role link 1 Role Links Define a process that can apply to multiple partners or services Contain send and receive port types Must specify the role link type and role (provider or consumer)
Choosing Partners for Role Links Party identifiers or aliases are used to determine the partner • Receive Ports • Party identification handled in the receive pipeline • Any receive port can be used by any partner or application • Requires that the receiving host is Authentication Trusted • Send Ports • Set the DestinationParty property on the role link in orchestration TradingPartnerRoleLink(Microsoft.XLANGs.DestinationParty) = new Microsoft.XLANGs.BaseTypes.Party(“keyvalue”, “qualifier”);
Dynamic Binding Options • MessageBox • You want the loose coupling of publish and subscribe • Shared Ports • You want to subscribe to messages from an orchestration • Dynamic Addressing • You will set the address and/or transport dynamically at runtime • Role Links • You are creating a reusable process used with several “partners” • You can define the parties and configure identifiers for them • You can determine at runtime the current “partner” in the process • Self Correlating Ports • You don’t have a common property to correlate on • You are calling the orchestration and can pass the port as a param
Demonstration: Configuring Dynamic Ports In this demonstration, you will see how to: • Configure a Port using Dynamic Binding • Configure a Role Link
Lesson 2: Receiving Multiple Related Messages • How Correlation Works • Orchestration Subscriptions • Convoy Messaging Patterns • Sequential Convoys • Parallel Convoys • Demonstration: Implementing Convoy Patterns
How Correlation Works Orchestration Instance Send Rcv OrderID = 5 Orchestration Instance OrderID = 7 MessageBox Send Rcv
Orchestration Subscriptions Types of Orchestration Subscriptions Activation Subscriptions are created for activating receive shapes Instance Subscriptions are created for receive shapes that are following a correlation set • Activation Subscriptions • New instance of the orchestration is created when a message is received • Subscription created when an orchestration is enlisted Instance Subscriptions Includes receives in called orchestrations Created at runtime when a correlation set is initialized Includes an instance ID for the current orchestration instance New messages routed to the existing orchestration instance
Convoy Messaging Patterns Special Types of Messaging Patterns Using Correlation Convoys are used to address race conditions in messaging Convoys setup instance subscriptions At routing, convoy information is used to correlate messages Two types: Sequential and Parallel
Sequential Convoys Used When Related Messages Are Received in a Series Process messages in a loop until known stop condition Messages must be received from the same port Uniform Sequential Convoy All messages are of the same type Non-Uniform Sequential Convoy Involve different message types
Implementing Sequential Convoys Initialize correlation set 1 Determine how many messages to process 3 Follow correlation set 2
Parallel Convoys Used When Related Messages Arrive in an Unknown Order Any message can be received first Must know at design time how many messages are coming Messages can be received from multiple ports Messages may be of different types The Parallel Actions shape is designed to implement parallel convoys Processing continues once all the messages have arrived
Implementing Parallel Convoys Initialize correlation set 1 Initialize SAME correlation set 2 Process continues after all messages are received 3 Activate = true for each Receive shape within the Parallel Action shape
Demonstration: Implementing Convoy Patterns In this demonstration, you will see how to: • Create a Non-Uniform Sequential Convoy • Create a Parallel Convoy
Lab: Implementing Dynamic Messaging Patterns • Exercise 1: Using Correlation • Exercise 2: Using Role Links • Exercise 3: Defining Parties • Exercise 4: Using Direct Messaging Ports