In the following orchestration (This is the HelloWorld sample application at C:\Program Files (x86)\Microsoft BizTalk Server 2013\SDK\Samples\Orchestrations\HelloWorld\)
Inside the message assignment shape I have added the following code.
Now when I deploy and test the HelloWorld application, I get the following error
xlang/s engine event log entry: Uncaught exception (see the ‘inner exception’ below) has suspended an instance of service ‘Microsoft.Samples.BizTalk.HelloWorld.HelloSchedule(e0eddb10-5fb9-a44c-aa06-423456a70585)’.
The service instance will remain suspended until administratively resumed or terminated.
If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.
Shape name: ConstructInvoice
Exception thrown from: segment 1, progress 6
Inner exception: There is no value associated with the property ‘BTS.MessageID’ in the message.
There are 2 ways message gets created in the message box
1. Message is published by receive port or orchestration.
–In this case message ID will be created as soon as the message gets into the MessageBox database.
2. Message is created in orchestration using construct shape.
–In this case the message will be created first in-memory representation on orchestration and it will be created into the MessageBox database only once the persistence point comes in the orchestration.
So in the above orchestration we are trying to use the Message ID of the newly created message(InvoiceMessage) in the construct shape which is not been yet created. The Message ID is created ONLY on persistence (normally the send shape adds the persistence point) or during any activity that cause the Message to be published to the MessageBox.
1. If you are using Message ID as a unique identifier may be for co-relation or something like that then its advisable to use Orchestration Instance ID, Microsoft.XLANGs.Core.Service.RootService.InstanceId
For the scenario mentioned above I changed the code to following and it worked.
2. You can either you the message which is already published to message box.
For the scenario mentioned above if I change the code to following it will also work because here the POMessage is already published in MessageBox by the receive port.
Also refer the MSDN forum link