예제 #1
0
        /// <summary>
        /// Init instance options and starts the connections
        /// </summary>
        private void InitInstances()
        {
            if (Options.Instances == null || Options.Instances.Length < 1)
            {
                return;
            }

            _connectors = new TmqStickyConnector[Options.Instances.Length];

            for (int i = 0; i < _connectors.Length; i++)
            {
                InstanceOptions options   = Options.Instances[i];
                TimeSpan        reconnect = TimeSpan.FromMilliseconds(options.ReconnectWait);

                TmqStickyConnector connector = options.KeepMessages
                                                   ? new TmqAbsoluteConnector(reconnect, () => CreateInstanceClient(options))
                                                   : new TmqStickyConnector(reconnect, () => CreateInstanceClient(options));

                _connectors[i] = connector;
                connector.Tag  = options;

                connector.AddHost(options.Host);
                connector.Run();
            }
        }
예제 #2
0
        public Consumer()
        {
            _connector = new TmqStickyConnector(TimeSpan.FromSeconds(5), () =>
            {
                TmqClient client = new TmqClient();
                client.ClientId  = "consumer-id";
                client.SetClientType("consumer");
                client.SetClientToken("anonymous");
                client.AutoAcknowledge = true;

                return(client);
            });
        }
예제 #3
0
파일: NodeServer.cs 프로젝트: ciker/twino
        /// <summary>
        /// Inits node options and starts the connections
        /// </summary>
        public void Initialize()
        {
            if (Server.Options.Nodes == null || Server.Options.Nodes.Length < 1)
            {
                return;
            }

            Connectors = new TmqStickyConnector[Server.Options.Nodes.Length];

            for (int i = 0; i < Connectors.Length; i++)
            {
                NodeOptions options   = Server.Options.Nodes[i];
                TimeSpan    reconnect = TimeSpan.FromMilliseconds(options.ReconnectWait);

                TmqStickyConnector connector = options.KeepMessages
                                                   ? new TmqAbsoluteConnector(reconnect, () => CreateInstanceClient(options))
                                                   : new TmqStickyConnector(reconnect, () => CreateInstanceClient(options));

                Connectors[i] = connector;
                connector.Tag = options;

                connector.AddHost(options.Host);
            }
        }
 internal TwinoRouteBus(TmqStickyConnector connector) : base(connector)
 {
 }
예제 #5
0
 internal TwinoQueueBus(TmqStickyConnector connector) : base(connector)
 {
 }
예제 #6
0
 internal TwinoDirectBus(TmqStickyConnector connector) : base(connector)
 {
 }
예제 #7
0
 internal TwinoBus(TmqStickyConnector connector) : base(connector)
 {
     Direct = new TwinoDirectBus <TIdentifier>(connector);
     Queue  = new TwinoQueueBus <TIdentifier>(connector);
     Route  = new TwinoRouteBus <TIdentifier>(connector);
 }