我有一个带有自定义拦截器的 Mule 流,它构造一个对象并将其转发到 JMS 出站端点。JMS 端点在尝试将 Object 转换为 JMS StreamMessage 时抛出异常。我想要的是端点将 Object 转换为 JMS ObjectMessage。那怎么做?
这是我的流程;
<spring:beans>
<spring:bean id="connectionFactoryFactory" name="connectionFactoryFactory"
class="ConnectionFactoryFactory">
<spring:property name="properties">
<spring:props>
<spring:prop key="imqAddressList">mqtcp://localhost:30001/jms</spring:prop>
<spring:prop key="imqReconnectAttempts">-1</spring:prop>
</spring:props>
</spring:property>
</spring:bean>
<spring:bean id="connectionFactory" name="connectionFactory"
factory-bean="connectionFactoryFactory" factory-method="createConnectionFactory" />
</spring:beans>
<jms:connector name="JMSConnector" connectionFactory-ref="connectionFactory"
specification="1.1" doc:name="JMS" />
<flow name="Request" doc:name="Request">
<quartz:inbound-endpoint responseTimeout="10000"
doc:name="InfoRequest" jobName="InfoRequest" repeatInterval="5000">
<quartz:event-generator-job />
</quartz:inbound-endpoint>
<custom-interceptor class="StateRequest"/>
<jms:outbound-endpoint connector-ref="JMSConnector"
doc:name="JMS" topic="requests"/>
</flow>
我还尝试将对象添加到 JMS 消息转换器;
<jms:object-to-jmsmessage-transformer returnClass="javax.jms.ObjectMessage" name="Object_to_JmsMessage" doc:name="Object to JmsMessage"/>
<jms:outbound-endpoint connector-ref="JMSConnector"
doc:name="JMS" topic="requests" transformer-refs="Object_to_JmsMessage"/>