そのため、Choice Flow Control を使用して、データベースのフィールドに基づいて請求書をルーティングしようとしています。これはコレクション アグリゲーターを使用しなくても問題なく機能しますが、アグリゲーターを使用してトランザクションを 1 つの電子メールにグループ化したいと考えています。ただし、コレクション アグリゲーターを追加すると、ルーティングがすべて混乱します。たとえば、前回のテスト実行では、LHF_INVOICE_METHOD='INACTV' および IS_ZERO_OR_NEGATIVE='1' の請求書が「Trucking」にルーティングされました (コレクションの集計なしで「非アクティブ」に正しくルーティングされます)。コレクションアグリゲーターがルートを互いに交差させていると思います。MULE_CORRELATION_ID をセットアップして LHF_INVOICE_METHOD と IS_ZERO_OR_NEGATIVE を含め、コレクション アグリゲーターが独自の相関 ID を持つようにします。
<flow name="InvoiceWorkflow" doc:name="InvoiceWorkflow" processingStrategy= "synchronous">
<jdbc:inbound-endpoint queryKey="GetUnprocessedInvoices" queryTimeout="10000" pollingFrequency= "1000" connector-ref ="Database" doc:name="Get invoice run" >
<jdbc:query key="GetUnprocessedInvoices" value="SELECT COMPANY_CODE, DIVISION, INVOICE_NUMBER, LHF_INVOICE_METHOD, STATUS_FLAG, SYSTEM_DATE, USERNAME, RUN_NUMBER, ROWID, IS_ZERO_OR_NEGATIVE, LHF_INVOICE_METHOD || RUN_NUMBER || IS_ZERO_OR_NEGATIVE AS CORRELATION_ID, LHF_INVOICE_METHOD || RUN_NUMBER || IS_ZERO_OR_NEGATIVE || '2' AS CORRELATION_ID_2 FROM FIN.LHF_INVOICE_WORKFLOW WHERE (STATUS_FLAG = 'N')"/>
</jdbc:inbound-endpoint>
<jdbc:outbound-endpoint exchange-pattern="one-way" queryKey="insert_invoice_run" queryTimeout= "10000" connector-ref="SPTSQL01_APPS_custom_app_data" doc:name= "Load to custom_app_data">
<jdbc:query key="insert_invoice_run" value="INSERT INTO lhf_ros_invoice_workflow ([COMPANY_CODE] ,[DIVISION] ,[INVOICE_NUMBER] ,[LHF_INVOICE_METHOD] ,[STATUS_FLAG] ,[SYSTEM_DATE] ,[USERNAME] ,[RUN_NUMBER] ,[IS_ZERO_OR_NEGATIVE]) VALUES (#[map-payload:COMPANY_CODE] ,#[map-payload:DIVISION] ,#[map-payload:INVOICE_NUMBER] ,#[map-payload:LHF_INVOICE_METHOD], #[map-payload:STATUS_FLAG] ,#[map-payload:SYSTEM_DATE] ,#[map-payload:USERNAME] ,#[map-payload:RUN_NUMBER] ,#[map-payload:IS_ZERO_OR_NEGATIVE])"/>
</jdbc:outbound-endpoint>
<jdbc:outbound-endpoint exchange-pattern="one-way" queryKey="MarkAsProcessed" queryTimeout= "10000" connector-ref="DatabaseMuleLogin" doc:name= "Mark Processed in Ross" >
<jdbc:query key="MarkAsProcessed" value="UPDATE FIN.LHF_INVOICE_WORKFLOW SET STATUS_FLAG = 'P' WHERE (ROWID = #[map-payload:ROWID])"/>
</jdbc:outbound-endpoint>
<message-properties-transformer doc:name="Message Properties">
<add-message-property key="MULE_CORRELATION_GROUP_SIZE" value="1000"/>
<add-message-property key="MULE_CORRELATION_ID" value="#[message.payload.CORRELATION_ID]"/>
</message-properties-transformer>
<choice doc:name="Choice" >
<when expression="#[message.payload.LHF_INVOICE_METHOD == 'INACTV']">
<processor-chain>
<collection-aggregator failOnTimeout="false" doc:name="Inactive" timeout="2000"/>
<smtp:outbound-endpoint responseTimeout="10000" doc:name="Inactive" from="muleservice@example.com" subject="[Invoice Workflow] Inactive 1" to="ben@example.com" host="mail.example.com"/>
<jdbc:outbound-endpoint exchange-pattern="one-way" queryKey="MARK_COMPLETE" queryTimeout="-1" connector-ref="SPTSQL01_APPS_custom_app_data" doc:name="Mark Complete"/>
</processor-chain>
</when>
<when expression="#[message.payload.IS_ZERO_OR_NEGATIVE=='1']">
<processor-chain>
<collection-aggregator timeout="3000" failOnTimeout="false" doc:name="Zero"/>
<smtp:outbound-endpoint to= "ben@example.com" from="muleservice@example.com" subject="[Invoice Workflow] Zero Dollar " responseTimeout= "10000" doc:name="Zero Dollar" host="mail.example.com"/>
<jdbc:outbound-endpoint exchange-pattern="one-way" queryKey="MARK_COMPLETE" queryTimeout="-1" connector-ref="SPTSQL01_APPS_custom_app_data" doc:name="Mark Complete"/>
</processor-chain>
</when>
<when expression="#[message.payload.LHF_INVOICE_METHOD=='TRUCK']">
<processor-chain>
<collection-aggregator timeout="4000" failOnTimeout="false" doc:name="Truck"/>
<smtp:outbound-endpoint to= "ben@example.com" from="muleservice@example.com" subject="[Invoice Workflow] Trucking" responseTimeout= "10000" doc:name="Trucking" host="mail.example.com"/>
<jdbc:outbound-endpoint exchange-pattern="one-way" queryKey="MARK_COMPLETE" queryTimeout="-1" connector-ref="SPTSQL01_APPS_custom_app_data" doc:name="Mark Complete"/>
</processor-chain>
</when>
<otherwise>
<processor-chain>
<smtp:outbound-endpoint host="mail.example.com" to="ben@example.com" from="muleservice@example.com" subject="[Invoice Workflow] RSForms Email" responseTimeout="10000" doc:name="RSForms"/>
<message-properties-transformer overwrite="true" doc:name="Message Properties">
<add-message-property key="MULE_CORRELATION_ID" value="#[message.payload.CORRELATION_ID_2]"/>
</message-properties-transformer>
<choice doc:name="Choice">
<when expression="#[message.payload.LHF_INVOICE_METHOD == 'SPEC']">
<processor-chain>
<collection-aggregator timeout="5000" failOnTimeout="false" doc:name="Special"/>
<smtp:outbound-endpoint host="mail.example.com" to="ben@example.com" from="muleservice@example.com" subject="[Invoice Workflow] Special Handling" responseTimeout="10000" doc:name="Special"/>
<jdbc:outbound-endpoint exchange-pattern="one-way" queryKey="MARK_COMPLETE" queryTimeout="-1" connector-ref="SPTSQL01_APPS_custom_app_data" doc:name="Mark Complete"/>
</processor-chain>
</when>
<when expression="#[message.payload.LHF_INVOICE_METHOD == 'EMAIL']">
<processor-chain>
<collection-aggregator timeout="6000" failOnTimeout="false" doc:name="Do Nothing"/>
<smtp:outbound-endpoint host="mail.example.com" to="ben@example.com" from="muleservice@example.com" subject="[Invoice Workflow] Do nothing" responseTimeout="10000" doc:name="Do Nothing"/>
<jdbc:outbound-endpoint exchange-pattern="one-way" queryKey="MARK_COMPLETE" queryTimeout="-1" connector-ref="SPTSQL01_APPS_custom_app_data" doc:name="Mark Complete"/>
</processor-chain>
</when>
<when expression="#[message.payload.LHF_INVOICE_METHOD == 'MAILUS']">
<processor-chain>
<collection-aggregator timeout="7000" failOnTimeout="false" doc:name="US Mail"/>
<smtp:outbound-endpoint host="mail.example.com" to="ben@example.com" from="muleservice@example.com" subject="[Invoice Workflow] US Mail" responseTimeout="10000" doc:name="US Mail"/>
<jdbc:outbound-endpoint exchange-pattern="one-way" queryKey="MARK_COMPLETE" queryTimeout="-1" connector-ref="SPTSQL01_APPS_custom_app_data" doc:name="Mark Complete"/>
</processor-chain>
</when>
<when expression="#[message.payload.LHF_INVOICE_METHOD == 'MAILCN']">
<processor-chain>
<collection-aggregator timeout="8000" failOnTimeout="false" doc:name="Intl Mail"/>
<smtp:outbound-endpoint host="mail.example.com" to="ben@example.com" from="muleservice@example.com" subject="[Invoice Workflow] Intl Mail" responseTimeout="10000" doc:name="Intl Mail"/>
<jdbc:outbound-endpoint exchange-pattern="one-way" queryKey="MARK_COMPLETE" queryTimeout="-1" connector-ref="SPTSQL01_APPS_custom_app_data" doc:name="Mark Complete"/>
</processor-chain>
</when>
<when expression="#[message.payload.LHF_INVOICE_METHOD == 'EDI']">
<processor-chain>
<collection-aggregator timeout="9000" failOnTimeout="false" doc:name="EDI"/>
<smtp:outbound-endpoint host="mail.example.com" to="ben@example.com" from="muleservice@example.com" subject="[Invoice Workflow] EDI" responseTimeout="10000" doc:name="EDI"/>
<jdbc:outbound-endpoint exchange-pattern="one-way" queryKey="MARK_COMPLETE" queryTimeout="-1" connector-ref="SPTSQL01_APPS_custom_app_data" doc:name="Mark Complete"/>
</processor-chain>
</when>
<otherwise>
<processor-chain>
<collection-aggregator timeout="10000" failOnTimeout="false" doc:name="Exceptions"/>
<smtp:outbound-endpoint host="mail.example.com" to="ben@example.com" from="muleservice@example.com" subject="[Invoice Workflow] Exceptions" responseTimeout="10000" doc:name="Exceptions"/>
<jdbc:outbound-endpoint exchange-pattern="one-way" queryKey="MARK_COMPLETE" queryTimeout="-1" connector-ref="SPTSQL01_APPS_custom_app_data" doc:name="Mark Complete"/>
</processor-chain>
</otherwise>
</choice>
</processor-chain>
</otherwise>
</choice>
</flow >
アグリゲーターの前に各 WHEN ブランチの後にロガーを追加し、トランザクションはアグリゲーションの前に適切なブランチに移動しました。Mule Correlation ID が各アグリゲータに固有であることがわかる限り、これが実際のデータです。何が起こったのか、私が予想したこととともに送信された実際のデータを次に示します。
BEFORE 集計 (すべて正しい)
ロガー非アクティブ
{INVOICE_NUMBER=408908、SYSTEM_DATE=2012-12-19 16:36:50.0、DIVISION=1、LHF_INVOICE_METHOD=INACTV、RUN_NUMBER=4862651810、ROWID=oracle.sql.ROWID@5a72f4f7、COMPANY_CODE=1、STATUS_FLAG=N、USERNAME= BBRYAN、CORRELATION_ID=INACTV48626518101、CORRELATION_ID_2=INACTV486265181012、IS_ZERO_OR_NEGATIVE=1}
{INVOICE_NUMBER=406749、SYSTEM_DATE=2012-12-19 16:36:50.0、DIVISION=1、LHF_INVOICE_METHOD=INACTV、RUN_NUMBER=4862651810、ROWID=oracle.sql.ROWID@c0a628c、COMPANY_CODE=1、STATUS_FLAG=N、USERNAME= BBRYAN、CORRELATION_ID=INACTV48626518101、CORRELATION_ID_2=INACTV486265181012、IS_ZERO_OR_NEGATIVE=1}
{INVOICE_NUMBER=408691、SYSTEM_DATE=2012-12-19 16:36:50.0、DIVISION=1、LHF_INVOICE_METHOD=INACTV、RUN_NUMBER=4862651810、ROWID=oracle.sql.ROWID@42652ecc、COMPANY_CODE=1、STATUS_FLAG=N、USERNAME= BBRYAN、CORRELATION_ID=INACTV48626518100、CORRELATION_ID_2=INACTV486265181002、IS_ZERO_OR_NEGATIVE=0}
ゼロまたは負のロガー
{INVOICE_NUMBER=409061、SYSTEM_DATE=2012-12-19 16:36:50.0、DIVISION=1、LHF_INVOICE_METHOD=MAILUS、RUN_NUMBER=4862651810、ROWID=oracle.sql.ROWID@7933b36f、COMPANY_CODE=1、STATUS_FLAG=N、USERNAME= BBRYAN、CORRELATION_ID=MAILUS48626518101、CORRELATION_ID_2=MAILUS486265181012、IS_ZERO_OR_NEGATIVE=1}
{INVOICE_NUMBER=410968、SYSTEM_DATE=2012-12-19 16:36:50.0、DIVISION=1、LHF_INVOICE_METHOD=EDI、RUN_NUMBER=4862651810、ROWID=oracle.sql.ROWID@7a9b36be、COMPANY_CODE=1、STATUS_FLAG=N、USERNAME= BBRYAN、CORRELATION_ID=EDI48626518101、CORRELATION_ID_2=EDI486265181012、IS_ZERO_OR_NEGATIVE=1}
集計後
非アクティブ 1: (これらの 2 つは正しいルートに行きました)
[{INVOICE_NUMBER=408908、SYSTEM_DATE=2012-12-19 16:36:50.0、DIVISION=1、LHF_INVOICE_METHOD=INACTV、RUN_NUMBER=4862651810、ROWID=oracle.sql.ROWID@5a72f4f7、COMPANY_CODE=1、STATUS_FLAG=N、ユーザー名=BBRYAN、CORRELATION_ID=INACTV48626518101、CORRELATION_ID_2=INACTV486265181012、IS_ZERO_OR_NEGATIVE=1}、
{INVOICE_NUMBER=406749、SYSTEM_DATE=2012-12-19 16:36:50.0、DIVISION=1、LHF_INVOICE_METHOD=INACTV、RUN_NUMBER=4862651810、ROWID=oracle.sql.ROWID@c0a628c、COMPANY_CODE=1、STATUS_FLAG=N、USERNAME= BBRYAN、CORRELATION_ID=INACTV48626518101、CORRELATION_ID_2=INACTV486265181012、IS_ZERO_OR_NEGATIVE=1}]
ゼロドル: (これは正しい)
[{INVOICE_NUMBER=409061、SYSTEM_DATE=2012-12-19 16:36:50.0、DIVISION=1、LHF_INVOICE_METHOD=MAILUS、RUN_NUMBER=4862651810、ROWID=oracle.sql.ROWID@7933b36f、COMPANY_CODE=1、STATUS_FLAG=N、ユーザー名=BBRYAN、CORRELATION_ID=MAILUS48626518101、CORRELATION_ID_2=MAILUS486265181012、IS_ZERO_OR_NEGATIVE=1}]
トラック輸送: (これはゼロドルに行くべきだった)
[{INVOICE_NUMBER=410968、SYSTEM_DATE=2012-12-19 16:36:50.0、DIVISION=1、LHF_INVOICE_METHOD=EDI、RUN_NUMBER=4862651810、ROWID=oracle.sql.ROWID@7a9b36be、COMPANY_CODE=1、STATUS_FLAG=N、ユーザー名=BBRYAN、CORRELATION_ID=EDI48626518101、CORRELATION_ID_2=EDI486265181012、IS_ZERO_OR_NEGATIVE=1}]
特別な取り扱い: (「非アクティブ 1」に移動する必要があります)
[{INVOICE_NUMBER=408691、SYSTEM_DATE=2012-12-19 16:36:50.0、DIVISION=1、LHF_INVOICE_METHOD=INACTV、RUN_NUMBER=4862651810、ROWID=oracle.sql.ROWID@42652ecc、COMPANY_CODE=1、STATUS_FLAG=N、ユーザー名=BBRYAN、CORRELATION_ID=INACTV48626518100、CORRELATION_ID_2=INACTV486265181002、IS_ZERO_OR_NEGATIVE=0}]