I recently had an issue in BizTalk where I needed to start off an orchestration with one of two types of message. This in itself is not a difficult task, although I do find that the documentation is a little lacking some times and it can take a while to figure out how it is done. In fact, some rather sketchy documentation will tell you that you may only have one activating receive shape at the start of an Orchestration without mentioning the exceptions to that rule; namely the
Listen shape and the
Parallel Actions shape.
In this post, we are concerned with the
Listen shape. But we need to know the basic difference between
Parallel Actions and
Listen. The difference is the operator:
| Shape |
Operator |
| Listen |
OR |
| Parallel Actions |
AND |
Simply put, a Parallel Actions shape must wait for all paths to complete before the orchestration may continue. A Listen shape will take whichever branch completes first.
The
Listen shape allows for multiple concurrent paths of execution in the Orchestration. The usual example is to give a
Listen shape and a
Delay to demonstarte the if the
Delaty shape expires before the message is received, the Orchestration will proceed regardless. The smae will happen if, instaead of a
Delay, we simply use another receive location.
The following is a bullet point list of how to set up and orchestartion that will activate on
one of any number of incoming messages:
- Create a new Orchestartion in your BizTalk project that will contain your dual-receive.
- Create two Schemas. The do not need to conain too much, they just need to be different. You will also need to generate an isnatnce of each schema.
- In your Orchestration, drag a Listen shape from the tool box.
- In to each path of the Listen shape, drag a Receive shape.
- Create a Message Type for each of the Schemas.
- Set each of the Receive Shapes to subscribe to one of the Message Types.
- Create a port for each Receive shape. You may of course just use different operations of the same port.
- Set each of the Receive shapes to be an Activating Receive.
- After each Receive Shape, ad an Expressions shape that writes "Received x" to the debug log. (where x is the Schema name)
- Add an Expression shape under the Listen that writes "Complete." out to the Debug log.
- Add a juicy key file, compile and deploy.
- In BizTalk Administrator, create and bind your receive locations.
- Launch a debug viewer, turn it all on and drop some instances of your schemas in. You should get some results out of the debug viewer.