none
Retriving the timestamp of the received message RRS feed

  • Question

  • Hello everyone,

    Thought my other thread is going long and wanted to know,

    how to retrieve the time stamp of the received messages. Based on the time the messages received I have to send emails to two different send ports. I understand how can I dynamically send the messages but dont know, how can I retrieve the time stamp.

    Thanks for everyone who helped me in the other thread. May be am asking same question again. Sorry about that.  Since I have basic knowledge in Biztalk and done very simple projects with it, I am blank doing this.

    Thanks

    Friday, November 14, 2014 2:03 PM

Answers

  • Hi vdha,

    There is a catch here..

    Do you want to get/analysis the “time stamp of the received message(s)” or do you want get/analysis the “time when the message was received in BizTalk”.

    To get the timestamp when the message was received in BizTalk, then:

    I would try Rachit solution. MessageTracking.AdapterReceiveCompleteTime. This context property give you the time when the BizTalk-Adapter completed reading the message stream from soruce system. This should be considered as the entry point to BizTalk.

    Only overhead with this way is you need to enable tracking at receive..

     

    Reference:NullReferenceException when trying to get the AdapterReceiveCompleteTime property

    To get/analysis the time stamp of the received message(s):

     then  use “File.FileCreationTime” to get the timestamp when the file was created not received/processed by BizTalk. obviously File based adapters adds this property to the context of the received message(s). And this will be available to non-service based adapters (obviously you would not get/have the file creation time if it’s not received by file based process)


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    • Marked as answer by vdha Friday, November 14, 2014 4:50 PM
    • Unmarked as answer by vdha Friday, November 14, 2014 4:51 PM
    • Marked as answer by vdha Friday, November 14, 2014 4:51 PM
    Friday, November 14, 2014 3:51 PM
  • Hi,

    In your Orchestration you should be able to check

    <yourmessessage>(MessageTracking.AdapterReceiveCompleteTime),

    This is the time it completed processing on the receive adapter.

    Note: Please ensure that the tracking for messages should be turned on.

    Refer: How to fetch timestamp from when a message hits the receive pipeline

    Rachit

    • Proposed as answer by Pushpendra K Singh Friday, November 14, 2014 2:31 PM
    • Marked as answer by vdha Friday, November 14, 2014 4:50 PM
    Friday, November 14, 2014 2:14 PM
    Moderator
  • This will be available in the context of the message, you shall be able to retrieve it in an orchestration.

    please check this thread as well

    http://blogs.msdn.com/b/mattlind/archive/2006/08/10/693241.aspx



    Regards Pushpendra K Singh


    • Edited by Pushpendra K Singh Friday, November 14, 2014 2:35 PM
    • Marked as answer by vdha Friday, November 14, 2014 4:51 PM
    Friday, November 14, 2014 2:34 PM
  • Yes thats the best way when you work with file adapter. It Represents the time that the file was written to the folder and it is that is monitored by the file receive adapter.

    varDatetime =Message_1(FILE.FileCreationTime);

    Thanks

    Abhishek

    • Marked as answer by vdha Friday, November 14, 2014 4:50 PM
    Friday, November 14, 2014 4:02 PM
  • try just this simple line in Rules shape:

    System.DateTime.Compare(msgIn(FILE.FileCreationTime),System.DateTime.Parse("11:30:00")) >0

    Idea is simlar to Abhishek's one, but simpler..


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    • Proposed as answer by Rachit SikroriaModerator Friday, November 14, 2014 6:05 PM
    • Marked as answer by vdha Monday, November 17, 2014 12:10 PM
    Friday, November 14, 2014 5:56 PM

All replies

  • Hi,

    In your Orchestration you should be able to check

    <yourmessessage>(MessageTracking.AdapterReceiveCompleteTime),

    This is the time it completed processing on the receive adapter.

    Note: Please ensure that the tracking for messages should be turned on.

    Refer: How to fetch timestamp from when a message hits the receive pipeline

    Rachit

    • Proposed as answer by Pushpendra K Singh Friday, November 14, 2014 2:31 PM
    • Marked as answer by vdha Friday, November 14, 2014 4:50 PM
    Friday, November 14, 2014 2:14 PM
    Moderator
  • After first receive shape ,you can have a expression shape were you can get the timestamps(you need to create a variable of type datetime)

    varDatetime =System.DateTime.Now; Or by below

    varDatetime =ReceiveMsg( MessageTracking.AdapterReceiveCompleteTime); email =fundatetime.GetemailaddressonDatetime(varDatetime);

    To get  the email address depending upon the date time C# method will be like this

     [Serializable]
        public class Class1
        {
            public string GetemailaddressonDatetime(DateTime dt )
            {
                TimeSpan whenTimeIsOver = new TimeSpan(07, 00, 00);
                string emailaddress1 ="abhi@gmail.com";
                string emailaddress2 ="yield@gmail.com";
    
                if (DateTime.Now.TimeOfDay > whenTimeIsOver)
                {
                    return emailaddress1;
                }
                else
                {
                    return emailaddress2;
                }
            }
        }

    In the above example email is a variable in Orchestration of type class1.

    Thanks

    Abhishek



    Friday, November 14, 2014 2:33 PM
  • This will be available in the context of the message, you shall be able to retrieve it in an orchestration.

    please check this thread as well

    http://blogs.msdn.com/b/mattlind/archive/2006/08/10/693241.aspx



    Regards Pushpendra K Singh


    • Edited by Pushpendra K Singh Friday, November 14, 2014 2:35 PM
    • Marked as answer by vdha Friday, November 14, 2014 4:51 PM
    Friday, November 14, 2014 2:34 PM
  • Hi vdha,

    There is a catch here..

    Do you want to get/analysis the “time stamp of the received message(s)” or do you want get/analysis the “time when the message was received in BizTalk”.

    To get the timestamp when the message was received in BizTalk, then:

    I would try Rachit solution. MessageTracking.AdapterReceiveCompleteTime. This context property give you the time when the BizTalk-Adapter completed reading the message stream from soruce system. This should be considered as the entry point to BizTalk.

    Only overhead with this way is you need to enable tracking at receive..

     

    Reference:NullReferenceException when trying to get the AdapterReceiveCompleteTime property

    To get/analysis the time stamp of the received message(s):

     then  use “File.FileCreationTime” to get the timestamp when the file was created not received/processed by BizTalk. obviously File based adapters adds this property to the context of the received message(s). And this will be available to non-service based adapters (obviously you would not get/have the file creation time if it’s not received by file based process)


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    • Marked as answer by vdha Friday, November 14, 2014 4:50 PM
    • Unmarked as answer by vdha Friday, November 14, 2014 4:51 PM
    • Marked as answer by vdha Friday, November 14, 2014 4:51 PM
    Friday, November 14, 2014 3:51 PM
  • Ashwin,

    I am using the File adapter in the receive port. So, should I go for File.FileCreationTime. Should I use this in the orchestration or on the send port.

    Thanks

    Friday, November 14, 2014 3:57 PM
  • Yes thats the best way when you work with file adapter. It Represents the time that the file was written to the folder and it is that is monitored by the file receive adapter.

    varDatetime =Message_1(FILE.FileCreationTime);

    Thanks

    Abhishek

    • Marked as answer by vdha Friday, November 14, 2014 4:50 PM
    Friday, November 14, 2014 4:02 PM
  • Vdha,

    For your case then File.FileCreationTime should do the trick. You can use it either in Orchestration or in send port filter.

    If you’re already using Orchestration as part of this process, then you can also consider using dynamic send port and check the timestamp and assign the dynamic SMTP send port property in Orchestration.

    So you have 3 options now- Orchestration, static send port with filter or dynamic send port with properties assigned in Orchestration :)


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    Friday, November 14, 2014 4:17 PM
  • Thank you everybody in your effort in explaining me this in detail.

    Just wanted to make sure if I can use <= in the Rule for comparing the date.Because when I use I am getting error,

    RM(FILE.FileCreationTime) <= System.DateTime.Parse("11:30:00")

    • Edited by vdha Friday, November 14, 2014 5:04 PM
    Friday, November 14, 2014 4:55 PM
  • You need to create some variable in Orchestration .Do like this in expression shape .

    varDatetime =Message_1(FILE.FileCreationTime) ;
    VarparseDatetime =System.DateTime.Parse("11:30:00");
    intresult =System.DateTime.Compare(varDatetime,VarparseDatetime);

    Now in decide shape your rule can be like this

    intresult >0 //File creation datetime is greater than varasig time

    Thanks

    Abhishek

    Friday, November 14, 2014 5:39 PM
  • try just this simple line in Rules shape:

    System.DateTime.Compare(msgIn(FILE.FileCreationTime),System.DateTime.Parse("11:30:00")) >0

    Idea is simlar to Abhishek's one, but simpler..


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    • Proposed as answer by Rachit SikroriaModerator Friday, November 14, 2014 6:05 PM
    • Marked as answer by vdha Monday, November 17, 2014 12:10 PM
    Friday, November 14, 2014 5:56 PM
  • Ashwin,

    So the operations under the Rule gets executed if time is less than 11:30:00. am I getting correct.


    • Edited by vdha Friday, November 14, 2014 6:03 PM
    Friday, November 14, 2014 5:59 PM
  • Yup. That's correct. Rule gets executed if time is greater than 11:30:00 with that statement,

    Refer: DateTime.Compare Method

    If you want to execute the rule when the file creation time is earlier than 11:30:00 you should go with this

    System.DateTime.Compare(msgIn(FILE.FileCreationTime),System.DateTime.Parse("11:30:00"))< 0

    If you want to execute the rule when the file creation time is later than 11:30:00 you should go with this

    System.DateTime.Compare(msgIn(FILE.FileCreationTime),System.DateTime.Parse("11:30:00")) >0

    Rachit




    Friday, November 14, 2014 6:03 PM
    Moderator
  • Yes you're correct. If the file creation time is greater than 11:30:00, “true/rule” side of the decision shape would execute otherwise “else” side.

    If you want greater-than or equal-to as you have given, try the code as below:

    System.DateTime.Compare(msgIn(FILE.FileCreationTime),System.DateTime.Parse("11:30:00")) >= 0





    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    Friday, November 14, 2014 6:09 PM
  • Hello Ashwin,

    I am having an issue with this Compare function. My Orchestration looks like this,

    In the rule I have set System.DateTime.Compare(RM(FILE.FileCreationTime),System.DateTime.Parse("08:05:00")) > 0

    And in the ConstructMessage_2 I have set the 

    E7P(Microsoft.XLANGs.BaseTypes.Address) = "mailto:abc@mail.com";

    in the ConstructMessage_3 I have set the

     E7P(Microsoft.XLANGs.BaseTypes.Address) = "mailto:xyz@mail.com";

    The problem is irrespective to the time the all mail is sent either to abc@mail.com or xyz@mail.com. I even changed the comparssion expression but same thing happens.

    Any help is greatly appreciated.

    Thanks

    Monday, November 17, 2014 1:17 PM
  • Sorry what's the question? Are the mails sent to abc@mail.com or xyz@mail.com? Or mails are not sent at all?

    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    Monday, November 17, 2014 1:51 PM
  • Sorry for not being specific,the  problem is if in the rule I give System.DateTime.Compare(RM(FILE.FileCreationTime),System.DateTime.Parse("09:00:00")) < 0

    expecting “true/rule” side of the decision shape would execute if I drop the message before 9.00 am and mail will be sent to abc@mail.com which is in ConstructMessage_2. But the messages are sent to the xyz@mail.com in else ConstructMessage_3 though it is dropped before 9.00 am or after 9.00 am

    Similarly if I give

    System.DateTime.Compare(RM(FILE.FileCreationTime),System.DateTime.Parse("09:00:00")) > 0 in the rule mails are sent to to the abc@mail.com in else ConstructMessage_2 though it is dropped before 9.00 am or after 9.00 am.

    I know its confusing but this is what happens here.And not sure if I am missing something


    • Edited by vdha Monday, November 17, 2014 3:08 PM
    Monday, November 17, 2014 2:14 PM
  • Or are there any other way for doing this. Any help is greatly appreciated. Thanks
    Monday, November 17, 2014 3:27 PM
  • Hi vdha,

     

    As mentioned in my earlier replies.

    The context property File.FileCreationTime is the file creation time of the file. Not the time when it has been consumed. If you’re using folder locations to drop files, this changes. To see the exact time. Disable the receive location, drop the file in the folder (file will be not processed as the Receive location is disable). Check the properties of the file, you will see the file creation time.

     

    Then now enable the Receive Location, by enabling the tracking on the Receive  Port. Once he file has been processed you see the FileCreationTime in the context property of the message. This shall match the file creation time which you saw in the properties of the file.

     

    If you want to have logic based on the file arrival date or file consummation datetime in BizTalk have your logic based on MessageTracking.AdapterReceiveCompleteTime context

     


    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

    Monday, November 17, 2014 5:18 PM