コード例 #1
0
        public IDispatchQueueHandler GetDispatchQueue(IMessageHandler handler)
        {
            if (_dispatchQueue == null)
            {
                if (handler == null)
                {
                    throw new InvalidOperationException("Please provide a call back function");
                }

                if (_sharedQueue.RegisterHandler(Descriptor.Id, handler))
                {
                    _dispatchQueue = new DispatchQueueHandler(_sharedQueue, Descriptor.Id);
                }
                else
                {
                    // failed to register messageHandler, fall back to in memory implementation
                    _dispatchQueue = new InMemoryDispatchQueueHandler(handler);
                }
            }
            else if (handler != null)
            {
                throw new InvalidOperationException("Cannot register more than one handler with a single function");
            }

            return(_dispatchQueue);
        }
コード例 #2
0
 public Listener(ListenerFactoryContext context)
 {
     _dispatchQueue = context.GetDispatchQueue(new SimpleHandler(context.Executor));
 }