Flex Gateway新着情報
Governance新着情報
Monitoring API Manager次のような場合は、特定のスコープまたは一連の操作でイベントの相関 ID を変更することが必要になることがあります。
For Each スコープ内でデータベースクエリの結果を処理しており、イベントを、処理中のレジスターと相関する必要がある。
JMS メッセージキューをコンシュームしており、トレーサビリティの目的で JMS 相関 ID を使用して続行する必要がある。
これらのシナリオでは、Tracing Module With CorrelationID スコープを使用して、そのスコープの実行中に相関 ID を変更することができます。
次の Mule アプリケーションの例では、Studio で With CorrelationID スコープを設定します。
Studio の [Mule Palette (Mule パレット)] ビューで、[HTTP] > [Listener] を選択します。
[Listener] を Studio キャンバスにドラッグします。
[Path (パス)] を /test
に設定します。
[Connector configuration (コネクタ設定)] 項目の横にあるプラス記号 (+) をクリックして、アプリケーション内のすべてのソースのインスタンスで使用できるグローバル要素を設定します。
HTTP リスナーのグローバル要素を設定して、[OK] をクリックします。
[Set Payload] コンポーネントを [HTTP] の [Listener] の右にドラッグします。
[Value (値)] を「some
」に設定します。
Studio の [Mule Palette (Mule パレット)] ビューで、[Logger] を選択します。
[Logger] を [Set Payload] の右にドラッグします。
[Message (メッセージ)] を #[payload]
に設定します。
[Level (レベル)] を WARN
に設定します。
[With CorrelationID] スコープを Studio キャンバスにドラッグします。
[Correlation id (相関 ID)] を #[correlationId ++ '-EXAMPLE']
に設定します。
別の [Logger] コンポーネントを [With CorrelationID] スコープにドラッグします。
[Message (メッセージ)] を #[payload]
に設定します。
[Level (レベル)] を WARN
に設定します。
Mule アプリケーションを保存して実行します。
コマンドラインで curl localhost:8081/test
を実行して、アプリケーションをテストします。
アプリケーションの出力ログは次のようになります。
WARN 2021-03-30 16:46:11,269 [[MuleRuntime].uber.05: [test-project-app].example.CPU_LITE @6d3b5ad] [processor: example/processors/1; event: bad0e5b0-9191-11eb-a0b3-36548d51aeee] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: some WARN 2021-03-30 16:46:11,271 [[MuleRuntime].uber.05: [test-project-app].example.CPU_LITE @6d3b5ad] [processor: example/processors/2/processors/0; event: bad0e5b0-9191-11eb-a0b3-36548d51aeee-EXAMPLE] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: some WARN 2021-03-30 16:46:11,274 [[MuleRuntime].uber.05: [test-project-app].example.CPU_LITE @6d3b5ad] [processor: example/processors/3; event: bad0e5b0-9191-11eb-a0b3-36548d51aeee] org.mule.runtime.core.internal.processor.LoggerMessageProcessor: some
xml
この例のフローをすばやく Mule アプリケーションに読み込むには、次のコードを Studio XML エディターに貼り付けます。
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:tracing="http://www.mulesoft.org/schema/mule/tracing"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/tracing http://www.mulesoft.org/schema/mule/tracing/current/mule-tracing.xsd
http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd">
<http:listener-config name="HTTP_Listener_config" >
<http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<flow name="tracingmodule2Flow" >
<http:listener config-ref="HTTP_Listener_config" path="/test"/>
<set-payload value="some" />
<logger level="WARN" message="#[payload]"/>
<tracing:with-correlation-id correlationId="#[correlationId ++ '-EXAMPLE']">
<logger level="WARN" message="#[payload]"/>
</tracing:with-correlation-id>
</flow>
</mule>
xml