简体   繁体   中英

MassTransit not receiving Azure ServiceBus Topic Messages

I'm monitoring the topic and subs and messages are getting in, however my masstransit consumer is not receiving anything.

Here's how it's been setup:

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.
                        });

The Ping Consumer:

public class PingConsumer : IConsumer<Ping>
{
    public async Task Consume(ConsumeContext<Ping> pingContext)
    {
        pingContext.Respond(new Pong
        {
            Message = "Pong: " + pingContext.Message.Message
        });
    }
}

And the sender:

           var pong = await _bus.CreatePublishRequestClient<Ping, Pong>(TimeSpan.FromSeconds(10),null ).Request(
            new Ping {Message = "Ping: " + message});

In Azure, I'm seeing my message count climbing up and not going down. So messages are getting to the queue, but consumer is not consuming the message.

I was missing a VERY important key call to make it all work on both client and server side.

Bus.Start

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM