locked
Syntax Error in Orchestration. RRS feed

  • Question

  • Hello,

    I am learning BizTalk Server 2010. Today, I am reading or changing message in the orchestration by promoted property. I have created a simple application which contains below artifacts :

    1. Single Orchestration

    2. One Input Schema (Student.xsd)

    3. One Property Schema.

    I have two message variables i.e. msgIn and msgOut. Both type of Student.XSD. If I use below code, It is working fine. 

    msgOut = msgIn;
    varNew =  msgOut(POC.ReadSetValueOrchestration.UseProperty.PropertySchema.Age);
    System.Diagnostics.EventLog.WriteEntry("Orchestration",varNew);
    
    msgOut(POC.ReadSetValueOrchestration.UseProperty.PropertySchema.Age) = "18";


    Different code - When I am trying to modify the property value, I am getting syntax error. Below is my code.

    varNew =  msgIn(POC.ReadSetValueOrchestration.UseProperty.PropertySchema.Age);
    System.Diagnostics.EventLog.WriteEntry("Orchestration",varNew);
    
    msgIn(POC.ReadSetValueOrchestration.UseProperty.PropertySchema.Age) = "18";

    As per MSDN - 

    A very important concept to understand is that all messages are immutable in BizTalk Server. This means that after a message is constructed, it cannot be changed. A message is considered constructed after it is placed into the MessageBox database. Any changes to the message require that a new message is created and used from that point forward. This is especially clear in the Orchestration Designer, where compilation rules force you to follow strict guidelines about constructing a message before using it, and do not allow the message to be altered outside of its construction block. If you need to change the message, you must create a new construction block that creates a message of the same type, copy the original message to the new message, and then make any changes to the new message before leaving the construction block.


    Error Reason - I cannot change input value. If I need to change it, I must copy in the different variable and then change in the new variable/message. 

    Well, I just want to confirm that I am understanding right or not.



    Thanks, Mohit Dahiya


    Wednesday, July 13, 2016 5:49 AM

Answers

  • Yes, A message once created, cannot be modified at anytime during or after its processing.  To modify a message, the message is copied over to another instance of the message and then modified. The original instance remains the same.

     If you want to make any modification then a new message needs to be constructed (Inside orchestration you use Construct, Transform shape etc, inside pipeline you create a temporary stream).

    Refer: Constructing Messages

    Why messages are immutable inside Biztalk?


    Rachit Sikroria (Microsoft Azure MVP)


    Wednesday, July 13, 2016 5:59 AM
    Moderator
  • Hi Mohit

    Your understanding is correct and what you posted from MSDN is the correct explanation for this.

    Any time you receive a message in an orchestration you cannot edit/modify that message itself. If you need to modify that message, you have to create a new copy of that message(in a new message variable) in a Message Construction Shape and then make the necessary modifications. This applies for both the message content and the message context properties. The reason for this is that the orchestration receives a reference to the message - the actual message body/properties are stored in the MessageBox. Due to the pub/sub nature of the MessageBox, there could be other subscribers who could have received the same message. So, it does not make sense for any subscriber to make modifications to the original message due to the problems it may create for other subscribers to the same message sitting in the MessageBox. There is only a single place (Spool and Parts table) where the message is stored in the MessageBox, all subscribers only receive a reference to the same message entry in those tables.

    Also if you have constructed a message in a Message Construct Shape, once you are out of the construction block you cannot make any modifications to that message.


    Thanks Arindam



    Wednesday, July 13, 2016 6:12 AM
    Moderator

All replies

  • Yes, A message once created, cannot be modified at anytime during or after its processing.  To modify a message, the message is copied over to another instance of the message and then modified. The original instance remains the same.

     If you want to make any modification then a new message needs to be constructed (Inside orchestration you use Construct, Transform shape etc, inside pipeline you create a temporary stream).

    Refer: Constructing Messages

    Why messages are immutable inside Biztalk?


    Rachit Sikroria (Microsoft Azure MVP)


    Wednesday, July 13, 2016 5:59 AM
    Moderator
  • Hi Mohit

    Your understanding is correct and what you posted from MSDN is the correct explanation for this.

    Any time you receive a message in an orchestration you cannot edit/modify that message itself. If you need to modify that message, you have to create a new copy of that message(in a new message variable) in a Message Construction Shape and then make the necessary modifications. This applies for both the message content and the message context properties. The reason for this is that the orchestration receives a reference to the message - the actual message body/properties are stored in the MessageBox. Due to the pub/sub nature of the MessageBox, there could be other subscribers who could have received the same message. So, it does not make sense for any subscriber to make modifications to the original message due to the problems it may create for other subscribers to the same message sitting in the MessageBox. There is only a single place (Spool and Parts table) where the message is stored in the MessageBox, all subscribers only receive a reference to the same message entry in those tables.

    Also if you have constructed a message in a Message Construct Shape, once you are out of the construction block you cannot make any modifications to that message.


    Thanks Arindam



    Wednesday, July 13, 2016 6:12 AM
    Moderator
  • Thank you Rachit and Roy. 

    You both are superbbb :)


    Thanks, Mohit Dahiya

    Wednesday, July 13, 2016 6:16 AM