Need Unique ID for a batch of messages

Home Page Forums BizTalk 2004 – BizTalk 2010 Need Unique ID for a batch of messages

Viewing 1 reply thread
  • Author
    Posts
    • #16128

      Hi,

       I have an orchestration that will process a set of messages (as rows in a single comma delimited file). After some processing in the orchestration, it adds each one into a database one by one (via  a web service that inserts a single record).  What I need to do is assign an identical id to every message in the batch, but a new id for the next batch. That is, file 1 comes in with 20 records. Each of the 20 records is inserted into a database with a sequence number of 1. File 2 comes into the receive location. It has 40 records. Each of the 40 records will be added to the database with a sequence number of 2, and so on. Remember that my web service only takes one record at a time, because for each single message within a batch that fails, I write a log message top a receive port. That is, the identifier is the same for all records within the batch, but different across subseqent batches.

       I have a web service that returns a sequence number, but of course since that will be called once for each record in the batch, all the sequence numbers will be different.

       Is there some way go grab a number like this from within a BizTalk orchestration? Or, is there some way to have something execite ONCE within an orchestration, no matter how many rows are in my input file – and then ONCE again, for the next input file (even though there are mutiple rows in the file). Details appreciated.

       Thanks,

       Chris

    • #16166

      I assume you are debatching inside your Receive Pipeline? If so you could set an “ID” on that batch of messages.  Then, you could use a Convoy to process all of the same messages in one file.  At this point, you can use Orchestration Instance Id, or any random ID (even the ID you set for the message, to be your unique ID. 

       

      I’ve done something like this in the past and setting the ID on the message inside the pipeline was the key.

      • #16481

        Yes, with a FF disassembler. 

        Could you provide any suggestions/details around how to set the ID in the pipeline? I can't access orchestration variables from the pipeline, so do I need to actually modify the message somehow in the pipeline?

         

        Thanks,

         

        Chris

         

         

        • #16482

          One possibility is to use the BTS.InterchangeID. This is a GUID that is assigned to the incoming message before it is debatched and all child messages will have the same InterchangeID.

          You could use this as the unique id in your database, change the Id datatype in your database to GUID or varchar.

        • #16483

          You just need to promote a value into the message context.

           

          Here are the steps at a high level:

          1. Create a property schema with a  MessageContext type property
          2. Create a custom pipeline component to promote your batch id into this property
          3. In code, create a batch id and promote it
          4. Create a custom pipeline using your new pipeline component.

           

          I think I have bits and pieces of all this on this site.  Look at some of the BizTalk 2004 Samples.  The hardest part is the custom pipeline component.

           

          To give you an idea, this is probably 8 hours of work.

Viewing 1 reply thread
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.