---
schema_version: "1"
id: c43fc0bc0572836c3e4ba7ddc230a77f75bb5b2df4bd0ed27fd1dba0aa6729e3
title: スケジューラーエンドポイント (トリガー)
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/mule-runtime/4.3/scheduler-concept.md
canonical_url: https://docs.mulesoft.com/jp/mule-runtime/4.3/scheduler-concept
source_site: docs.mulesoft.com
content_type: documentation
content_hash: ecd18a57fc93d71ee7545653527c9a894f40a002aa5f6aa6f22da708f91e0f5b
description: MuleSoft Documentation Site
release: "4.3"
latest: false
---
# スケジューラーエンドポイント (トリガー)

Scheduler コンポーネントは、時間ベースの条件が成立した時点でフローをトリガーします。Scheduler は、一定間隔でトリガーするように設定したり、より柔軟な Cron 式を使用して設定したりすることができます。たとえば、フローを開始するイベントを 5 秒おきにトリガーするように Scheduler を設定できます。

Mule アプリケーションに Scheduler を実装するときは次の点を考慮してください。

- Scheduler は、Mule が動作しているマシンと同じタイムゾーンを使用します。ただし、アプリケーションが CloudHub で動作している場合は、アプリケーションが動作している地理的リージョンに関係なく、Scheduler は UTC タイムゾーンに準拠します。
- `disallowConcurrentExecution`​ プロパティを使用すると、フローの処理が終了するまで Scheduler でそのフローを再トリガーできないようにすることができます。​[「<scheduler> プロパティ」](https://docs.mulesoft.com/jp/mule-runtime/4.3/scheduler-xml-reference#scheduler-properties)​を参照してください。
- スケジュールされたトリガー時に利用できるリソースが 1 つもないために ​[back-pressure](https://docs.mulesoft.com/jp/mule-runtime/4.3/execution-engine#backpressure)​ が発生した場合、そのトリガーはスキップされます。
- Mule Runtime Engine クラスターやマルチワーカー CloudHub デプロイメントでは、Scheduler はプライマリノードのみで (つまり 1 つの Mule インスタンスのみで) 実行 (フローがトリガー) されます。

## [](#サンプルプロジェクト)サンプルプロジェクト

Anypoint Exchange には、Anypoint Studio で開いて Scheduler コンポーネントの詳細を見るためのサンプルプロジェクトがいくつかあります。

- _Data Sync Using Watermarking and Batch (ウォーターマークとバッチを使用したデータの同期)_
- _Import Contacts into Microsoft Dynamics CRM (Microsoft Dynamics CRM への取引先責任者のインポート)_
- _Import Leads into Salesforce (Salesforce へのリードのインポート)_
- _Importing a CSV File into mongoDB (mongoDB への CSV ファイルのインポート)_
- _Importing an Email Attachment Using the IMAP Connector (IMAP Connector を使用したメールの添付ファイルのインポート)_
- _Salesforce to MySQL Database Using Batch Processing (バッチ処理を使用した Salesforce から MySQL データベースへのインポート)_
- _Sending a CSV File Through Email Using SMTP (SMTP を使用したメールでの CSV ファイルの送信)_

Anypoint Studio でサンプルプロジェクトをダウンロードして開くには、左上隅にある Exchange アイコンをクリックします。次に、開いたウィンドウで、Anypoint Exchange にログインし、プロジェクトの名前を検索します。

## [](#一定間隔)一定間隔

次のパラメーターを使用して、Scheduler がフローを一定間隔でトリガーするように設定できます。

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 25%;">
<col style="width: 50%;">
<col style="width: 25%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">属性</th>
<th class="tableblock halign-left valign-top">説明</th>
<th class="tableblock halign-left valign-top">デフォルト</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Frequency (頻度)</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">Scheduler がフローをトリガーする頻度。単位は ​<strong>Time unit (時間単位)</strong>​ 項目で選択できます。値を ​<code>0</code>​ または負の値を指定すると、デフォルト値が使用されます。</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">1000</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Start Delay (開始遅延)</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">アプリケーションが起動してからフローを最初にトリガーするまで待つ時間。値は、頻度と同じ時間単位で表されます。</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">0</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Time Unit (時間単位)</strong></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><strong>Frequency (頻度)</strong>​ と ​<strong>Start Delay (開始遅延)</strong>​ の値の時間単位。可能な値:</p>
<p class="tableblock">MILLISECONDS (ミリ秒)、SECONDS (秒)、MINUTES (分)、HOURS (時)、DAYS (日)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">MILLISECONDS</p></td>
</tr>
</tbody>
</table>

## [](#cron-式)Cron 式

Cron は、日時情報を記述するのに広く利用されている標準です。

Scheduler は、毎秒を監視し、Quartz Cron 式が日時の設定と一致すると Mule イベントを作成します。イベントは 1 回だけ、または一定間隔でトリガーできます。

日時の式は、6 つの必須設定と、年の設定 (省略可能) で構成されます。設定は以下の順序で指定します。

1. 秒 (0-59)
2. 分 (0-59)
3. 時 (0-23)
4. 日 (1-31)
5. 月 (1-12 または JAN-DEC)
6. 曜日 (1-7 または SUN-SAT)
7. 年 (空白、または 1970-2099 の範囲内の 4 桁。例: 2019)

Scheduler は Quartz Cron 式をサポートします。例をいくつか示します。

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 50%;">
<col style="width: 50%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">式</th>
<th class="tableblock halign-left valign-top">動作</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>1/2 * * * * ?</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">毎日 2 秒おきに実行。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0 15 10 ? * *</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">毎日午前 10 時 15 分に実行。  <code>0 15 10 * * ? <strong></strong></code><strong>​</strong>` と <code>​0 15 10 *​`0 15 10 * * ?</code>​ は同じ結果になります。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0 15 10 * * ? 2019</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">2019 年の毎日午前 10 時 15 分に実行。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0 * 14 * * ?</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">毎日午後 2 時から 2 時 59 分まで、毎分実行。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>0 0/5 14 * * ?</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">毎日午後 2 時から 2 時 55 分まで、5 分おきに実行。</p></td>
</tr>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>1 1 1 1,7 * ?</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">毎月 1 日と 7 日の午前 1 時 1 分 1 秒に実行。</p></td>
</tr>
</tbody>
</table>

Scheduler コンポーネントは、Quartz Scheduler の特殊も時もサポートします。

- `*`​: すべての値。
- `?`​: 任意の 1 つの値。
- `-`​: 値の範囲。例: `1-3`​。
- `,`​: 追加の値。例: `1,7`​。
- `/`​: 増分値。例: `1/7`​。
- `L`​: 週または月の最終日、または月の最後の特定の曜日 (例: `6L`​ は月の最後の土曜日)。
- `W`​: 平日。日付項目で有効で、特定の日付以降になります。例: `15W`​ はその月の 15 日に最も近い平日を表します。
- `#`​: 月の n 日目。例: `#3`​ は月の 3 日。

詳細は、 [「CronExpression」](https://www.quartz-scheduler.org/api/2.3.0/org/quartz/CronExpression.html)​を参照してください。

次の例は、「hello」というメッセージを毎秒ログに記録します。

```XML
<flow name="cronFlow" doc:id="ae257a5d-6b4f-4006-80c8-e7c76d2f67a0" >
  <scheduler doc:name="Scheduler" doc:id="e7b68ccb-c6d8-4567-87af-aa7904a50359" >
    <scheduling-strategy >
      <cron expression="* * * * * ?" timeZone="America/Los_Angeles"/>
    </scheduling-strategy>
  </scheduler>
  <logger level="INFO" doc:name="Logger" doc:id="e2626dbb-54a9-4791-8ffa-b7c9a23e88a1" message='"hello"'/>
</flow>
```

Cron 式をビルドするための無料のオンラインツールがたくさんあります。

### [](#タイムゾーン-timezone)タイムゾーン (timeZone)

Cron 式では Java の ​`timeZone`​ 値がサポートされます。Java の短縮表記 (​`PST`​ や ​`AGT`​) は使用せず、Java の完全表記 (​`America/Los_Angeles`​ や ​`America/Argentina/Buenos_Aires`​) を使用してください。

## [](#デバッグ)デバッグ

Studio の ​**\[Debug Mode (デバッグモード)\]**​ ビューでは、Mule アプリケーションはイベントをトリガーできません。その代わりに、デバッグ時には Scheduler コンポーネントの下に表示される緑色の矢印アイコンをクリックすることで Scheduler を実行できます。

## [](#関連情報)関連情報

- [Scheduler XML リファレンス](https://docs.mulesoft.com/jp/mule-runtime/4.3/scheduler-xml-reference)