private IMessageInvoker MessageInvokerFactory(IHandlerScope arg)
        {
            var invoker = new MessageInvoker(arg);

            invoker.HandlerMissing += (sender, args) =>
            {
                _log.Warn("Handler missing for " + args.Message.Body.GetType());
            };
            invoker.Logger          = DiagnosticLog;
            invoker.HandlerInvoked += (sender, args) =>
            {
                _log.Debug(args.Message.Body);
                if (args.Exception == null)
                {
                    return;
                }

                Err.Report(args.Exception, new
                {
                    args.Message.Body,
                    HandlerType = args.Handler.GetType(),
                    args.ExecutionTime
                });
                _log.Error(
                    $"Ran {args.Handler}, took {args.ExecutionTime.TotalMilliseconds}ms, but FAILED.",
                    args.Exception);
            };
            return(invoker);
        }
Example #2
0
        private IMessageInvoker MessageInvokerFactory(IHandlerScope arg)
        {
            var k       = arg.ResolveDependency <IMessageHandler <FeedbackAttachedToIncident> >();
            var invoker = new MessageInvoker(arg);

            invoker.HandlerMissing += (sender, args) =>
            {
                _logger.Warn(
                    "Failed to find a handler for " + args.Message.Body.GetType());
            };
            invoker.HandlerInvoked += (sender, args) =>
            {
                if (args.Exception == null)
                {
                    return;
                }

                Err.Report(args.Exception,
                           new { args.Message, HandlerType = args.Handler.GetType(), args.ExecutionTime });
                _logger.Error(
                    $"Ran {args.Handler}, took {args.ExecutionTime.TotalMilliseconds}ms, but FAILED.",
                    args.Exception);
            };
            return(invoker);
        }
 public HandlerInvokedEventArgs(IHandlerScope scope, object handler, Message message, object applicationState,
                                TimeSpan executionTime)
 {
     Scope            = scope;
     Handler          = handler;
     Message          = message;
     ApplicationState = applicationState;
     ExecutionTime    = executionTime;
 }
        public QueueListenerTests(TestDbFixture fixture)
        {
            fixture.ClearQueue("QLInbound");
            _inboundQueue  = fixture.OpenQueue("QLInbound");
            _scopeFactory  = Substitute.For <IHandlerScopeFactory>();
            _queueListener = new QueueListener(_inboundQueue, fixture.OpenQueue("QLOutbound"), _scopeFactory);

            _handlerScope = Substitute.For <IHandlerScope>();
            _scopeFactory.CreateScope().Returns(_handlerScope);
            _messageInvoker = Substitute.For <IMessageInvoker>();
            _handlerScope.ResolveDependency <IMessageInvoker>().Returns(new[] { _messageInvoker });

            this._fixture = fixture;
        }
 public HandlerMissingEventArgs(ClaimsPrincipal user, Message message, IHandlerScope scope)
 {
     User    = user;
     Message = message;
     Scope   = scope;
 }
Example #6
0
 /// <summary>
 ///     Creates a new instance of <see cref="ScopeCreatedEventArgs" />.
 /// </summary>
 /// <param name="scope">Created scope</param>
 /// <param name="principal">Principal attached to the message</param>
 /// <param name="message">Message that triggered the scope creation</param>
 public ScopeCreatedEventArgs(IHandlerScope scope, ClaimsPrincipal principal, Message message)
 {
     Principal = principal;
     Scope     = scope ?? throw new ArgumentNullException(nameof(scope));
     Message   = message ?? throw new ArgumentNullException(nameof(message));
 }
 /// <summary>
 ///     Creates a new instance of <see cref="ScopeClosingEventArgs" />.
 /// </summary>
 /// <param name="scope">Created message scope</param>
 /// <param name="message">Message that triggered the scope creation</param>
 /// <param name="principal"></param>
 /// <param name="applicationState">
 ///     Application state (used by the library used to be able to pass information to the other
 ///     events for the same message)
 /// </param>
 public ScopeClosingEventArgs(IHandlerScope scope, Message message, object applicationState)
 {
     Scope            = scope ?? throw new ArgumentNullException(nameof(scope));
     Message          = message ?? throw new ArgumentNullException(nameof(message));
     ApplicationState = applicationState;
 }
Example #8
0
 public InvokingHandlerEventArgs(IHandlerScope scope, object handler, Message message)
 {
     Scope   = scope ?? throw new ArgumentNullException(nameof(scope));
     Handler = handler;
     Message = message ?? throw new ArgumentNullException(nameof(message));
 }
Example #9
0
 public MessageInvoker(IHandlerScope scope, IOutboundMessageRouter outboundMessageRouter)
 {
     _outboundMessageRouter = outboundMessageRouter;
     _scope = scope ?? throw new ArgumentNullException(nameof(scope));
 }
Example #10
0
 public MessageInvoker(IHandlerScope scope)
 {
     _scope = scope ?? throw new ArgumentNullException(nameof(scope));
 }