Closed zqxin45 closed 6 years ago
Hello @zqxin45 - thanks for reaching out. There simply is not enough information in this issue to be able to help you. Feel free to update the ticket with version information, code snippets of what you are trying to do and any other useful informaiton.
we use the 2.0.0.beta version,but we modified something,the code like this
_client.SubscribeAsync<Item, MessageContext>(async (msg, context) =>
{
var scopeFactory = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>();
using (var scope = scopeFactory.CreateScope())
{
return
}
}, ctx => ctx.UseConsumerConfiguration(cfg => cfg
.FromDeclaredQueue(e => e.WithName("DataCenter_CreateBaseItem"))
.OnDeclaredExchange(e=> e.WithName("DataCenter"))
.Consume(c => c.WithRoutingKey("DataCenter_CreateBaseItem_Route"))
)
);
credentials = pika.PlainCredentials('user', 'password'')
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost', 5672, "/", credentials))
channel = connection.channel()
repository = 'test'
#声明队列,如果消息发送到不存在的队列,rabbitmq会自动清除这些消息
#channel.exchange_declare(exchange="DataCenter",durable=True, type='topic')
result = channel.queue_declare(queue='DataCenter_CreateBaseItem', durable=True)
#channel.queue_bind(exchange="DataCenter",queue=result.method.queue, routing_key='DataCenter_CreateBaseItem_Route.#')
#exchange表示交换器,可以精确的制定消息应发到哪个队列,route_key设置队列的名称,body表示发送的内容
channel.basic_publish(exchange='', routing_key='DataCenter_CreateBaseItem', body=repository, properties=pika.BasicProperties(delivery_mode=2))
#关闭连接
connection.close()
i use C# it's can publish and receive both,but python publish can't receive
So the problem is that messages published by the python client does not trigger an invokation of the message handler?
If so, I would check the following:
I'm afraid I'mo not going to be able to help out more, as I'm not familiar with the python lib you use for RabbitMQ
Closing now. Feel free to read [the documentation[(http://rawrabbit.readthedocs.io/en/master/) of RawRabbit for more information about the client.
i use python to publish message,use rawrabbit to receive, but doesn't receive