码迷,mamicode.com
首页 > 其他好文 > 详细

MULE RabbitMQ使用时出现session variable错误

时间:2021-02-25 12:20:16      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:截图   spec   -o   erro   thrown   rri   cal   def   ica   

异常信息
ERROR [amqpReceiver.01] org.mule.exception.DefaultSystemExceptionStrategy: Caught exception in
flowConstructt&org/mule/api/construct/FlowConstruct is malfomed and cannot be read
java.lang.IllegalArgumentException:Session Variable org.mule.session.DefaultMuleSession

放一个异常截图
技术图片

错误场景
我在3.9.0环境上开发了两个程序,姑且称之为生产者程序和消费者程序,开发到测试过程中没有出现什么问题,生产者将消息流经AMQP入站,消费者从AMQP出站消费,但是由于某些原因需要将这两个程序运行到3.6.0的运行时上。
高版本迁低版本可想而知,首先studio改Mule环境,同时3.6.0需要使用JDK1.7,因此JDK也是需要修改。万事具备只带测试,我将生产者部署到3.6.0运行时,AnypointStudio运行消费者程序,一跑就出现上面的错误。
看异常说是session variable之类的错误,但是我并没有使用过session variable变量,而且3.9.0并没有出现过该类似错误,我开始猜测有可能是消息中的变量有问题或者乱码,因为MULE消息到Rabbitmq后会额外有一些Mule变量,如MULE_SESSION。停止消费者,重新利用生产者发送产生一条消息进入队列中,使得消息留在队列中,从Rabbitmq控制台GetMessage后发现并没有什么问题(毕竟MULE_SESSION本身就是一大串数字+字母),我当然第一时间怀疑版本导致的问题。各种clean,build,还是不行。最后谷歌了一番,在本博客最后的第一个参考资料中,有一段解释引起了我注意:

Mule when it consumes message from AMQ, it tries to parse the parameters. While parsing the outbound properties. It specifically decodes property.
While decoding it sets the key and value to Mule session variable.
In most of the scenarios, above error will be thrown if we have set any session variable with Because there is a logic to tokenize on ; and parse the key and value. If there is any value with semicolon then it will be treated as a key value pair and tries to parse. If parsing fails then it will result in IllegalArgumentException

 

(via谷歌翻译)Mule在消耗来自AMQ的消息时,会尝试解析参数。解析出站属性时。它专门解码。在解码时,它将键和值设置为Mule会话变量。在大多数情况下,如果我们设置任何会话变量,则会抛出上述错误因为有一个逻辑要标记;并解析密钥和值。如果有分号的任何值,那么它将被视为键值对并尝试解析。如果解析失败,那么将导致IllegalArgumentException.

英文一般的我谷歌翻译看了一下,感觉说的挺符合目前碰到的异常问题。也就是AMQP出站时,MULE对消息的解析出现了问题。因此直接在AMQP出站时就抛出了异常。

最终从资料二的论坛里面,它们说的是如何在http request中去掉MULE_SESSION的文章中找到了一行关键的代码解决了该问题。

 

<service-overrides sessionHandler="org.mule.session.NullSessionHandler"/>

既然应该是MULE_SESSION的问题,那就舍弃它不要。
将上面的代码放到标签中

    <amqp:connector name="AMQP" validateConnections="true" doc:name="AMQP-0-9 Connector" >
        <service-overrides sessionHandler="org.mule.session.NullSessionHandler"/>
    </amqp:connector>

重新运行程序,没有出现异常。

MULE RabbitMQ使用时出现session variable错误

标签:截图   spec   -o   erro   thrown   rri   cal   def   ica   

原文地址:https://www.cnblogs.com/youngdeng/p/14444989.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!