Register() public method

public Register ( string command, RequestHandler handler ) : TcpMessageDispatcher
command string
handler RequestHandler
return TcpMessageDispatcher
Esempio n. 1
0
        public QueueEndpoint(QueueStorage storage, ResConfiguration config)
        {
            var ctx = NetMQContext.Create();
            _ctx = ctx;

            var outBuffer = new OutBuffer(config.QueueEndpoint.BufferSize);
            var dispatcher = new TcpMessageDispatcher();

            dispatcher.Register(ResCommands.SubscribeToQueue, new Queues.SubscribeHandler(storage, outBuffer));
            dispatcher.Register(ResCommands.AcknowledgeQueue, new Queues.AcknowledgeHandler(storage, outBuffer));

            MessageProcessor messageProcessor = new TcpIncomingMessageProcessor(dispatcher);
            messageProcessor = new ErrorHandlingMessageProcessor(messageProcessor);

            //important...the factory method parameter must "create" the gateway, threading issue otherwise.
            Logger.Debug("[QueueEndpoint] Initialising Transceiver. Endpoint: {0}", config.QueueEndpoint.Endpoint);
            _transceiver = new Transceiver(() => new TcpGateway(ctx, config.QueueEndpoint.Endpoint, messageProcessor), outBuffer);
        }
Esempio n. 2
0
        public PublishEndpoint(EventStorageWriter eventStorageWriter, ResConfiguration config)
        {
            var ctx = NetMQContext.Create();
            _ctx = ctx;

            var outBuffer = new OutBuffer(config.PublishEndpoint.BufferSize);
            var dispatcher = new TcpMessageDispatcher();

            dispatcher.Register(ResCommands.AppendCommit, new CommitHandler(eventStorageWriter, outBuffer));

            MessageProcessor messageProcessor = new TcpIncomingMessageProcessor(dispatcher);
            messageProcessor = new ErrorHandlingMessageProcessor(messageProcessor);

            //important...the factory method parameter must "create" the gateway, threading issue otherwise.
            Logger.Debug("[CommitEndpoint] Initialising Transceiver. Endpoint: {0}", config.PublishEndpoint.Endpoint);
            _transceiver = new Transceiver(() => new TcpGateway(ctx, config.PublishEndpoint.Endpoint, messageProcessor), outBuffer);
        }