Exemplo n.º 1
0
        private void DistributeInThreadPool <T>(T @event) where T : IEvent
        {
            if (_eventHandlerFactory == null)
            {
                return;
            }
            var handlers = _eventHandlerFactory.GetHandlers <T>();

            if (handlers != null)
            {
                _busLogger.Received(@event);
                foreach (var handler in handlers)
                {
                    Task.Factory.StartNew(() =>
                    {
                        try
                        {
                            handler.Handle(@event);
                        }
                        catch (Exception ex)
                        {
                            _busLogger.Exception(@event, ex);
                        }
                    });
                }
            }
        }
Exemplo n.º 2
0
        public void Invoke <T>(T @event) where T : IEvent
        {
            var handlers = _eventHandlerFactory.GetHandlers <T>();

            if (handlers != null)
            {
                _busLogger.Received(@event);
                foreach (var handler in handlers)
                {
                    try
                    {
                        // handle event in current thread
                        handler.Handle(@event);
                    }
                    catch (ACE.Exceptions.BusinessException)
                    {
                    }
                    catch (Exception ex)
                    {
                        _busLogger.Exception(@event, ex);
                        throw;
                    }
                }
            }
        }
Exemplo n.º 3
0
        public void Invoke <T>(T action) where T : IAction
        {
            var handler = _actionHandlerFactory.GetHandler <T>();

            if (handler != null)
            {
                _busLogger.Received(action);
                try
                {
                    handler.Invoke(action);
                }
                catch (Exception ex)
                {
                    if (!(ex is ACE.Exceptions.BusinessException))
                    {
                        _busLogger.Exception(action, ex);
                    }
                    throw;
                }
            }
        }