ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » MQMD.PutTime is ahead of CURRENT_TIMESTAMP

Post new topic  Reply to topic
 MQMD.PutTime is ahead of CURRENT_TIMESTAMP « View previous topic :: View next topic » 
Author Message
juandelcid
PostPosted: Fri Feb 22, 2019 6:02 pm    Post subject: MQMD.PutTime is ahead of CURRENT_TIMESTAMP Reply with quote

Newbie

Joined: 22 Feb 2019
Posts: 6

Hello, I'm trying to distinguish between these two instances (moments in time):

- When a message was put in a queue (MQMD.PutTime)
- The current timestamp (CURRENT_TIMESTAMP)

But, for some reason, MQMD.PutTime is always ahead (by a few hundredths of a second) relative to CURRENT_TIMESTAMP. This strikes me as odd and it's screwing with my log.

Here's a simple test I wrote to evidence this behavior:

MQ Input -> ESQL Compute -> MQ Output

ESQL Code:

Code:

   CREATE FUNCTION Main() RETURNS BOOLEAN
   BEGIN
      SET OutputRoot = InputRoot;

      SET OutputRoot.XMLNSC.Test.MQPutTime = InputRoot.MQMD.PutTime;
      SET OutputRoot.XMLNSC.Test.CURRENTTIMESTAMP = CURRENT_TIMESTAMP;
      
      RETURN TRUE;
   END;


And these are some results:

Code:

<Test><MQPutTime>19:04:13.100</MQPutTime><CURRENTTIMESTAMP>2019-02-22T14:04:13.056369-05:00</CURRENTTIMESTAMP></Test>
<Test><MQPutTime>19:04:13.100</MQPutTime><CURRENTTIMESTAMP>2019-02-22T14:04:13.059274-05:00</CURRENTTIMESTAMP></Test>
<Test><MQPutTime>19:04:13.100</MQPutTime><CURRENTTIMESTAMP>2019-02-22T14:04:13.060569-05:00</CURRENTTIMESTAMP></Test>
<Test><MQPutTime>19:04:13.100</MQPutTime><CURRENTTIMESTAMP>2019-02-22T14:04:13.063354-05:00</CURRENTTIMESTAMP></Test>
<Test><MQPutTime>19:04:13.100</MQPutTime><CURRENTTIMESTAMP>2019-02-22T14:04:13.064548-05:00</CURRENTTIMESTAMP></Test>
<Test><MQPutTime>19:04:13.100</MQPutTime><CURRENTTIMESTAMP>2019-02-22T14:04:13.065608-05:00</CURRENTTIMESTAMP></Test>
<Test><MQPutTime>19:04:13.110</MQPutTime><CURRENTTIMESTAMP>2019-02-22T14:04:13.066664-05:00</CURRENTTIMESTAMP></Test>
<Test><MQPutTime>19:04:13.120</MQPutTime><CURRENTTIMESTAMP>2019-02-22T14:04:13.078409-05:00</CURRENTTIMESTAMP></Test>
<Test><MQPutTime>19:04:13.120</MQPutTime><CURRENTTIMESTAMP>2019-02-22T14:04:13.079523-05:00</CURRENTTIMESTAMP></Test>
<Test><MQPutTime>19:04:13.120</MQPutTime><CURRENTTIMESTAMP>2019-02-22T14:04:13.080586-05:00</CURRENTTIMESTAMP></Test>
<Test><MQPutTime>19:04:13.120</MQPutTime><CURRENTTIMESTAMP>2019-02-22T14:04:13.083440-05:00</CURRENTTIMESTAMP></Test>
<Test><MQPutTime>19:04:13.120</MQPutTime><CURRENTTIMESTAMP>2019-02-22T14:04:13.085449-05:00</CURRENTTIMESTAMP></Test>
<Test><MQPutTime>19:04:13.130</MQPutTime><CURRENTTIMESTAMP>2019-02-22T14:04:13.087388-05:00</CURRENTTIMESTAMP></Test>
<Test><MQPutTime>19:04:13.130</MQPutTime><CURRENTTIMESTAMP>2019-02-22T14:04:13.089379-05:00</CURRENTTIMESTAMP></Test>
<Test><MQPutTime>19:04:13.130</MQPutTime><CURRENTTIMESTAMP>2019-02-22T14:04:13.090434-05:00</CURRENTTIMESTAMP></Test>
<Test><MQPutTime>19:04:13.130</MQPutTime><CURRENTTIMESTAMP>2019-02-22T14:04:13.092401-05:00</CURRENTTIMESTAMP></Test>
<Test><MQPutTime>19:04:13.130</MQPutTime><CURRENTTIMESTAMP>2019-02-22T14:04:13.095274-05:00</CURRENTTIMESTAMP></Test>


As you can see, MQMD.PutTime is ahead by a little (0.05 seconds, on average).

Does anybody know how to fix this?

My setup is:
- Windows 2012 R2 64 bits
- IBM MQ v9.0.0.5
- IBM Integration Bus v10.0.0.15

Another thing, this does not happen on a Linux machine where I tried to replicate the problem (CentOS7 64 bits, MQ v9.0.0.5 + IIB v10.0.0.15), only on Windows.

Thanks in advance,
-JG
[/code]
Back to top
View user's profile Send private message
mvic
PostPosted: Sat Feb 23, 2019 4:35 am    Post subject: Re: MQMD.PutTime is ahead of CURRENT_TIMESTAMP Reply with quote

Jedi

Joined: 09 Mar 2004
Posts: 2080

Add something into your program that grabs the time from the OS, for comparison.
Eg. _ftime from https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/ftime-ftime32-ftime64?view=vs-2017
Back to top
View user's profile Send private message
bruce2359
PostPosted: Sat Feb 23, 2019 6:25 am    Post subject: Re: MQMD.PutTime is ahead of CURRENT_TIMESTAMP Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9396
Location: US: west coast, almost. Otherwise, enroute.

juandelcid wrote:
As you can see, MQMD.PutTime is ahead by a little (0.05 seconds, on average).

Does anybody know how to fix this?

Your app makes two calls, one after the other, MQPUT and gettime, These calls will not occur at the same precise instance in time. Nothing to fix here.

Is your concern about the differences you cite as ‘on average?’

In a computer science class, we were assigned the fun and interesting task of asking what time it is on different hardware (chip-set, clock speed, # of processors, RAM), differing o/s’s, guest vs host, etc.. included machine-language vs compiler-languages.

Asking, answering and understanding ‘what time is it?’ (or the duration of an event) is not as simple as it seems. Wide variation, especially as the clock has more decimal digits (subseconds) of resolution.
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
juandelcid
PostPosted: Sat Feb 23, 2019 11:49 am    Post subject: Re: MQMD.PutTime is ahead of CURRENT_TIMESTAMP Reply with quote

Newbie

Joined: 22 Feb 2019
Posts: 6

bruce2359 wrote:
juandelcid wrote:
As you can see, MQMD.PutTime is ahead by a little (0.05 seconds, on average).

Does anybody know how to fix this?

Your app makes two calls, one after the other, MQPUT and gettime, These calls will not occur at the same precise instance in time. Nothing to fix here.

Is your concern about the differences you cite as ‘on average?’


Thanks for your reply. My problem is not with variation... it has to do with the expectation that a message has been put on a queue (MQMD.PutTime), presumably earlier than when it is being processed (CURRENT_TIMESTAMP). Would you agree?

What I need to know is how long the message has been waiting on the queue before it was taken by my flow and processed. That's the ultimate goal... and right now I'm getting negative duration. This is what I need to fix.

I understand that MQMD.PutTime has a precision of 0.01 seconds (one hundredth of a second), that's not the problem. So long MQMD.PutTime registers before CURRENT_TIMESTAMP I'll be content.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sat Feb 23, 2019 1:09 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

You are comparing the MQ Put time to CURRENT_TIMESTAMP...
Any particular reason you're not using CURRENT_GMTTIMESTAMP?

Please check if a call to CURRENT_GMTTIMESTAMP would provide the results you're expecting...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
juandelcid
PostPosted: Sat Feb 23, 2019 6:32 pm    Post subject: Re: MQMD.PutTime is ahead of CURRENT_TIMESTAMP Reply with quote

Newbie

Joined: 22 Feb 2019
Posts: 6

mvic wrote:
Add something into your program that grabs the time from the OS, for comparison.
Eg. _ftime from https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/ftime-ftime32-ftime64?view=vs-2017


I added a call to

Code:
java.time.Instant.now()


and found that the OS time is consistent with MQMD.PutTime (i.e. the OS time happens later than PutTime):

Code:
<Test><OSTime><MQPutTime>02:20:59.070</MQPutTime><CURRENTTIMESTAMP>2019-02-23 20:20:59.067498-05:00</CURRENTTIMESTAMP><OSTime>2019-02-24T02:20:59.074Z</OSTime></Test>


I'll use the OS time instead of CURRENT_TIMESTAMP.

Thanks for your reply!

-JG
Back to top
View user's profile Send private message
juandelcid
PostPosted: Sat Feb 23, 2019 6:36 pm    Post subject: Reply with quote

Newbie

Joined: 22 Feb 2019
Posts: 6

fjb_saper wrote:
You are comparing the MQ Put time to CURRENT_TIMESTAMP...
Any particular reason you're not using CURRENT_GMTTIMESTAMP?

Please check if a call to CURRENT_GMTTIMESTAMP would provide the results you're expecting...


It made no difference, CURRENT_GMTTIMESTAMP is shifted by 5 hours from CURRENT_TIMESTAMP but with the same seconds and milliseconds.

Thank you, anyway, for your attention.

-JG
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Sat Feb 23, 2019 9:23 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

juandelcid wrote:
fjb_saper wrote:
You are comparing the MQ Put time to CURRENT_TIMESTAMP...
Any particular reason you're not using CURRENT_GMTTIMESTAMP?

Please check if a call to CURRENT_GMTTIMESTAMP would provide the results you're expecting...


It made no difference, CURRENT_GMTTIMESTAMP is shifted by 5 hours from CURRENT_TIMESTAMP but with the same seconds and milliseconds.

Thank you, anyway, for your attention.

-JG

I suppose your servers all subscribe to an nts service. Do they all subscribe to the same nts server and what is the allowed drift ?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
tczielke
PostPosted: Sun Feb 24, 2019 4:19 am    Post subject: Re: MQMD.PutTime is ahead of CURRENT_TIMESTAMP Reply with quote

Guardian

Joined: 08 Jul 2010
Posts: 939
Location: Illinois, USA

juandelcid wrote:
bruce2359 wrote:
juandelcid wrote:
As you can see, MQMD.PutTime is ahead by a little (0.05 seconds, on average).

Does anybody know how to fix this?

Your app makes two calls, one after the other, MQPUT and gettime, These calls will not occur at the same precise instance in time. Nothing to fix here.

Is your concern about the differences you cite as ‘on average?’


Thanks for your reply. My problem is not with variation... it has to do with the expectation that a message has been put on a queue (MQMD.PutTime), presumably earlier than when it is being processed (CURRENT_TIMESTAMP). Would you agree?

What I need to know is how long the message has been waiting on the queue before it was taken by my flow and processed. That's the ultimate goal... and right now I'm getting negative duration. This is what I need to fix.

I understand that MQMD.PutTime has a precision of 0.01 seconds (one hundredth of a second), that's not the problem. So long MQMD.PutTime registers before CURRENT_TIMESTAMP I'll be content.


Just a few things to be aware of when you try to work with time at the microsecond level on the x86 processors (which I assume you are using here with Windows). This explanation is more based on what I have researched on Linux x86, but it probably applies to Windows x86, as well.

Linux can usally measure time accurately down to the millisecond level. This has to do with how often the system timer is firing and interupting the kernel. When you need to get time at the microsecond level, what is usually happening is a TSC register is being accessed. When working on a computer with multiple CPUs, it is possible for TSC registers on different CPUs to be slightly off. I personally feel I have observed this by running some MQ API exit tests on a Linux x86 processors with multiple CPUs.

I am not saying you can't write code to track things like MQ calls at the microsecond level on a x86 processor with multiple CPUs. However, when I do write this type of code, I prepare myself for the possibility that I might get a negative time interval. It doesn't mean your computer has entered a time warp, just that this type of architecture isn't always consistent at measuring time at that granular of a level.
_________________
Working with MQ since 2010.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » MQMD.PutTime is ahead of CURRENT_TIMESTAMP
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.