There is no value associated with the property ‘BTS.MessageID’ in the message.

In the following orchestration (This is the HelloWorld sample application at C:\Program Files (x86)\Microsoft BizTalk Server 2013\SDK\Samples\Orchestrations\HelloWorld\)

 

 

HelloHorldOrch

Inside the message assignment shape I have added the following code.

System.Diagnostics.EventLog.WriteEntry(“HelloWorld”,InvoiceMessage(BTS.MessageID));

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.
InstanceId: fbaf254b-ac0f-4b8d-b1ed-94a58d7f8cd9
Shape name: ConstructInvoice
ShapeId: 619c4eb0-2371-4cb6-a60c-eae729be8693
Exception thrown from: segment 1, progress 6
Inner exception: There is no value associated with the property ‘BTS.MessageID’ in the message.

REASON

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.

SOLUTION

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.

System.Diagnostics.EventLog.WriteEntry(“HelloWorld”, Microsoft.XLANGs.Core.Service.RootService.InstanceId.ToString()); 

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.

System.Diagnostics.EventLog.WriteEntry(“HelloWorld”, POMessage(BTS.MessageID));

 

Also refer the MSDN forum link

https://social.msdn.microsoft.com/Forums/en-US/5e6df6f2-a4cf-4e75-b2eb-ed7cb1553085/btsmessageid-is-not-working-with-new-constructed-message?forum=biztalkgeneral

 

Loved this? Spread the word


BizTalk Server Monitoring

Gautam

Follow me here

About the Author

My name is Gyanendra Kumar Gautam. I am Solution Consultant, who basically works to hook the stuff together using Microsoft technologies like Azure PaaS, Azure Serverless Services, Microsoft BizTalk Server, and Azure DevOps Services.

You may also like

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}
turbo360

Never miss a good story!

 Subscribe to my blog to keep up with the latest news!