Monday, April 26, 2010

Specifying date time and duration in BPEL and understanding its impact in WAIT activity

To get much idea on date and time format i recommend you to refer to this link.

http://www.w3.org/TR/NOTE-datetime

Here we will discuss about one of the very important activity in BPEL ,that is WAIT ativity.In Wait activity we have got two option one is the time duration and other is the timeperiod.

They are represented by two different character.IF you will have a look in the wait activity you may get their are two options for specifying time



One option if for and the other option is until so we will here try to understand what these two block mean

The first is FOR which denotes the time duration for which the thread has to wait

In BPEL the Time durations are specified in the format:
PnYnMnDTnHnMnS
where,
P - is a required character that represents period, the duration designator. All duration expressions always start with a P
Y - is the year designator. For example, to indicate 10 years, you'd use10Y
M - is the month designator. For example, to indicate 10 years, you'd use10M
D - is the days designator. For example, to indicate 10 days, you'd use 10D
T - is an optional character that indicates the start of the time duration
H - is the hour designator. For example, to indicate 10 hours, you'd use10H
M - is the minute designator. For example, to indicate 10 minutes, you'd use 10M
S - is the seconds designator. For example, to indicate 10 seconds, you'd use 10S

So if you have to specify a duration of 10 years, 05 months, 12 days, 08 hours, 37 minutes, and 46 seconds, the duration expression would look like P10Y05M12DT08H37M46S. If you want to use it in a BPEL activity, it would read:

which means wait for a duration of 19 years, 10 months, 28 days, 10 hours, 37 minutes, and 46 seconds.





Now if you will check for the entry in your source code you will find an entry like

<wait name="Wait_activity" for="P10Y05M12DT08H37M46S"/>

Again we have one more Option that is Until,here it is not time duration it is the time period at which the process has to activate.

So it means be passive until the right time comes.

IT takes the date time format

Specific date and time references have the form:
CCYY-MM-DDThh:mm:ss
where,
CC - is the century designator, specified as 2 or more digits. Valid range from 00 to ...
YY - is the year designator, specified as 2 digits. Valid range from 00 to 99.
MM - is the month designator, specified as 2 digits. Valid range from 01 to 12.
DD - is the day designator, specified as 2 digits. Valid range from 01 to 31.
T - indicates the start of the time designator.
hh - is the hour designator, specified as 2 digits. Valid range from 00 to 23.
mm - is the minute designator, specified as 2 digits. Valid range from 00 to 59.
ss - is the seconds designator, specified as 2 digits with an optional decimal value allowed of the form ss.ssss to increase precision. Valid range from 00 to 59.
z - is the optional Coordinated Universal Time (UTC). If present, it should immediately follow the time element. To specify an offset from the UTC time, append a positive(+) or negative(-) time to the datetime value of the form hh:mm.


So, to specify 07:40:19pm, 26th April 2010, the datetime expression would look like 2010-04-26T19:40:19.

If you want to use it in a BPEL WAIT activity, it would read:
<wait name="Wait_activity" until="2010-04-26T19:40:19"/>
which means wait until the deadline 07:40:19pm, 26th April 2010

UTC datetime samples:
Similarly, to specify 10:28:19am in UTC, the datetime expression would look like 10:28:19z. If you want to use it in a BPEL WAIT activity, it would read:

which means wait until the deadline 10:28:19am, in UTC.

So based on these information can we try some experiment on dynamically setting up a wait activity ;)

No comments: