我正在监控主题、订阅和消息正在进入,但是我的公共(public)交通消费者没有收到任何东西。
这是它的设置方式:
var bus = Bus.Factory.CreateUsingAzureServiceBus(
cfg =>
{
var azSbHost = cfg.Host(new Uri(CloudConfigurationManager.GetSetting("ServiceBus.Url"))
, host =>
{
host.TokenProvider = TokenProvider
.CreateSharedAccessSignatureTokenProvider
(CloudConfigurationManager.GetSetting("ServiceBus.SharedAccessKeyName"),
CloudConfigurationManager.GetSetting("ServiceBus.AccessKey"),
TokenScope.Namespace);
});
cfg.ReceiveEndpoint(azSbHost,
e =>
{
e.Consumer<PingConsumer>();
});
//azSbHost.
});
Ping 消费者:
public class PingConsumer : IConsumer<Ping>
{
public async Task Consume(ConsumeContext<Ping> pingContext)
{
pingContext.Respond(new Pong
{
Message = "Pong: " + pingContext.Message.Message
});
}
}
发送者:
var pong = await _bus.CreatePublishRequestClient<Ping, Pong>(TimeSpan.FromSeconds(10),null ).Request(
new Ping {Message = "Ping: " + message});
在 Azure 中,我看到我的消息计数在上升而不是下降。因此消息正在进入队列,但消费者并未使用该消息。
最佳答案
我错过了一个非常重要的关键调用,以使其在客户端和服务器端都能正常工作。
总线启动
关于c# - MassTransit 未收到 Azure ServiceBus 主题消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35298424/