java 如何解决消息有效负载的类型:Mule 中的 BufferInputStream Exception

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28713759/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 14:03:15  来源:igfitidea点击:

How to Solve Message payload is of type: BufferInputStream Exception in Mule

javamuletransformesb

提问by MoienGK

I am already transforming to byte array but i constantly get this error :

我已经转换为字节数组,但我不断收到此错误:

ERROR 2015-02-25 11:12:30,517 [[ESR].HTTP_Request_Listener.worker.01] org.mule.exception.DefaultMessagingExceptionStrategy: 
********************************************************************************
Message               : Response code 400 mapped as failure. Message payload is of type: BufferInputStream
Code                  : MULE_ERROR--2
--------------------------------------------------------------------------------
Exception stack is:
1. Response code 400 mapped as failure. Message payload is of type: BufferInputStream (org.mule.module.http.internal.request.ResponseValidatorException)
  org.mule.module.http.internal.request.SuccessStatusCodeValidator:37 (http://www.mulesoft.org/docs/site/current3/apidocs/org/mule/module/http/internal/request/ResponseValidatorException.html)
--------------------------------------------------------------------------------
Root Exception stack trace:
org.mule.module.http.internal.request.ResponseValidatorException: Response code 400 mapped as failure. Message payload is of type: BufferInputStream
    at org.mule.module.http.internal.request.SuccessStatusCodeValidator.validate(SuccessStatusCodeValidator.java:37)
    at org.mule.module.http.internal.request.DefaultHttpRequester.innerProcess(DefaultHttpRequester.java:202)
    at org.mule.module.http.internal.request.DefaultHttpRequester.process(DefaultHttpRequester.java:166)
    + 3 more (set debug level logging or '-Dmule.verbose.exceptions=true' for everything)
********************************************************************************

and this is my flow :

这是我的流程:

<sub-flow name="requestBeanCreate">
    <object-to-byte-array-transformer />
    <set-payload value="#[app.registry.messageBean.createServiceRequest(message.inboundProperties['http.uri.params']['name'],payload)]"/>
</sub-flow>

<flow name = "RequestsEntryFlow" >
    <http:listener allowedMethods="POST"  parseRequest="false"  config-ref="HTTP_Request_Listener" path="/{name}" doc:name="HTTP Entry Flow" />
    <flow-ref name="requestBeanCreate" />
    <choice doc:name="Choice">
        <when expression="#[app.registry.messageBean.isEMCRequired(payload)]">
            <jms:outbound-endpoint connector-ref="jms-connector" ref="EMCRequiredRequestsQueue" />
        </when>
        <otherwise>             
             <flow-ref name="req" />
        </otherwise>
    </choice>
</flow>

<http:request-config parseResponse="false" name="HTTP_Request_Configuration"   />

<sub-flow name = "req">    
    <set-variable variableName="id" value="#[payload]" doc:name="Variable" />
    <set-variable variableName="destination" value="#[app.registry.routerBean.getDestination(app.registry.messageBean.getReceiverID(payload))]"  doc:name="Variable" />
    <set-payload value="#[app.registry.messageBean.sendRequestToDestination(payload)]" />              
    <processor-chain>
    <http:request  parseResponse="false" config-ref="HTTP_Request_Configuration" host="#[flowVars.destination]" port="80" path="/" method="POST" />
        <object-to-byte-array-transformer />
        <expression-component>
            app.registry.messageBean.sendResponseToSender(flowVars.id);
            app.registry.messageBean.messageProcessedSuccessfully(flowVars.id);
        </expression-component>
    </processor-chain>
</sub-flow>

回答by afelisatti

It seems you are getting a 400 status code from the HTTP request which is causing an exception before even reaching the transformer. Try adding a success-status-code-validator that covers all of the cases (you can choose which ones to consider later):

似乎您从 HTTP 请求中获得了 400 状态代码,这导致在到达转换器之前发生异常。尝试添加一个涵盖所有情况的成功状态代码验证器(您可以选择稍后考虑哪些):

<http:request parseResponse="false" config-ref="HTTP_Request_Configuration" host="#[flowVars.destination]" port="80" path="/" method="POST">
        <http:success-status-code-validator values="0..599"/>
    </http:request>

回答by madajee

I also got this error when posting a status update using twitter mulesoft adapter, though after some googling & trial, I figured out that error is not with the adapter, it is with the payload string passed to the adapter.

我在使用 twitter mulesoft 适配器发布状态更新时也遇到了这个错误,但经过一些谷歌搜索和试用后,我发现错误不是与适配器有关,而是与传递给适配器的有效负载字符串有关。

In the SetPayload try this expression in the value field: #['RT @' + message.payload[0].user.screenName + ':' + message.payload[0].text]

在 SetPayload 的值字段中尝试这个表达式:#['RT @' + message.payload[0].user.screenName + ':' + message.payload[0].text]

And in the twitter adapter try these values:

在 twitter 适配器中尝试这些值:

Operation: Update status Status: #[payload]

操作:更新状态状态:#[payload]

If still you get an error, there may be some special characters in the "message.payload[0].text" which is the last tweet of the screenName, either try putting a logger without the update status adapter and check if you can log it correctly.

如果仍然出现错误,“message.payload[0].text”中可能有一些特殊字符,这是 screenName 的最后一条推文,要么尝试放置一个没有更新状态适配器的记录器,然后检查是否可以记录它正确。

回答by manishd_2000

Thanks Madajee. I had the same issue and your answer helped me to resolve it. Also, to add to this, there are issues with Twitter access that must be looked into in conjunction to ensure that you have a working solution. Especially around changing the permission to DT (Direct Tweet) and regenerating the Access Key and re-entering it in your Twitter connector config.

谢谢马达吉。我遇到了同样的问题,您的回答帮助我解决了这个问题。此外,除此之外,还有一些 Twitter 访问问题,必须联合研究,以确保您有一个可行的解决方案。尤其是将权限更改为 DT(直接推文)并重新生成访问密钥并将其重新输入到您的 Twitter 连接器配置中。