骡子附件返回值

时间:2015-05-27 19:04:14

标签: mule

<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>

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

审计流程的目的是记录数据库中成功/失败的状态,该状态不应返回任何内容。如果我删除<set-payload value="===Audit Log ===" name="AuditStatus" doc:name="Status"/>

它开始返回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$1
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:

    1. Unable to process a synchronous event asynchronously. Message payload is of type: MuleResponseWriter$1 (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$1

流量变化:

<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>

修改-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>

1 个答案:

答案 0 :(得分:1)

  • 删除<set-payload value="#[message.payload]" doc:name="Set Payload"/>:它将消息有效负载设置为自身,这是无用的。
  • <flow-ref name="audit" doc:name="audit"/>包裹在async范围内,以便其响应不会混淆JAX-RS组件的响应。
  • 除非您确实需要通过HTTP公开audit流,否则请删除其中的http:inbound-endpoint