我能够在WSO2 ESB版本4.8.1上配置代理而没有错误(除了JMS错误,但此时看起来无关紧要)。这是一个配置xml:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="AMQP1"
transports="rabbitmq"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<log level="full"/>
<property name="OUT_ONLY" value="true"/>
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
</inSequence>
<endpoint>
<address uri="rabbitmq:/AMQP1?rabbitmq.server.host.name=localhost&rabbitmq.server.port=5672&rabbitmq.server.user.name=guest&rabbitmq.server.password=guest&rabbitmq.queue.name=queue1&rabbitmq.exchange.name=exchange1"/>
</endpoint>
</target>
<parameter name="rabbitmq.queue.name">queue2</parameter>
<parameter name="rabbitmq.connection.factory">AMQPConnectionFactory</parameter>
<parameter name="rabbitmq.exchange.name">amq.direct</parameter>
<parameter name="rabbitmq.queue.routing.key">queue2</parameter>
<description/>
</proxy>
我将消息从java客户端发送到queue2,并在其他客户端上侦听queue1。我想前面的信息是这样的吗?我还没有执行任何消息格式更改。 我可以看到消息从RabbitMQ控制台到达queue2,但是在WSO2控制台上我可以看到错误:
[2015-06-30 11:44:54,920] INFO – CarbonAuthenticationUtil ‘admin@carbon.super [
-1234]’ logged in at [2015-06-30 11:44:54,920+0200]
[2015-06-30 12:07:40,293] ERROR – NativeWorkerPool Uncaught exception
org.apache.axiom.om.OMException: javax.xml.stream.XMLStreamException: ParseError
at [row,col]:[1,23]
Message: Element type “soapenv:Envelopexmlns” must be followed by either attribu
te specifications, “>” or “/>”.
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.jav
a:296)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.getSOAPEnvelo
pe(StAXSOAPModelBuilder.java:204)
at org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder.(StAXSO
APModelBuilder.java:154)
at org.apache.axiom.om.impl.AbstractOMMetaFactory.createStAXSOAPModelBui
lder(AbstractOMMetaFactory.java:73)
at org.apache.axiom.om.impl.AbstractOMMetaFactory.createSOAPModelBuilder
(AbstractOMMetaFactory.java:79)
at org.apache.axiom.om.OMXMLBuilderFactory.createSOAPModelBuilder(OMXMLB
uilderFactory.java:196)
at org.apache.axis2.builder.SOAPBuilder.processDocument(SOAPBuilder.java
:55)
at org.apache.axis2.transport.rabbitmq.utils.RabbitMQUtils.setSOAPEnvelo
pe(RabbitMQUtils.java:80)
at org.apache.axis2.transport.rabbitmq.RabbitMQMessageReceiver.processTh
roughAxisEngine(RabbitMQMessageReceiver.java:106)
at org.apache.axis2.transport.rabbitmq.RabbitMQMessageReceiver.onMessage
(RabbitMQMessageReceiver.java:58)
at org.apache.axis2.transport.rabbitmq.ServiceTaskManager$MessageListene
rTask.handleMessage(ServiceTaskManager.java:303)
at org.apache.axis2.transport.rabbitmq.ServiceTaskManager$MessageListene
rTask.run(ServiceTaskManager.java:188)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(Native
WorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.
java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor
.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,23]
Message: Element type “soapenv:Envelopexmlns” must be followed by either attribu
te specifications, “>” or “/>”.
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLS
treamReaderImpl.java:598)
at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStr
eamReaderWrapper.java:225)
at org.apache.axiom.util.stax.dialect.DisallowDoctypeDeclStreamReaderWra
pper.next(DisallowDoctypeDeclStreamReaderWrapper.java:34)
at org.apache.axiom.util.stax.wrapper.XMLStreamReaderWrapper.next(XMLStr
eamReaderWrapper.java:225)
at org.apache.axiom.util.stax.dialect.SJSXPStreamReaderWrapper.next(SJSX
PStreamReaderWrapper.java:138)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuild
er.java:681)
at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.jav
a:214)
… 15 more
你能帮帮我吧!
提前致谢,
卢德米拉
答案 0 :(得分:0)
在将消息发布到队列时,是否将消息内容类型设置为text / xml?请通过[1]解释一个真正的集成用例(WSO2 ESB + RabbitMQ),其中包含代理配置和Java客户端,用于向/从RabbitMQ发布/使用消息。
[1] http://blog.rajkumarr.com/2014/12/wso2-esb-and-rabbitmq.html
答案 1 :(得分:0)
您必须创建1个代理才能从第一个队列中获取消息,读取后,在inSequence中,您应该使用Payload Mediator正确创建要发送到其他队列的新消息。在inSequence中添加一个Send Mediator,将最近创建的有效负载传递给第二个队列的EndPoint。
要向RabbitMQ发布消息,请再次按照上述博客(https://luispenarrubia.wordpress.com/2015/05/04/how-to-integrate-wso2-esb-and-rabbitmq-using-amqp-transport-part-2)。请记住在发布和使用之前正确设置内容类型,在博客文章中解释了这一点。
问候。
答案 2 :(得分:0)
如果有人需要,我已经解决了使用以下代理定义从一个队列发布到另一个队列的问题。
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="AMQPProxyXml"
transports="rabbitmq"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<log level="full"/>
<property name="OUT_ONLY" value="true"/>
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
<property name="rabbitmq.message.content.type"
value="application/xml"
scope="transport"
type="STRING"/>
</inSequence>
<endpoint>
<address uri="rabbitmq:/AMQPProxy?rabbitmq.server.host.name=localhost&rabbitmq.server.port=5672&rabbitmq.server.user.name=guest&rabbitmq.server.password=guest&rabbitmq.queue.name=queue2&rabbitmq.exchange.name=exchange2&rabbitmq.message.content.type=application/xml"/>
</endpoint>
</target>
<parameter name="rabbitmq.queue.name">queue1</parameter>
<parameter name="rabbitmq.connection.factory">AMQPConnectionFactory</parameter>
<parameter name="rabbitmq.exchange.name">exchange1</parameter>
<description/>
</proxy>