none
Global variable in Biztalk orchestration RRS feed

  • Question

  • Hi All,

    I have one requirement. I am polling from DB and storing the count of total polled records in an integer variable INTCOUNTER in one orchestration1.

    I have one other separate orchestration2 in the same project. What I want is to access the value of INTCOUNTER of orchestration1 in Orchestration2.

    Please remember I am not using call orch or start orch. Both are totally independent processes in one project.

    Is it possible ?? Please advice

    Thanks

    Anshu Kumar

    Friday, May 13, 2016 10:24 AM

Answers

  • This should be fairly easy to achieve.

    1) Create a property schema with a single property Count(of type MessageContextPropertyBase). 

    2) If you are debatching using a receive pipeline within your orchestration: Setup a CorrelationType (CType1) on BTS.InterchangeID in orch1. Send out each debatched message via a DirectBound MessageBox Port. On this send shape, initialize a CorrelationSet of the above CorrelationType. Since, you are debatching, all debatched messages will have the same InterchangeID. Given you are debatching within a loop and your Send Shape would be within the loop, you have to declare the CorrelationSet within a scope, and not globally at orchestration level(otherwise you will get an error saying that the CorrelationSet  is already initialized).

    Also, set the Count property in your property schema to the number of records, and write it to the message you are sending out.

    The orch2 has it's Activating Receive Shape with a ReceivePort that is Direct Bound to the MessageBox. Create a CorrelationSet of same correlationType in this orch as well. The activating Receive Shape would initialize the CorrelationSet. Start a loop with a counter that loops as per the Count property in the input message. Inside the loop, have a subsequent ReceiveShape that is connected to the same ReceivePort which follows the above CorrelationSet - basically setup a sequential convoy. So, you would loop until you receive all the messages from orch1.

    Note: 

    If you are not debatching using a ReceivePipeline in orch1, you can create a correlationSet on any property other than InterchangeID. It can be your custom property as well - just initialize that property to a SINGLE value in orch1 for every debatched message, so that the convoy can be setup correctly. For example, you can use orchestration instanceID as your correlationSet property. Or even generate a global Guid before the start of the send loop, and set the CorrelationSet underlying property to that same Guid string for every debatched message in your loop, like-

    Message_Out(ProjName.YourPropertySchemaPropertyName) = varGuidString;


    Thanks Arindam







    Saturday, May 14, 2016 5:16 PM
    Moderator

All replies

  • Please remember I am not using call orch or start orch. Both are totally independent processes in one project.

    First question you need to ask yourself - how do you know orchestration1 is running when your code/thread is executing in Orchestration2?

    There is surely a better approach you can think of - maybe you can use Start orchestration from orchestration1, OR, use Direct Binding port to MessageBox(from orch1) and send a message that contains INTCOUNTER that triggers Orchestration2?


    Thanks Arindam



    Friday, May 13, 2016 10:31 AM
    Moderator
  • Thanks Arindam,

    can u tell me that can we use sequential convoy when we use call orch or start orch ???

    Bcz in first orchestartion I am debatching the record one by one from the polled record and sending to out folder.

    The out folder is Receive location for second orchestration in which I am using sequential convoy to aggregate all the messages.

    In second orchestration Convoy message is under loop. I want to run the loop till the Intcounter.

    Please suggest

    Friday, May 13, 2016 11:06 AM
  • What you can do is not send out the messages from Orch 1 to a receive location butAssign some properties to the message and also ur intcounter value to context property of the message and put message in msg box.

    Have ur Orch 2 subscribe from message box based on some filter and then u can access ur int conuter.

    No need to introduce extra send and receive ports.


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer

    Friday, May 13, 2016 11:13 AM
    Answerer
  • Thanks Pi_Xel_xar,

    It measn ur saying me to use Direct Binding port to MessageBox(from orch1)

    Friday, May 13, 2016 11:29 AM
  • Yes, Please.. And that should also be the correct pattern ,

    Create a property schema with fileds

    INTCOUNTER

    ToProcessName

    The have the message out from Orch 1

    messageOut = message;

    messageOut(Property.INTCOUNTER) = 20; (ur variable)

    messageOut(Property.ToProcessName) = Orch2

    And then create a correlation set on Property.ToProcessName and then in the send shape initialise that correlation

    Then in Orch2 have ur Receive direct binded and a filter condition on the property.

    U dont need to promote IntCounter so no need to have this in initialize correlation.


    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer


    Friday, May 13, 2016 11:58 AM
    Answerer
  • You don't want to do what you're asking.  It won't work.

    Can you describe your entire process?  Then we can give you much better advice.

    Friday, May 13, 2016 12:07 PM
    Moderator
  • You don't want to do what you're asking.  It won't work.

    Can you describe your entire process?  Then we can give you much better advice.

    Hi John,

    Here is my Requirement:

    I have a table in which one column is available in which xml record is stored in each row.

    I need to poll all the records based on some condition. For that I am using Oracle polling.

    Now I need to de-batch every single xml which is coming under below structure from DB

    <POLLINGSTMT xmlns="http://Microsoft.LobServices.OracleDB/2007/03/POLLINGSTMTCPTEST">
    <POLLINGSTMTRECORD>
    <POLLINGSTMTRECORD>
    <R_DETAILS>

    xml record from table

    </R_DETAILS>
        </POLLINGSTMTRECORD>
      </POLLINGSTMTRECORD>
    </POLLINGSTMT>

    I need to extract the exact xml structure which is under <R_DETAILS> node because that value is also a complete xml for which I have defined a separate schema. I am validating every extracted xml with that schema and sending to another orchestration for creating the batch of all de-batched xml.

    Now I want to create the batch count equivalent to the count which was polled from DB in the orchestration in which I am aggregating these xmls.

    This is my requirement. I hope I am clear if not please let me know.

    Thanks in Advance

    Friday, May 13, 2016 12:37 PM
  • Hi Anshu

    Just eliminate the folder/intermediate Receive Location.

    Also, can you share more details on what your scenario is?

    Why are your debatching and then aggregating again? Is there any business logic involved?



    Thanks Arindam

    Friday, May 13, 2016 12:39 PM
    Moderator
  • The simplest way is for you to create a promoted property on the message where you can assign this value. Since you're de-batching messages there should be a InterchangeSequenceNumber which will tell you the sequence number of the message and your promoted property will tell you the total number of the messages in that batch.

    Then it does not make a difference about the de-batcher and the receiver being different orchestrations or otherwise and I do not think a call orchestration is warranted.

    Regards.

    • Proposed as answer by Angie Xu Monday, May 23, 2016 1:55 AM
    Friday, May 13, 2016 1:35 PM
  • Hi Anshu,

    in the orch 1 --> Read from DB base and calculate the no of records in the polled data and keep the count value in one variable. And debatch message and add contect property to hold the counter values(each debatched message will have the counter) publish the message to message box.

    Orche 2--> implement sequential convoy--> after receiving the first message in the orch2 read context value and set it as loop counter.

    This way you can avoid temporary file share location.

    please mark it as answer if it helped you.

    Saturday, May 14, 2016 12:11 AM
  • This should be fairly easy to achieve.

    1) Create a property schema with a single property Count(of type MessageContextPropertyBase). 

    2) If you are debatching using a receive pipeline within your orchestration: Setup a CorrelationType (CType1) on BTS.InterchangeID in orch1. Send out each debatched message via a DirectBound MessageBox Port. On this send shape, initialize a CorrelationSet of the above CorrelationType. Since, you are debatching, all debatched messages will have the same InterchangeID. Given you are debatching within a loop and your Send Shape would be within the loop, you have to declare the CorrelationSet within a scope, and not globally at orchestration level(otherwise you will get an error saying that the CorrelationSet  is already initialized).

    Also, set the Count property in your property schema to the number of records, and write it to the message you are sending out.

    The orch2 has it's Activating Receive Shape with a ReceivePort that is Direct Bound to the MessageBox. Create a CorrelationSet of same correlationType in this orch as well. The activating Receive Shape would initialize the CorrelationSet. Start a loop with a counter that loops as per the Count property in the input message. Inside the loop, have a subsequent ReceiveShape that is connected to the same ReceivePort which follows the above CorrelationSet - basically setup a sequential convoy. So, you would loop until you receive all the messages from orch1.

    Note: 

    If you are not debatching using a ReceivePipeline in orch1, you can create a correlationSet on any property other than InterchangeID. It can be your custom property as well - just initialize that property to a SINGLE value in orch1 for every debatched message, so that the convoy can be setup correctly. For example, you can use orchestration instanceID as your correlationSet property. Or even generate a global Guid before the start of the send loop, and set the CorrelationSet underlying property to that same Guid string for every debatched message in your loop, like-

    Message_Out(ProjName.YourPropertySchemaPropertyName) = varGuidString;


    Thanks Arindam







    Saturday, May 14, 2016 5:16 PM
    Moderator