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 » Fetching milliseconds from CURRENT_TIMESTAMP

Post new topic  Reply to topic
 Fetching milliseconds from CURRENT_TIMESTAMP « View previous topic :: View next topic » 
Author Message
sleepyjamie
PostPosted: Tue Sep 01, 2015 8:35 am    Post subject: Fetching milliseconds from CURRENT_TIMESTAMP Reply with quote

Centurion

Joined: 29 Apr 2015
Posts: 135

I have a message flow that I want to measure the http response time which will be sent to InfluxDB/Graphana.

Code:
Compute Node->HTTP Request->Trace Node


In my compute node I build the http payload and also
Code:
SET Environment.HTTP_REQUEST_TIMESTAMP = CURRENT_TIMESTAMP


In my trace node I have the following in the pattern

Code:
measurement http_response_time=${CAST ((Environment.HTTP_REQUEST_TIMESTAMP - CURRENT_TIMESTAMP) SECOND as INTEGER)}


Which outputs the follow to my log file:

Code:
measurement http_response_time=0


What I would like is that instead of outputting SECONDS I want it to output milliseconds. For the life of me I cannot find documentation on how to do this.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Tue Sep 01, 2015 8:48 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Think about the CAST.

Lets for argument sake say that the difference in time between the two times is 1.2345 seconds.

Casting that to an integer will give 1

So your value of '0' is probably correct if the elapsed time is less than one second.

So to get the milliseconds I might do something like this.

1) take the time difference in SECONDS and cast to FLOAT
2) Multiply by 1000
3) Cast to INTEGER

so for
1) 0.123456
2) 0.1234 * 1000 = 1234.56
3) Cast to Integer = 1234 milliseconds

I hope this gives you an idea of how to go forward.
[/code]
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
sleepyjamie
PostPosted: Tue Sep 01, 2015 8:53 am    Post subject: Reply with quote

Centurion

Joined: 29 Apr 2015
Posts: 135

Yeah just realized the alternative is to cast as float and multiply by 1000.

I was hoping to extract it as milliseconds however that doesn't work.

6/12

1/2

thanks!
Back to top
View user's profile Send private message
smdavies99
PostPosted: Tue Sep 01, 2015 9:10 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

You may have to use the MOD function
{from memory}

Personaly, I'd do this in ESQL and then print out the result in the trace node.
At least then you can debug the logic.


Yay! Post Number 5000.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Sep 01, 2015 9:22 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

smdavies99 wrote:
Yay! Post Number 5000.


Welcome To The Council
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Tue Sep 01, 2015 9:47 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Vitor wrote:
smdavies99 wrote:
Yay! Post Number 5000.


Welcome To The Council


Thank you kind sir.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
maurito
PostPosted: Wed Sep 02, 2015 1:51 am    Post subject: Reply with quote

Partisan

Joined: 17 Apr 2014
Posts: 358

sleepyjamie wrote:
Yeah just realized the alternative is to cast as float and multiply by 1000.

I was hoping to extract it as milliseconds however that doesn't work.

6/12

1/2

thanks!

save the Environment.HTTP_REQUEST_TIMESTAMP as ss.SSSSS , for example:
Code:

SET Environment.HTTP_REQUEST_TIMESTAMP   = SUBSTRING(CAST(CURRENT_TIMESTAMP AS CHAR FORMAT 'yyyy-MM-dd HH:mm:ss.SSSSSS')
      FROM LENGTH('yyyy-MM-dd HH:mm:.'));

and cast as decimal.
do the same in the trace node, then substract the two values ( in your example above the substruction should be the other way around ! , as the time in the trace node will be greater that the one in the Environment ).

mind you, that is not going to work either... need to consider the case when you change from seconds to minutes, minutes to hours... ignore the suggestion.
so probably you need to do MINUTE TO SECOND, or SECOND, which you are already doing.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Wed Sep 02, 2015 2:57 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

Here is how I did it in an old project.
In a compute node
Code:

      set Environment.DATA.CurTime_1 = CURRENT_TIMESTAMP;
      declare fDiff FLOAT;
      set fDiff = CAST((Environment.DATA.CurTime_1 - Environment.DATA.CurTime_0) SECOND as FLOAT);
      set fDiff = fDiff * 1000.0;
      declare iTime INTEGER;
      set iTime = CAST(fDiff as integer);
      
      set OutputRoot.XMLNSC.Data.T1 = Environment.DATA.CurTime_0;
      set OutputRoot.XMLNSC.Data.T2 = Environment.DATA.CurTime_1;   
      set OutputRoot.XMLNSC.Data.D1 = fDiff;
      set OutputRoot.XMLNSC.Data.I1 = iTime;


Then in the Trace node
Code:

Elapsed time = ${Root.XMLNSC.Data.I1} Milliseconds

With the input data of
Code:

CurTime_0 = TIMESTAMP '2010-04-12 18:52:44.468712' (TIMESTAMP)
CurTime_1 = TIMESTAMP '2010-04-12 18:52:44.854580' (TIMESTAMP)

I got this in the output

Code:

Elapsed time = 385 Milliseconds


Enjoy
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
sleepyjamie
PostPosted: Wed Sep 02, 2015 7:57 am    Post subject: Reply with quote

Centurion

Joined: 29 Apr 2015
Posts: 135

Here is the solution I ended up going with. I didn't want a lot of boilerplate code in compute nodes. Instead I did all the logic to determine milliseconds in the Trace Node.

Code:
measurement http_response_time=${CAST(CAST ((CURRENT_TIMESTAMP - Environment.GCM_HTTP_REQUEST_TIMESTAMP) SECOND as DECIMAL) * 1000 AS INTEGER)}}
Back to top
View user's profile Send private message
smdavies99
PostPosted: Wed Sep 02, 2015 8:08 am    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

You could have put it all in a re-usable subflow. That's where mine is. Ready to use whenever needed.
Ok, I've not had to use it for a couple of years but... You never know when the need would arise again.
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
sleepyjamie
PostPosted: Wed Sep 02, 2015 8:52 am    Post subject: Reply with quote

Centurion

Joined: 29 Apr 2015
Posts: 135

smdavies99 wrote:
You could have put it all in a re-usable subflow. That's where mine is. Ready to use whenever needed.
Ok, I've not had to use it for a couple of years but... You never know when the need would arise again.


Yes that's another option. Thanks!
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 » Fetching milliseconds from 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.