我正在设置流程以将数据从表格拉到另一个表格中,标记已处理的行,并通过电子邮件发送结果。我使用了聚合器(参见: How do I get a Mule to return multiple rows from a JDBC query as a single transaction?)将所有行合并为一封电子邮件,但在添加聚合器后,SMTP端点无法在第二次迭代中运行...
只运行SQL脚本... SMTP端点根本不运行。
<flow name="Invoice_Workflow2Flow1" doc:name="Ross_invoice_Workflow2Flow1" processingStrategy="asynchronous">
<jdbc:inbound-endpoint queryKey="GetUnprocessedInvoices" queryTimeout="10000" pollingFrequency="10000" connector-ref="Database" doc:name="Get invoice run">
<jdbc:query key="GetUnprocessedInvoices" value="SELECT INVOICE_NUMBER, ROWID 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 ([INVOICE_NUMBER] VALUES #[map-payload:INVOICE_NUMBER])"/>
</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="1"/>
</message-properties-transformer>
<collection-aggregator timeout="1000" failOnTimeout="false" doc:name="Collection Aggregator"/>
<smtp:outbound-endpoint host="mail.example.com" to="test@example.com" from="muleservice@example.com" subject="[Invoice Workflow] Exceptions" responseTimeout="10000" doc:name="SMTP"/>
</flow>
如果有用的话会记录下发生的事情......
(首次运行正常,SMTP端点运行)
INFO 2012-12-06 09:08:52,143 [[ross_invoice_workflow] .DatabaseMuleLogin.dispatcher.02] org.mule.transport.jdbc.sqlstrategy.SimpleUpdateSqlStatementStrategy:执行SQL语句:1行更新 INFO 2012-12-06 09:08:52,159 [[ross_invoice_workflow] .DatabaseMuleLogin.dispatcher.03] org.mule.transport.jdbc.sqlstrategy.SimpleUpdateSqlStatementStrategy:执行SQL语句:1行更新 INFO 2012-12-06 09:08:52,180 [[ross_invoice_workflow] .DatabaseMuleLogin.dispatcher.01] org.mule.transport.jdbc.sqlstrategy.SimpleUpdateSqlStatementStrategy:执行SQL语句:1行更新 INFO 2012-12-06 09:08:52,223 [[ross_invoice_workflow] .SPTSQL01_APPS_custom_app_data.dispatcher.01] org.mule.transport.jdbc.sqlstrategy.SimpleUpdateSqlStatementStrategy:执行SQL语句:1行更新 INFO 2012-12-06 09:08:52,223 [[ross_invoice_workflow] .SPTSQL01_APPS_custom_app_data.dispatcher.03] org.mule.transport.jdbc.sqlstrategy.SimpleUpdateSqlStatementStrategy:执行SQL语句:1行更新 INFO 2012-12-06 09:08:52,223 [[ross_invoice_workflow] .SPTSQL01_APPS_custom_app_data.dispatcher.02] org.mule.transport.jdbc.sqlstrategy.SimpleUpdateSqlStatementStrategy:执行SQL语句:1行更新 INFO 2012-12-06 09:08:53,131 [[ross_invoice_workflow] .connector.smtp.mule.default.dispatcher.01] org.mule.transport.service.DefaultTransportServiceDescriptor:加载默认的出站变换器:org.mule。 transport.email.transformers.ObjectToMimeMessage INFO 2012-12-06 09:08:53,138 [[ross_invoice_workflow] .connector.smtp.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager:Initialising:&#39; connector.smtp.mule.default。 dispatcher.1935379626&#39 ;.对象是:SmtpMessageDispatcher INFO 2012-12-06 09:08:53,174 [[ross_invoice_workflow] .connector.smtp.mule.default.dispatcher.01] org.mule.lifecycle.AbstractLifecycleManager:Starting:&#39; connector.smtp.mule.default。 dispatcher.1935379626&#39 ;.对象是:SmtpMessageDispatcher
(插入更多行,SQL端点运行但SMTP不运行...)
INFO 2012-12-06 09:09:22,111 [[ross_invoice_workflow] .DatabaseMuleLogin.dispatcher.03] org.mule.transport.jdbc.sqlstrategy.SimpleUpdateSqlStatementStrategy:执行SQL语句:1行更新 INFO 2012-12-06 09:09:22,129 [[ross_invoice_workflow] .DatabaseMuleLogin.dispatcher.02] org.mule.transport.jdbc.sqlstrategy.SimpleUpdateSqlStatementStrategy:执行SQL语句:1行更新 INFO 2012-12-06 09:09:22,146 [[ross_invoice_workflow] .DatabaseMuleLogin.dispatcher.01] org.mule.transport.jdbc.sqlstrategy.SimpleUpdateSqlStatementStrategy:执行SQL语句:1行更新 INFO 2012-12-06 09:09:22,168 [[ross_invoice_workflow] .SPTSQL01_APPS_custom_app_data.dispatcher.03] org.mule.transport.jdbc.sqlstrategy.SimpleUpdateSqlStatementStrategy:执行SQL语句:1行更新 INFO 2012-12-06 09:09:22,168 [[ross_invoice_workflow] .SPTSQL01_APPS_custom_app_data.dispatcher.01] org.mule.transport.jdbc.sqlstrategy.SimpleUpdateSqlStatementStrategy:执行SQL语句:1行更新 INFO 2012-12-06 09:09:22,168 [[ross_invoice_workflow] .SPTSQL01_APPS_custom_app_data.dispatcher.02] org.mule.transport.jdbc.sqlstrategy.SimpleUpdateSqlStatementStrategy:执行SQL语句:1行更新
(插入更多行,同样的事情)
INFO 2012-12-06 09:09:22,111 [[ross_invoice_workflow] .DatabaseMuleLogin.dispatcher.03] org.mule.transport.jdbc.sqlstrategy.SimpleUpdateSqlStatementStrategy:执行SQL语句:1行更新 INFO 2012-12-06 09:09:22,129 [[ross_invoice_workflow] .DatabaseMuleLogin.dispatcher.02] org.mule.transport.jdbc.sqlstrategy.SimpleUpdateSqlStatementStrategy:执行SQL语句:1行更新 INFO 2012-12-06 09:09:22,146 [[ross_invoice_workflow] .DatabaseMuleLogin.dispatcher.01] org.mule.transport.jdbc.sqlstrategy.SimpleUpdateSqlStatementStrategy:执行SQL语句:1行更新 INFO 2012-12-06 09:09:22,168 [[ross_invoice_workflow] .SPTSQL01_APPS_custom_app_data.dispatcher.03] org.mule.transport.jdbc.sqlstrategy.SimpleUpdateSqlStatementStrategy:执行SQL语句:1行更新 INFO 2012-12-06 09:09:22,168 [[ross_invoice_workflow] .SPTSQL01_APPS_custom_app_data.dispatcher.01] org.mule.transport.jdbc.sqlstrategy.SimpleUpdateSqlStatementStrategy:执行SQL语句:1行更新 INFO 2012-12-06 09:09:22,168 [[ross_invoice_workflow] .SPTSQL01_APPS_custom_app_data.dispatcher.02] org.mule.transport.jdbc.sqlstrategy.SimpleUpdateSqlStatementStrategy:执行SQL语句:1行更新
答案 0 :(得分:1)
问题来自MULE_CORRELATION_ID
设置为1
的事实。由于已经处理了具有此相关ID的组,因此在组交付后不可能继续使用此ID。在我的条带化测试中,当我尝试在第一组被释放后尝试使用相同的相关ID提供更多事件时,我实际上会收到错误。
我建议你在select查询中添加一个列,该列为所有选定的行返回相同的值,但每次Mule运行查询时都会更改。例如,查询可以接收由Mule生成的UUID,其表达式为#[java.util.UUID.randomUUID().toString()]
,并返回列中的值。然后,您可以将此值用作相关ID,因为它对于所选记录组将是相同的。
假设添加的列名为“CID”,则配置为:
<set-property propertyName="MULE_CORRELATION_GROUP_SIZE" value="3" />
<set-property propertyName="MULE_CORRELATION_ID" value="#[message.payload.CID]" />
(请注意,set-property
是比message-properties-transformer
更具表现力的配置元素)