Beispiel #1
0
        public ActionResponse Send <B, T>(T action)
            where B : class, IAction
            where T : B
        {
            _busLogger.Sent(action);
            ActionResponse response = _bus.Request <B, ActionResponse>(action);

            _busLogger.Received(response);
            return(response);
        }
Beispiel #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;
                    }
                }
            }
        }
Beispiel #3
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);
                        }
                    });
                }
            }
        }
Beispiel #4
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;
                }
            }
        }