skip to Main Content

Hi I have a publisher and consumer

The registration for the publisher seems very simple

 services.AddMassTransit(x =>
            {
                x.SetKebabCaseEndpointNameFormatter();
                x.UsingAzureServiceBus((context, cfg) =>
                {
                    
                    cfg.Host(configInstance.AzureServiceBusSettings.Connectionstring);
                    cfg.AutoStart = true;
                }
                );
            });

The registration for the consumer looks like this

services.AddMassTransit(x =>
{
    x.SetKebabCaseEndpointNameFormatter();
    var entryAssembly = Assembly.GetEntryAssembly();
    x.AddConsumers(entryAssembly);
    x.AddSagaStateMachines(entryAssembly);
    x.AddSagas(entryAssembly);
    x.AddActivities(entryAssembly);
    x.UsingAzureServiceBus((context, cfg) =>
    {
        cfg.Host(configuration.AzureServiceBusSettings.Connectionstring);
        cfg.ConfigureEndpoints(context);
    });
                   
});

When I start this two projects it will create me the subscriptions and queues

For example the debug output from the consumer

[21:53:35 DBG] Create queue: hello
[21:53:40 DBG] Queue: hello (dead letter)
[21:53:44 DBG] Endpoint Ready: sb://xxxx.servicebus.windows.net/hello
[21:53:44 INF] Bus started: sb://xxx.servicebus.windows.net/

This reflects the state of the servicebus, there is one queue called hello and a subscription

So my consumer looks like this

public class HelloConsumer : IConsumer<Hello>
    {
        ILogger<HelloConsumer> _logger;
        public HelloConsumer(ILogger<HelloConsumer> logger)
        {
            this._logger = logger;
        }

        public Task Consume(ConsumeContext<Hello> context)
        {
            this._logger.LogInformation("HEllo");
            return Task.CompletedTask; 
        }
    }

Now when I send the "Hello" it will send to the queue
enter image description here

as you see I have 7 messages in it. But unfortunalley the messaged won’t be fetched from the ASB. In the consumer log is no action in it.

I tried to delete the topics and queues, this throws me several 404 errors. So I think that it will be 2monitored" but why not fetchted?

Do I miss here s.th.?

I am using the following nuget version

    <PackageReference Include="MassTransit.Azure.ServiceBus.Core" Version="8.0.16" />

Aditional information: The Servicebus has a standard plan selected.

2

Answers


  1. Chosen as BEST ANSWER

    I just figured it out. So it was reproducable when I remove the existing nuget package to masstransit.Rabbitmq. After that the messages are fetched all again. So I don't know if this is the real problem but that's at my environment a solution.

    So in fact it was maybe overlapping the logic I think


  2. using this reference Azure Service Bus MassTransit able to fetch messages Thank @Chris Patterson

    x.AddSagaStateMachines(entryAssembly);
                           x.AddSagas(entryAssembly);
                           x.AddActivities(entryAssembly);
                           x.UsingAzureServiceBus((context, cfg) =>
                               {
                                   cfg.Host(connectionString: "Endpoint=sb://samp12334.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=z ");
                                   cfg.ConfigureEndpoints(context);
                               });
                       
                       });
                       services.AddHostedService<worker>();
                   });
       }
    }
    
     public class HelloConsumer :
            IConsumer<Hello>
        {
            readonly ILogger<HelloConsumer> _logger;
            public HelloConsumer(ILogger<HelloConsumer> logger) 
             { 
              _logger = logger;
            }
            public Task Consume(ConsumeContext<Hello> context)
            {
                _logger.LogInformation(message: "Hello{Name}", context.Message.Name);
                return Task.CompletedTask;
            }
        }
    }
    

    Output:

    enter image description here

    enter image description here

    enter image description here

    For queue:

    x.UsingAzureServiceBus((context, cfg) => { cfg.Host("Endpoint=sb://your-service-bus-namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=your-access-key"); 
    cfg.ReceiveEndpoint("your-queue-name", e => { e.ConfigureConsumer<MyMessageConsumer>(context); }); });
    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search