当前位置: 首页 > 知识库问答 >
问题:

Apache camel,如何将消息从SOAP移动到JMS

周苑博
2023-03-14
<route id="cxfToJMSRoute">
    <from uri="cxf:bean:endpoint" />
    <log message="test" />
    <wireTap uri="direct:logInfo" />
    <to uri="activemq:queue:api" />
</route>
<cxf:cxfEndpoint id="endpoint" address="http://localhost:1010/hello"
        serviceClass="net.webservicex.GlobalWeatherSoap" wsdlURL="META-INF/globalweather.wsdl" />

<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="brokerURL" value="tcp://127.0.0.1:61616"/>
</bean>
org.apache.camel.RuntimeCamelException: Failed to extract body due to: javax.jms.JMSException: Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: Forbidden class org.apache.cxf.message.MessageContentsList! This class is not trusted to be serialized as ObjectMessage payload. Please take a look at http://activemq.apache.org/objectmessage.html for more information on how to configure trusted classes.. Message: ActiveMQObjectMessage {commandId = 8, responseRequired = true, messageId = ID:IT-L-R90HKRNH-64004-1511880368329-1:1:2:1:1, originalDestination = null, originalTransactionId = null, producerId = ID:IT-L-R90HKRNH-64004-1511880368329-1:1:2:1, destination = queue://api, transactionId = null, expiration = 1511880389430, timestamp = 1511880369430, arrival = 0, brokerInTime = 1511880369434, brokerOutTime = 1511880369495, correlationId = Camel-ID-IT-L-R90HKRNH-1511880338904-0-3, replyTo = temp-queue://ID:IT-L-R90HKRNH-64004-1511880368329-1:1:1, persistent = true, type = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = null, compressed = false, userID = null, content = org.apache.activemq.util.ByteSequence@663a8b1b, marshalledProperties = org.apache.activemq.util.ByteSequence@504b2d9b, dataStructure = null, redeliveryCounter = 0, size = 1640, properties = {SOAPAction=http://www.webserviceX.NET/GetCitiesByCountry, CamelHttpCharacterEncoding=UTF-8, User_HYPHEN_Agent=Apache-HttpClient/4.1.1 (java 1.5), Host=127.0.0.1:1010, operationName=GetCitiesByCountry, operationNamespace=http://www.webserviceX.NET, breadcrumbId=ID-IT-L-R90HKRNH-1511880338904-0-1, Content_HYPHEN_Type=text/xml;charset=UTF-8, CamelHttpMethod=POST, accept_HYPHEN_encoding=gzip,deflate, connection=keep-alive, CamelHttpUri=/hello, CamelHttpPath=}, readOnlyProperties = true, readOnlyBody = true, droppable = false, jmsXGroupFirstForConsumer = false}
        at org.apache.camel.component.jms.JmsBinding.extractBodyFromJms(JmsBinding.java:160) ~[camel-jms-2.16.3.jar!/:2.16.3]
        at org.apache.camel.component.jms.JmsMessage.createBody(JmsMessage.java:236) ~[camel-jms-2.16.3.jar!/:2.16.3]
        at org.apache.camel.impl.MessageSupport.getBody(MessageSupport.java:54) ~[camel-core-2.20.1.jar!/:2.20.1]
        at org.apache.camel.builder.ExpressionBuilder$35.evaluate(ExpressionBuilder.java:905) ~[camel-core-2.20.1.jar!/:2.20.1]
        at org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:36) ~[camel-core-2.20.1.jar!/:2.20.1]
        at org.apache.camel.builder.ExpressionBuilder$76.evaluate(ExpressionBuilder.java:1836) ~[camel-core-2.20.1.jar!/:2.20.1]
        at org.apache.camel.support.ExpressionAdapter.evaluate(ExpressionAdapter.java:36) ~[camel-core-2.20.1.jar!/:2.20.1]
        at org.apache.camel.processor.LogProcessor.process(LogProcessor.java:64) ~[camel-core-2.20.1.jar!/:2.20.1]
        at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548) ~[camel-core-2.20.1.jar!/:2.20.1]
        at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) ~[camel-core-2.20.1.jar!/:2.20.1]
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:138) ~[camel-core-2.20.1.jar!/:2.20.1]
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:101) ~[camel-core-2.20.1.jar!/:2.20.1]
        at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201) ~[camel-core-2.20.1.jar!/:2.20.1]
        at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:97) ~[camel-core-2.20.1.jar!/:2.20.1]
        at org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:112) ~[camel-jms-2.16.3.jar!/:2.16.3]
        at org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:719) ~[spring-jms-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
        at org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:679) ~[spring-jms-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
        at org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:649) ~[spring-jms-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
        at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:317) [spring-jms-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
        at org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:255) [spring-jms-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
        at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1166) [spring-jms-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
        at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1158) [spring-jms-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
        at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1055) [spring-jms-4.3.12.RELEASE.jar!/:4.3.12.RELEASE]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_92]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_92]
        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_92]
Caused by: javax.jms.JMSException: Failed to build body from content. Serializable class not available to broker. Reason: java.lang.ClassNotFoundException: Forbidden class org.apache.cxf.message.MessageContentsList! This class is not trusted to be serialized as ObjectMessage payload. Please take a look at http://activemq.apache.org/objectmessage.html for more information on how to configure trusted classes.
        at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:36) ~[activemq-client-5.14.5.jar!/:5.14.5]
        at org.apache.activemq.command.ActiveMQObjectMessage.getObject(ActiveMQObjectMessage.java:208) ~[activemq-client-5.14.5.jar!/:5.14.5]
        at org.apache.camel.component.jms.JmsBinding.extractBodyFromJms(JmsBinding.java:135) ~[camel-jms-2.16.3.jar!/:2.16.3]
        ... 25 common frames omitted
Caused by: java.lang.ClassNotFoundException: Forbidden class org.apache.cxf.message.MessageContentsList! This class is not trusted to be serialized as ObjectMessage payload. Please take a look at http://activemq.apache.org/objectmessage.html for more information on how to configure trusted classes.
        at org.apache.activemq.util.ClassLoadingAwareObjectInputStream.checkSecurity(ClassLoadingAwareObjectInputStream.java:112) ~[activemq-client-5.14.5.jar!/:5.14.5]
        at org.apache.activemq.util.ClassLoadingAwareObjectInputStream.resolveClass(ClassLoadingAwareObjectInputStream.java:57) ~[activemq-client-5.14.5.jar!/:5.14.5]
        at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1620) ~[na:1.8.0_92]
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1521) ~[na:1.8.0_92]
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1781) ~[na:1.8.0_92]
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1353) ~[na:1.8.0_92]
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:373) ~[na:1.8.0_92]
        at org.apache.activemq.command.ActiveMQObjectMessage.getObject(ActiveMQObjectMessage.java:206) ~[activemq-client-5.14.5.jar!/:5.14.5]
        ... 26 common frames omitted

那么,在JMS之前,我必须自己将消息转换为POJO吗?我对Camel完全陌生,但我得到的印象是Camel应该自动处理类型转换。

共有1个答案

勾炜
2023-03-14

您不想将Java对象发送到JMS代理,因此可以通过添加

<convertBodyTo type="String"/>
<to uri="activemq:queue:api" />

在发送到JMS代理之前。

您可能需要在类路径上添加camel-jaxb,以允许Camel自动将POJO类转换为XML文本。或者您可以将SOAPendpoint配置为不使用POJO类型而只使用原始XML,那么Camel就可以将原始XML作为基于文本的形式直接发送到JMS。

 类似资料:
  • 我正在尝试创建一条骆驼路线,它将: 从队列中获取JMS消息,消息体是SOAP请求 这是我的代码: endpoint配置: 我觉得我误解了这个场景中骆驼工作的一些基本原理。似乎是soap信封的存在导致了此问题。我曾假设camel能够获取原始soap消息并将其转换为cxfendpoint的正确消息格式。 有人能向我解释一下如何将SOAP请求传递给CXFendpoint吗?

  • 我正在使用apache camel cxf开发一个Web服务(肥皂),我遇到了这个错误。 Java . lang . illegalargumentexception:Part { http://blue print . camel . ngt . TN/}返回的类型应为[ltn . ngt . camel . blue print . WB _ subscriptions;,而不是org . A

  • Artemis 2.2.0的新版本有一个,它显然是在内部消息ID(而不是JMS消息ID)上操作的。 问题是:如何在Artemis Version2.x中使用JMS消息ID将消息从一个队列移动到另一个队列?

  • 问题内容: 我有一个SOAPMessage对象。我想解析并将其转换为一组Jaxb类。我如何将消息转换为Jaxb可以解组的格式? javax.xml.bind.Unmarshaller.unmarshal(??) 问题答案: SOAP消息的主体包含实际数据及其要解组的位。您可以执行以下操作:

  • //使用startActivity(intent)也不起作用//无论我做什么,应用程序都会崩溃

  • 本文向大家介绍Python如何将消息发布到RabbitMQ,包括了Python如何将消息发布到RabbitMQ的使用技巧和注意事项,需要的朋友参考一下 示例 从导入库开始。 接下来,我们需要打开与RabbitMQ服务器的连接。 之后,我们需要建立一个频道。每个连接可以有多个通道,通常在执行多线程任务时,建议(但不是必需)每个线程一个。 建立频道后,我们就可以开始准备信息了。 现在,我们可以通过简单