骡子附件返回值

Mule attachment returning values

<flow..>
    ...
    <jersey:resources doc:name="REST">
            <component class="com.rest.SyncAccountService"/>
    </jersey:resources>
    <set-payload value="#[message.payload]" doc:name="Set Payload"/>
    <set-property propertyName="mimeType" value="application/octet-stream" doc:name="Property"/>
    <set-property propertyName="Content-Disposition" value="attachment;filename=${file_name}" doc:name="Property"/> 
    <set-variable variableName="status" value="Success" doc:name="Status"/>
    <flow-ref name="audit" doc:name="audit"/>
</flow>

<flow name="audit" doc:name="audit">
    <http:inbound-endpoint exchange-pattern="request-response" host="${hostname}" port="${glport}" path="audit" doc:name="HTTP"/>
    <db:insert config-ref="QB_Oracle_Configuration" doc:name="Audit" transactionalAction="NOT_SUPPORTED">
        <db:parameterized-query><![CDATA[INSERT INTO SIAS_AUDIT(ACCESS_ID,EMPLID) VALUES('1','value1')]]></db:parameterized-query>
    </db:insert>
    <set-payload value="===Audit Log ===" name="AuditStatus" doc:name="Status"/>
</flow>

上面的代码工作正常,但它 returns ===Audit Log === 在下载的文件中。取而代之的是,我需要显示在静态组件生成的附件级别定义的有效负载。

审计流程的目的是在数据库中记录 success/failure 的状态,不应该 return 任何东西。如果我删除 <set-payload value="===Audit Log ===" name="AuditStatus" doc:name="Status"/>

开始 returning java.lang.Number

编辑

将其设置为异步后出现以下错误:

ERROR 2015-05-27 13:43:51,846 [[qbiif].connector.http.mule.default.receiver.02] org.mule.exception.CatchMessagingExceptionStrategy: 
********************************************************************************
Message               : Unable to process a synchronous event asynchronously. Message payload is of type: MuleResponseWriter
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:

    1. Unable to process a synchronous event asynchronously. Message payload is of type: MuleResponseWriter (org.mule.api.MessagingException)
      org.mule.processor.AsyncInterceptingMessageProcessor:132 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/api/MessagingException.html)
    --------------------------------------------------------------------------------
    Root Exception stack trace:
    org.mule.api.MessagingException: Unable to process a synchronous event asynchronously. Message payload is of type: MuleResponseWriter

流量变化:

<flow name="audit" doc:name="audit" processingStrategy="asynchronous">   
    <db:insert config-ref="QB_Oracle_Configuration" doc:name="Audit" transactionalAction="NOT_SUPPORTED">
        <db:parameterized-query><![CDATA[INSERT INTO SIAS_AUDIT(ACCESS_ID,EMPLID) VALUES('1','value1')]]></db:parameterized-query>
    </db:insert>
    <set-payload value="===Audit Log ===" name="AuditStatus" doc:name="Status"/>
</flow>

EDIT-2

遵循 link

后对工作代码的最终更改
<flow name="audit" doc:name="audit">   
    <async>
        <db:insert config-ref="QB_Oracle_Configuration" doc:name="Audit" transactionalAction="NOT_SUPPORTED">
            <db:parameterized-query><![CDATA[INSERT INTO SIAS_AUDIT(ACCESS_ID,EMPLID) VALUES('1','value1')]]></db:parameterized-query>
        </db:insert>
        <set-payload value="===Audit Log ===" name="AuditStatus" doc:name="Status"/>
    </async>
</flow>
  • 删除<set-payload value="#[message.payload]" doc:name="Set Payload"/> : 它将消息有效载荷设置为它自己,这是无用的。
  • <flow-ref name="audit" doc:name="audit"/> 包装在 async 范围内,这样它的响应就不会与来自 JAX-RS 组件的响应混淆。
  • 除非您真的需要通过 HTTP 公开 audit 流,否则请删除其中的 http:inbound-endpoint