用于python的wso2消息代理客户端

用于python的wso2消息代理客户端,python,wso2,messagebroker,Python,Wso2,Messagebroker,我想使用python客户端消费消息并将消息发布到wso2 message broker。我搜索了很多,没有找到任何专门为wso2 message broker设计的python客户端 虽然我知道为rabbitmq工作的pika库可以为wso2消息代理工作 所以我编写了一个代码来将消息发布到wso2队列。我在wso2 message broker上创建了一个测试队列,并尝试使用pika库发布消息 import pika params = pika.URLParameters("amqp://ad

我想使用python客户端消费消息并将消息发布到wso2 message broker。我搜索了很多,没有找到任何专门为wso2 message broker设计的python客户端

虽然我知道为rabbitmq工作的pika库可以为wso2消息代理工作

所以我编写了一个代码来将消息发布到wso2队列。我在wso2 message broker上创建了一个测试队列,并尝试使用pika库发布消息

import pika

params = pika.URLParameters("amqp://admin:admin@localhost:5672/%2F")
connection = pika.BlockingConnection(params)
channel = connection.channel()
# channel.queue_declare(queue="testqueue", durable=True, exclusive=False, auto_delete=False)
if channel.basic_publish(exchange='', routing_key='testqueue',
                         body='New message for testing',
                         properties=pika.BasicProperties(content_type='text/plain', delivery_mode=1),
                         mandatory=True):
    print(" Message was published sucessfully")
else:
    print("message could not be published")
它显示消息已发布,但尚未发布。但是在wso2消息代理中,我得到了控制台错误

[ Sequence: 24976 ] Exception occurred while processing inbound events.Event type: MESSAGE_EVENT
java.lang.NullPointerException
    at java.util.HashSet.<init>(HashSet.java:118)
    at org.wso2.andes.kernel.router.QueueMessageRouter.getMatchingStorageQueues(QueueMessageRouter.java:88)
    at org.wso2.andes.kernel.disruptor.inbound.MessagePreProcessor.preProcessIncomingMessage(MessagePreProcessor.java:214)
    at org.wso2.andes.kernel.disruptor.inbound.MessagePreProcessor.updateRoutingInformation(MessagePreProcessor.java:190)
    at org.wso2.andes.kernel.disruptor.inbound.MessagePreProcessor.onEvent(MessagePreProcessor.java:75)
    at org.wso2.andes.kernel.disruptor.inbound.MessagePreProcessor.onEvent(MessagePreProcessor.java:49)
    at com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:128)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
[序列:24976]处理入站事件时发生异常。事件类型:消息\u事件
java.lang.NullPointerException
位于java.util.HashSet.(HashSet.java:118)
位于org.wso2.andes.kernel.router.QueueMessageRouter.GetMatchingStorage Queues(QueueMessageRouter.java:88)
位于org.wso2.andes.kernel.disruptor.inbound.MessagePreProcessor.preProcessIncomingMessage(MessagePreProcessor.java:214)
位于org.wso2.andes.kernel.disruptor.inbound.MessagePreProcessor.updateRoutingInformation(MessagePreProcessor.java:190)
位于org.wso2.andes.kernel.disruptor.inbound.MessagePreProcessor.onEvent(MessagePreProcessor.java:75)
位于org.wso2.andes.kernel.disruptor.inbound.MessagePreProcessor.onEvent(MessagePreProcessor.java:49)
位于com.lmax.disruptor.BatchEventProcessor.run(BatchEventProcessor.java:128)
位于java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
位于java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
运行(Thread.java:748)

上面的代码缺少exchange(变为空白),而是添加了
amq.direct
,以使其正常工作

channel.publish(exchange='amq.direct', 
        routing_key='testqueue', 
        body='Hello World!',
        properties=pika.BasicProperties(content_type='text/plain', delivery_mode=1)
)