共用方式為


TimerTrigger Interface

public interface TimerTrigger

TimerTrigger(name = "keepAliveTrigger", schedule = "0 */5 * * * *") String timerInfo, ExecutionContext context ) { // timeInfo is a JSON string, you can deserialize it to an object using your favorite JSON library context.getLogger().info("Timer is triggered: " + timerInfo); }

Method Summary

Modifier and Type Method and Description
String dataType()

Defines how Functions runtime should treat the parameter value. Possible values are:

    <li>
    
      <p>"": get the value as a string, and try to deserialize to actual parameter type like POJO </p>
    
    </li>
    
    <li>
    
      <p>string: always get the value as a string </p>
    
    </li>
    
    <li>
    
      <p>binary: get the value as a binary data, and try to deserialize to actual parameter type byte[] </p>
    
    </li>
    

String name()

The name of the variable that represents the timer object in function code.

String schedule()

A CRON expression in the format {minute} {hour} {day} {month} {day-of-week} 

</code> .</p>

<caption>A table showing some examples of CRON expressions that could be used.</caption>

<row>

  <entry thead="yes">

    <p>Goal </p>

  </entry>

  <entry thead="yes">

    <p>CRON Expression  </p>

  </entry>

</row>

<row>

  <entry thead="no">

    <p>To trigger once every five minutes: </p>

  </entry>

  <entry thead="no">

    <p>0 *&amp;#47;5 * * * *  </p>

  </entry>

</row>

<row>

  <entry thead="no">

    <p>To trigger once at the top of every hour: </p>

  </entry>

  <entry thead="no">

    <p>0 0 * * * *  </p>

  </entry>

</row>

<row>

  <entry thead="no">

    <p>To trigger once every two hours: </p>

  </entry>

  <entry thead="no">

    <p>0 0 *&amp;#47;2 * * *  </p>

  </entry>

</row>

<row>

  <entry thead="no">

    <p>To trigger once every hour from 9 AM to 5 PM: </p>

  </entry>

  <entry thead="no">

    <p>0 0 9-17 * * *  </p>

  </entry>

</row>

<row>

  <entry thead="no">

    <p>To trigger at 9:30 AM every day: </p>

  </entry>

  <entry thead="no">

    <p>0 30 9 * * *  </p>

  </entry>

</row>

<row>

  <entry thead="no">

    <p>To trigger at 9:30 AM every weekday: </p>

  </entry>

  <entry thead="no">

    <p>0 30 9 * * 1-5  </p>

  </entry>

</row>

Method Details

dataType

public String dataType() default ""

Defines how Functions runtime should treat the parameter value. Possible values are:

    <li>
    
      <p>"": get the value as a string, and try to deserialize to actual parameter type like POJO </p>
    
    </li>
    
    <li>
    
      <p>string: always get the value as a string </p>
    
    </li>
    
    <li>
    
      <p>binary: get the value as a binary data, and try to deserialize to actual parameter type byte[] </p>
    
    </li>
    

Returns:

The dataType which will be used by the Functions runtime.

name

public String name()

The name of the variable that represents the timer object in function code.

Returns:

The name of the variable that represents the timer object in function code.

schedule

public String schedule()

A CRON expression in the format {minute} {hour} {day} {month} {day-of-week} 

</code> .</p>

<caption>A table showing some examples of CRON expressions that could be used.</caption>

<row>

  <entry thead="yes">

    <p>Goal </p>

  </entry>

  <entry thead="yes">

    <p>CRON Expression  </p>

  </entry>

</row>

<row>

  <entry thead="no">

    <p>To trigger once every five minutes: </p>

  </entry>

  <entry thead="no">

    <p>0 *&amp;#47;5 * * * *  </p>

  </entry>

</row>

<row>

  <entry thead="no">

    <p>To trigger once at the top of every hour: </p>

  </entry>

  <entry thead="no">

    <p>0 0 * * * *  </p>

  </entry>

</row>

<row>

  <entry thead="no">

    <p>To trigger once every two hours: </p>

  </entry>

  <entry thead="no">

    <p>0 0 *&amp;#47;2 * * *  </p>

  </entry>

</row>

<row>

  <entry thead="no">

    <p>To trigger once every hour from 9 AM to 5 PM: </p>

  </entry>

  <entry thead="no">

    <p>0 0 9-17 * * *  </p>

  </entry>

</row>

<row>

  <entry thead="no">

    <p>To trigger at 9:30 AM every day: </p>

  </entry>

  <entry thead="no">

    <p>0 30 9 * * *  </p>

  </entry>

</row>

<row>

  <entry thead="no">

    <p>To trigger at 9:30 AM every weekday: </p>

  </entry>

  <entry thead="no">

    <p>0 30 9 * * 1-5  </p>

  </entry>

</row>

Returns:

A string representing a CRON expression that will be used to schedule a function to run.

Applies to