Masstransit: The IErrorTransport was not available on the ReceiveContext. exception thrown in Azure Functions Consumer

Created on 19 Feb 2020  路  8Comments  路  Source: MassTransit/MassTransit

Is this a bug report?

Yes
https://stackoverflow.com/questions/60233193/masstransit-additional-error-raised-when-consumer-has-an-exception-the-ierror/60233491#60233491

Can you also reproduce the problem with the latest version?

Yes

Environment

  1. Operating system: Windows 10
  2. Visual Studio version: Visual Studio 2019
  3. Dotnet version: core 3.0

Steps to Reproduce

(Write your steps here:)

  1. Consumer hosted in Azure Functions 3.0 throws an exception


    1. 3.

Expected Behavior

Original exception logged and message retried or put on deadletter queue after retries

Actual Behavior

An additional exception is logged.
System.Private.CoreLib: Exception while executing function: ExecuteMessageConsumerAsync. MassTransit: The IErrorTransport was not available on the ReceiveContext.

Reproducible Demo

The current issue is in our application code, but I could make a demo to try and reproduce if needed.

All 8 comments

This is fixed, I think, in my latest changes for functions. I haven't pushed them to develop yet though. I completely rewrote it have a more consistent approach, however. So the code may need slight adjustment. That, and I can't seem to test ASB functions locally using the Function Core Tools (installed using homebrew on Mac).

A develop package should be available in an hour that may resolve this issue.

Great, I'll give it a try. Thanks for the quick response.

There are changes to the syntax to set it up, by the way. This is the updated sample code:

        [FunctionName("SubmitOrder")]
        public static Task SubmitOrderAsync([ServiceBusTrigger("input-queue")] Message message, IBinder binder, Microsoft.Extensions.Logging.ILogger logger,
            CancellationToken cancellationToken)
        {
            var handler = binder.CreateBrokeredMessageReceiver(logger, cancellationToken, cfg =>
            {
                cfg.InputAddress = new Uri("sb://masstransit-build.servicebus.windows.net/input-queue");

                cfg.UseRetry(x => x.Intervals(10, 100, 500, 1000));
                cfg.Consumer(() => new SubmitOrderConsumer());
            });

            return handler.Handle(message);
        }

Let me know if you get a chance to try it and verify it works. I couldn't get my function deployed to Azure to verify, so I'm shrugging. I really don't want to install Visual Studio, like, anywhere.

I'll test it out today and let you know.

Looks good, the error is gone. Thanks for your help.

There is one issue with the changes in 6.2. We were using the InMemerySendContext in a couple of unit tests. The class is no longer in MassTransit.Transports.InMemory.Contexts. Has it moved or is there a replacement?

    [Test]
    public void TestSendContextFilter_Should_Set_TenantId_Header()
    {
        // arrange
        var pipe = Pipe.New<SendContext>(x =>
        {
            x.AddPipeSpecification(new TenantContextPipeSpecification<SendContext, int>(ProviderFactory, HeaderName));
        });

        var sendContext = new InMemorySendContext<A>(new A());

        // act
        pipe.Send(sendContext);

        // assert
        sendContext.Headers.GetAll()
            .Should().Contain(x => x.Key == HeaderName)
            .Which.Value.Should().Be(TenantId);
    }

It's now MessageSendContext<T> - the InMemory version wasn't any different so I nix'd it.

Was this page helpful?
0 / 5 - 0 ratings