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); }
public Listener(ListenerFactoryContext context) { _dispatchQueue = context.GetDispatchQueue(new SimpleHandler(context.Executor)); }