NullPointer引用在RabbitMQ传输上发送消息

时间:2016-05-09 19:12:04

标签: wso2 rabbitmq esb

使用此传输字符串从ESB 4.9.0 API发送到RabbitMQ时:

<send>
    <endpoint>
        <address name="scalehouse_001_rabbitmq" trace="enable" uri="rabbitmq:/ScaleHouses?rabbitmq.server.host.name=localhost&amp;rabbitmq.server.port=5672&amp;rabbitmq.server.user.name=guest&amp;rabbitmq.server.password=guest&amp;rabbitmq.queue.name=scalehouse_001"/>
    </endpoint>
  </send>

我收到此错误:

java.lang.NullPointerException at org.apache.axis2.transport.rabbitmq.RabbitMQMessage.&lt;init&gt;(RabbitMQMessage.java:43) at org.apache.axis2.transport.rabbitmq.RabbitMQSender.sendOverAMQP(RabbitMQSender.java:84) at org.apache.axis2.transport.rabbitmq.RabbitMQSender.sendMessage(RabbitMQSender.java:72) at org.apache.axis2.transport.base.AbstractTransportSender.invoke(AbstractTransportSender.java:112) at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442) at org.apache.synapse.core.axis2.DynamicAxisOperation$DynamicOperationClient.send(DynamicAxisOperation.java:185) at org.apache.synapse.core.axis2.DynamicAxisOperation$DynamicOperationClient.executeImpl(DynamicAxisOperation.java:167) at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149) at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:542) at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:79)

有没有人有使用RabbitMQ传输的经验,并且能够深入了解潜在的原因?

1 个答案:

答案 0 :(得分:0)

我认为问题出在你的axis2.xml配置中。请按照以下步骤操作。

在axis2.xml的transport receiver部分下,找到rabbitmq传输接收器并将其替换为您的配置。这里给出了一个示例配置来帮助您。

<transportReceiver name="rabbitmq" class="org.apache.axis2.transport.rabbitmq.RabbitMQListener">
    <parameter name="AMQPConnectionFactory" locked="false">
        <parameter name="rabbitmq.server.host.name" locked="false">localhost</parameter>
        <parameter name="rabbitmq.server.port" locked="false">5672</parameter>
        <parameter name="rabbitmq.server.user.name" locked="false">guest</parameter>
        <parameter name="rabbitmq.server.password" locked="false">guest</parameter>
        <parameter name="rabbitmq.connection.retry.interval" locked="false">10000</parameter>
        <parameter name="rabbitmq.connection.retry.count" locked="false">5</parameter>
    </parameter>
</transportReceiver>

从上面的配置中,WSO2 ESB可以充当RabbitMQ消费者。然后在axis2.xml中找到rabbitmq的transport sender元素并取消注释。下面给出了rabbitmq发送方的示例配置。

<transportSender name="rabbitmq" class="org.apache.axis2.transport.rabbitmq.RabbitMQSender"/>

应用这一行代码后,WSO2 ESB可以充当RabbitMQ生成器,它可以生成给定RabbitMQ队列或主题的消息。

有关此内容的更多信息,请点击此处。

http://ravindraranwala.blogspot.com/2015/09/rabbitmq-transport-in-wso2-esb.html