Skip to content

Commit

Permalink
fixed consumer method injection context bug. (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
yang-xiaodong committed Aug 17, 2017
1 parent 75a3833 commit 8c5da12
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/DotNetCore.CAP/Internal/ConsumerInvokerFactory.cs
@@ -1,5 +1,6 @@
using System;
using DotNetCore.CAP.Abstractions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

namespace DotNetCore.CAP.Internal
Expand All @@ -22,12 +23,15 @@ public class ConsumerInvokerFactory : IConsumerInvokerFactory

public IConsumerInvoker CreateInvoker(ConsumerContext consumerContext)
{
var context = new ConsumerInvokerContext(consumerContext)
using(var scope = _serviceProvider.CreateScope())
{
Result = new DefaultConsumerInvoker(_logger, _serviceProvider, _modelBinderFactory, consumerContext)
};
var context = new ConsumerInvokerContext(consumerContext)
{
Result = new DefaultConsumerInvoker(_logger, scope.ServiceProvider, _modelBinderFactory, consumerContext)
};

return context.Result;
return context.Result;
}
}
}
}

0 comments on commit 8c5da12

Please sign in to comment.