Exemple #1
0
 public override HandlerRegistration <DefaultHandlerConfiguration> RegisterHandler <T>(Func <IMessage <T>, object> processMessageFn, Action <IMessage <T>, Exception> processExceptionEx, DefaultHandlerConfiguration queueHandlerConfiguration, MessageHandlerConfiguration messageHandlerConfiguration)
 {
     return(new HandlerRegistration <DefaultHandlerConfiguration>(this.CreateMessageHandlerFactory(processMessageFn, processExceptionEx, messageHandlerConfiguration), queueHandlerConfiguration));
 }
Exemple #2
0
 public abstract HandlerRegistration <TQueueHandlerConfiguration> RegisterHandler <T>(Func <IMessage <T>, object> processMessageFn, Action <IMessage <T>, Exception> processExceptionEx, TQueueHandlerConfiguration queueHandlerConfiguration, MessageHandlerConfiguration messageHandlerConfiguration);
Exemple #3
0
        // TODO:Add 'Retry Count' to default config parameters? Request/Response Filters?
        // TODO: Add Error Count to Queue (And Msg?) BG Handlers
        // TODO: Switch 'Task' approach with std ThreadPool, so it is 3.5 compatable? => Finish.

        protected IMessageHandlerFactory CreateMessageHandlerFactory <T>(Func <IMessage <T>, object> processMessageFn, Action <IMessage <T>, Exception> processExceptionEx, MessageHandlerConfiguration messageHandlerConfiguration)
        {
            messageHandlerConfiguration = messageHandlerConfiguration ?? new MessageHandlerConfiguration();
            return(new MessageHandlerFactory <T>(this.MessageServer, processMessageFn, processExceptionEx)
            {
                RequestFilter = messageHandlerConfiguration.RequestFilter ?? this.RequestFilter,
                ResponseFilter = messageHandlerConfiguration.ResponseFilter ?? this.ResponseFilter,
                RetryCount = messageHandlerConfiguration.RetryCount ?? this.RetryCount
            });
        }
Exemple #4
0
 protected virtual void AddPooledMessageHandler <T>(Func <IMessage <T>, object> processMessageFn, Action <IMessage <T>, Exception> processExceptionEx, TQueueHandlerConfiguration queueHandlerConfiguration, MessageHandlerConfiguration messageHandlerConfiguration)
 {
     // A thread count of 0, indicates that the handler should use the thread pool
     queueHandlerConfiguration             = queueHandlerConfiguration ?? new TQueueHandlerConfiguration();
     queueHandlerConfiguration.NoOfThreads = 0; // 0 => ThreadPool
     this.AddMessageHandler <T>(processMessageFn, processExceptionEx, queueHandlerConfiguration, messageHandlerConfiguration);
 }
Exemple #5
0
        protected virtual void AddMessageHandler <T>(Func <IMessage <T>, object> processMessageFn, Action <IMessage <T>, Exception> processExceptionEx, TQueueHandlerConfiguration queueHandlerConfiguration, MessageHandlerConfiguration messageHandlerConfiguration)
        {
            if (RegisteredHandlers.ContainsKey(typeof(T)))
            {
                throw new ArgumentException("Message handler has already been registered for type: " + typeof(T).Name);
            }

            this.RegisteredHandlers.Add(typeof(T), RegisterHandler(processMessageFn, processExceptionEx, queueHandlerConfiguration, messageHandlerConfiguration));
        }
Exemple #6
0
        protected void AddMessageHandler <T, TResponse>(Func <IMessage <T>, TResponse> processMessageFn, Action <IMessage <T>, Exception> processExceptionEx, TQueueHandlerConfiguration queueHandlerConfiguration, MessageHandlerConfiguration messageHandlerConfiguration)
        {
            if (RegisteredHandlers.ContainsKey(typeof(T)))
            {
                throw new ArgumentException("Message handler has already been registered for type: " + typeof(T).Name);
            }

            var wrappedTypedResponseFn = WrapTypedResponseHandler(processMessageFn);

            this.AddMessageHandler <T>(wrappedTypedResponseFn, processExceptionEx, queueHandlerConfiguration, messageHandlerConfiguration);
            // this.RegisteredHandlers.Add(typeof(T), RegisterHandler(wrappedTypedResponseFn, processExceptionEx, noOfThreads));

            if (typeof(TResponse) == typeof(object))
            {
                return;
            }

            this.ResponseMessageTypes.Add(typeof(TResponse)); //// Need to enable queue creation
        }
Exemple #7
0
        protected void AddPooledMessageHandler <T, TResponse>(Func <IMessage <T>, TResponse> processMessageFn, Action <IMessage <T>, Exception> processExceptionEx, TQueueHandlerConfiguration queueHandlerConfiguration, MessageHandlerConfiguration messageHandlerConfiguration)
        {
            // A thread count of 0, indicates that the handler should use the thread pool
            var wrappedTypedResponseFn = WrapTypedResponseHandler(processMessageFn);

            this.AddPooledMessageHandler <T>(wrappedTypedResponseFn, processExceptionEx, queueHandlerConfiguration, messageHandlerConfiguration);

            if (typeof(TResponse) == typeof(object))
            {
                return;
            }

            this.ResponseMessageTypes.Add(typeof(TResponse)); //// Need to enable queue creation
        }
Exemple #8
0
        public void AddHandler <T>(Action <IMessage <T> > processMessageFn, Action <IMessage <T>, Exception> processExceptionEx, TQueueHandlerConfiguration queueHandlerConfiguration = null, MessageHandlerConfiguration messageHandlerConfiguration = null)
        {
            var wrappedMessageFn = WrapActionHandler(processMessageFn);

            this.AddMessageHandler(wrappedMessageFn, processExceptionEx, queueHandlerConfiguration, messageHandlerConfiguration);
        }
Exemple #9
0
 public void AddHandler <T>(Action <IMessage <T> > processMessageFn, TQueueHandlerConfiguration queueHandlerConfiguration = null, MessageHandlerConfiguration messageHandlerConfiguration = null)
 {
     this.AddHandler(processMessageFn, null, queueHandlerConfiguration, messageHandlerConfiguration);
 }
Exemple #10
0
 public void AddHandler <T, TResponse>(Func <IMessage <T>, TResponse> processMessageFn, Action <IMessage <T>, Exception> processExceptionEx, TQueueHandlerConfiguration queueHandlerConfiguration = null, MessageHandlerConfiguration messageHandlerConfiguration = null)
 {
     this.AddMessageHandler(processMessageFn, processExceptionEx, queueHandlerConfiguration, messageHandlerConfiguration);
 }
Exemple #11
0
 public void AddHandler <T, TResponse>(Func <IMessage <T>, TResponse> processMessageFn, TQueueHandlerConfiguration queueHandlerConfiguration = null, MessageHandlerConfiguration messageHandlerConfiguration = null)
 {
     this.AddHandler(processMessageFn, null, queueHandlerConfiguration, messageHandlerConfiguration);
 }
Exemple #12
0
        public void AddPooledHandler <T>(Action <IMessage <T> > processMessageFn, Action <IMessage <T>, Exception> processExceptionEx, TQueueHandlerConfiguration queueHandlerConfiguration = null, MessageHandlerConfiguration messageHandlerConfiguration = null)
        {
            // A thread count of 0, indicates that the handler should use the thread pool
            var wrappedMessageFn = WrapActionHandler(processMessageFn);

            this.AddPooledMessageHandler(wrappedMessageFn, processExceptionEx, queueHandlerConfiguration, messageHandlerConfiguration);
            //this.AddMessageHandler(wrappedMessageFn, processExceptionEx, 0);
        }