Python社区  »  MQ

无法将对象类型消息发布到Mule 4中的消息队列(ActiveMQ)

ravibeli • 6 天前 • 18 次点击  

我正在处理从3.9到4.1.4的Mule迁移,尝试将ArrayList转换为JSON,然后发布到JMS队列(使用ActiveMQ),得到下面的错误消息

代码:

<sub-flow name="xxxx_part_data_to_messaging_system_flow">
        <logger level="INFO" doc:name="Logger" doc:id="0607190d-f3ed-4b1b-a5b4-3572c08cf2d5" message='[vars.correlationId ++ "" ++ vars.batch_id]'/>
    <jms:publish doc:name="xxxx-part-data-jms-queue" doc:id="b44b1880-7374-4e4d-a0e0-1b4ab193ade4" config-ref="transactional_data_jms_connection_config" destination="${ld.transaction.xxxx.part.messaging.queue}">
    <jms:message >
    <jms:body ><![CDATA[#[[payload]]]]></jms:body>
    </jms:message>
    </jms:publish>
    <logger message="#[" $(vars.correlationId)-$(vars.batch_id) xxxx part posted successfully into transaction data queue ${ld.transaction.xxxx.part.messaging.queue}"]" level="INFO" doc:name="Logger" />
</sub-flow>

错误:

the data fetched from DB is ArrayList
An error occurred while sending a message to the QUEUE: [ld.stock.part.queue]: 
Invalid type passed to StreamMessage: java.util.ArrayList . Allowed types are: 
Boolean, Byte, Short, Character, Integer, Long, Float, Double,String and 
byte[]. Invalid type passed to StreamMessage: java.util.ArrayList . Allowed 
types are: Boolean, Byte, Short, Character, Integer, Long, Float, Double,String 
and byte[].
Error type    : JMS:ILLEGAL_BODY
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/50724
 
18 次点击  
分享到微博
文章 [ 1 ]  |  最新文章 6 天前
Ryan Carter
Reply   •   1 楼
Ryan Carter    8 月前

您的负载不是JSON。您正在用额外的[]将有效负载包装在数组中: #[[payload]] 默认为application/java。

可以内联转换为JSON。如果要使用周围的数组:

#[output application/json --- [payload]]

或者如果不需要额外的数组使用:

#[output application/json --- payload]

内联示例:

 <jms:publish doc:name="xxxx-part-data-jms-queue" doc:id="b44b1880-7374-4e4d-a0e0-1b4ab193ade4" config-ref="transactional_data_jms_connection_config" destination="${ld.transaction.xxxx.part.messaging.queue}">
    <jms:message >
       <jms:body ><![CDATA[#[[output application/json --- payload]]]]></jms:body>
    </jms:message>
 </jms:publish>