rebus-org / Rebus.Async

:bus: Experimental async extensions for Rebus
https://mookid.dk/category/rebus
Other
13 stars 9 forks source link

Error when firing async #5

Closed frostebite closed 6 years ago

frostebite commented 6 years ago

I'm getting the following exception.

No idea why. Any help appreciated

my local tests work just fine by not when run on a cloud machine?

message Object reference not set to an instance of an object.
stack at Rebus.AsyncBusExtensions.d2`1.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Rebus.AsyncBusExtensions.d11.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at DocWorks.BuildingBlocks.EventBus.Implementation.EventBusService.d__12.MoveNext()
mookid8000 commented 6 years ago

Can I see the code in EventBusService that makes the call to SendRequest?

frostebite commented 6 years ago

it's super simple. Just calling SendRequest

frostebite commented 6 years ago

I'm adding rebus like this

services.AddRebus(configure => configure
                .Logging(l =>
                {
                    l.Trace();
                })
                .Transport(t =>
                {
                    t.UseInMemoryTransport(new InMemNetwork(true), "default");
                })
                .Subscriptions(s=>
                {
                    s.StoreInMemory();
                })
                .Options(o =>
                {
                    o.LogPipeline(verbose:true);
                    o.SetNumberOfWorkers(workers);
                    o.SetMaxParallelism(parallelism);
                    o.EnableSynchronousRequestReply(30);
                    o.SimpleRetryStrategy(
                        maxDeliveryAttempts:1
                    );
                })
                .Routing(r =>
                {
                    r.TypeBased()
                        .MapFallback("default")
                        .Map<bool>("default")
                        .Map<EventHandlerPayloadBase>("default");
                }));

I'm sending with this:

await memBus.SendRequest(baseRequest, null, TimeSpan.FromMinutes(6));

I get this and then I get this:

c4c90ae4-b065-4f81-b4fd-ce6b07393da5 ---> default (In-mem network 1) 248dffa0-ab60-4e78-9178-b6448e777a42 ---> default (In-mem network 1) default ---> 248dffa0-ab60-4e78-9178-b6448e777a42 (In-mem network 1) default ---> c4c90ae4-b065-4f81-b4fd-ce6b07393da5 (In-mem network 1) request-reply:f099f206-2562-44de-a5f9-a911b38297af ---> default (In-mem network 1) default ---> request-reply:f099f206-2562-44de-a5f9-a911b38297af (In-mem network 1) default ---> request-reply:f099f206-2562-44de-a5f9-a911b38297af (In-mem network 1) request-reply:f099f206-2562-44de-a5f9-a911b38297af ---> error (In-mem network 1)

when firing a simple request on startup in the Configure services method of a netcore api

frostebite commented 6 years ago
public async Task processMessage(EventHandlerPayloadBase baseRequest)
        {
            try
            {
                if(acceptedHandlers.Contains(baseRequest.GetType()))
                {
                    _logger.LogInformation(new
                    {
                        message = "Handler found, executing",
                        label = baseRequest.label,
                        handlers = acceptedHandlers.Select(x => x.Name),
                        type = baseRequest.GetType().Name
                    }.ToJson());
                    await memBus.SendRequest<bool>(baseRequest, null, TimeSpan.FromMinutes(6));
                }
                else
                {
                    _logger.LogInformation(new
                    {
                        message = "No handler for event skipping",
                        label = baseRequest.label,
                        handlers = acceptedHandlers.Select(x => x.Name),
                        type = baseRequest.GetType().Name
                    }.ToJson());
                }
            }
            catch (Exception ex)
            {
                _logger.LogError(new
                {
                    error = "true",
                    message = ex.Message,
                    stack = ex.StackTrace,
                    type = ex.GetType().GetType().Name,
                    exception = ex
                }.ToJson());
                throw ex;
            }
        }

is that method if it helps

frostebite commented 6 years ago

@mookid8000 Any idea at all from glancing? Anything I could provide?

mookid8000 commented 6 years ago

So when do you get the exception?

Could you maybe post the entire exception, including the full stack trace?

frostebite commented 6 years ago

That latest thing running locally produces no exception just halts the program and the console says that thing with request reply error

mookid8000 commented 6 years ago

Ok. I'll see if I can get time to investigate this tomorrow.

mookid8000 commented 6 years ago

Hi @frostebite , sorry – I never got this done, and then vacation happened.... 🌞 what's the status? Have you figured something out?

If not, could you maybe try and reproduce the problem in a small program and send it to me?

mookid8000 commented 6 years ago

Hi @frostebite , any chance you can tell me more about what you're trying to achieve, and how you're trying to do it?

From your code it seems strange to me that your processMessage method seems to handle a request of some kind (EventHandlerPayloadBase), but then it uses the SendRequest to send it somewhere else, effectively blocking until a reply is received.

It's a little bit hard for me to get an understanding of what you want to achieve from the code you posted, so I think it might help if you tell me some more about it.

mookid8000 commented 6 years ago

Closing this one for now. Feel free to resume the discussion if it hasn't been resolved somehow.