170 likes | 309 Views
User Governed Workflows – Responding in Real Time to Business Priority. What this talk is about: Scatter / Gather Patterns in BizTalk What happens when there is a very large number of work items to process… Ideas for an implementation strategy “Pre-Requisites”
E N D
User Governed Workflows – Responding in Real Time to Business Priority • What this talk is about: • Scatter / Gather Patterns in BizTalk • What happens when there is a very large number of work items to process… • Ideas for an implementation strategy • “Pre-Requisites” • Basic understanding of correlation / convoys in BizTalk • Exposure to integration patterns
Scott Colestock Principal - Trace Ventures, LLC blog: www.traceofthought.net
Agenda • Explore Scatter/Gather Techniques in BizTalk • Establish common terms… • Business problem motivating a particular variation… • Drill-down into “User-controllable & governed” Scatter/Gather
Scatter / Gather Background • Gregor Hohpe’s Enterprise Integration Patterns defines “Scatter/Gather” as composition of “Recipient-List” and “Aggregator” • See Enterprise Integration Patterns with BizTalk Server 2004 (diagrams sourced from here!) • Recipient-List: Single message (or type of message) forwarded to multiple recipients – based on criteria like content
Scatter / Gather Background (cont) • Implementations for Recipient-List: • Parallel shape – good for fixed number of synchronous interactions. Each branch applies criteria for inclusion before Send. • Loop with computed recipients – good for dynamic number of async interactions. • Send shape on each loop iteration • Message box (no orch needed) – good for dynamic number of async one-way interactions, especially when criteria (for who gets message) meshes well with BizTalk filters • [Missing from Hohpe: Send Port Groups…]
Scatter / Gather Background (cont) • Aggregator: Collect sequence of incoming messages and consolidate into single message • (Recipient-List “scatters”; Aggregator “gathers”) • Implementations for Aggregator: • Parallel shape with Receive shapes & “message integration” – optionally inline with the parallel shape used by Recipient-List • Loop that Receives (& integrates responses) on each iteration, and understands when sufficient responses have been received…
Scatter / Gather Background (cont) • Whether you use parallel shapes or loops to implement the scatter and the gather… • The Scatter & Gather can co-exist in the same orchestration • Or exist in distinct orchestrations… • Recipient-List pattern can publish… • Work can be done in subscribing orchestrations, where results are published… • Aggregator can subscribe to results, & publish an aggregated message
What happens when there are a large number of items to scatter? • Typical examples given involve getting quotes from suppliers or shippers (small-scale) • What if I want to execute one or more services on the data represented by each of several thousand elements in a set ? • And then compute an aggregate result ? • Example: Bidding to purchase a large set of assets in a set… • Each asset in a package of thousands requires analysis via several services (“double scatter/gather”) • Results must be persisted and a price for the bid computed
Large Scale Scatter/Gather • Recipient-List loop will be the scatter technique… • Parallel shape would be too wide (kidding) • # of items to scatter is dynamic • Alternative: individual pieces of work published to message box by virtue of external system or de-batching pipeline • Once you have thousands of items to execute against (to “scatter”)…you need “manageability” • You need pause, resume, cancel – initiated through an end-user experience • Recipient-List loop needs to look for and manage interruptions! • …But it is quickly too late!
Large Scale Scatter/Gather (cont) • Work can be “scattered” much more quickly than it can be acted upon • So it will accumulate in the MessageBox as queued work… • Pausing or canceling the “scattering” process isn’t sufficient – at large scale, there will quickly be too much work pending • Do you really want to wait for 1000 orchestrations to spin up, only to have them receive a user cancellation notice and quit?
(Aggregate, aka Gather) (Work on each item) Accumulating work… Scatter work…
Large Scale Scatter/Gather Solution • A “Scattering” loop that on each iteration: • Performs the scatter operation, increments a “work in flight” counter • Looks for Pause/Resume/Cancel messages and implement accordingly • Delay if “work in flight” counter exceeds a defined threshold • A “Gathering” loop that… • Waits for responses, knows when “done” • Decrements “work in flight” counter on each iteration • Key: Prevent us from queuing work that we can’t easily control (pause/resume/cancel)
Conclusion • Scatter/Gather is a composition of “Recipient List” and “Aggregation” patterns • Several techniques available for Scatter/Gather in BizTalk… • Once the process is very lengthy, “management function” over a given instance of the process will be desirable.