/// <summary> /// 訂閱頻道 /// </summary> /// <param name="channel"></param> /// <returns></returns> public bool CreateChannelListener(string channel) { if (IsConnected == false) { throw new IOException("Connection error"); } ConsumerManager consumerManager = new ConsumerManager() { Channel = channel }; if (_listenChannels.TryAdd(channel, consumerManager)) { IModel model = _connection.CreateModel(); if (last != null) { last = model; } var consumer = new EventingBasicConsumer(model); BindReceiveMessageEvent(model, channel, consumer); string consumerTag = model.BasicConsume(channel, false, consumer); consumerManager.Model = model; consumerManager.ConsumerTag = consumerTag; Console.WriteLine("監聽: " + channel); return(true); } return(false); }
public void Should_catch_all_exception_when_dispose_consumers() { // Arrange var autoResetEvent = new AutoResetEvent(false); var model = Substitute.For<IModel>(); var watcher = Substitute.For<IRabbitWatcher>(); watcher.When(w => w.InfoFormat(Arg.Any<string>(), Arg.Any<object[]>())) .Do(callinfo => { throw new Exception(); }); var handlerFactory = Substitute.For<IMessageHandlerFactory>(); var handler = Substitute.For<IMessageHandler>(); handlerFactory.Create(Arg.Any<string>(), Arg.Any<Action<int, MessageDeliverEventArgs>>()).Returns(handler); handler.When(h => h.HandleMessage(Arg.Any<BasicDeliverEventArgs>())) .Do(callInfo => autoResetEvent.Set()); var consumerManager = new ConsumerManager(watcher, handlerFactory, Substitute.For<ISerializer>()); var consumer = consumerManager.CreateConsumer<int>(model, "", x => { }, null); //To make it wait when dispose the BurrowConsumer ((QueueingBasicConsumer)consumer).Queue.Enqueue(new BasicDeliverEventArgs()); // Action autoResetEvent.WaitOne(); consumerManager.ClearConsumers(); // Assert watcher.Received(1).Error(Arg.Any<Exception>()); }
public IConsumerManager Create(IConsumerConfiguration configuration, IDependencyResolver resolver) { var logHandler = resolver.Resolve <ILogHandler>(); var middlewares = configuration.MiddlewareConfiguration.Factories .Select(factory => factory(resolver)) .ToList(); var consumer = new Consumer(configuration, logHandler); var consumerWorkerPool = new ConsumerWorkerPool( consumer, resolver, logHandler, new MiddlewareExecutor(middlewares), configuration.DistributionStrategyFactory); var feeder = new WorkerPoolFeeder( consumer, consumerWorkerPool, logHandler); var consumerManager = new ConsumerManager( consumer, consumerWorkerPool, feeder, logHandler); return(consumerManager); }
private BrokerController(BrokerSetting setting) { Setting = setting ?? new BrokerSetting(); Setting.BrokerInfo.Valid(); if (Setting.NameServerList == null || Setting.NameServerList.Count() == 0) { throw new ArgumentException("NameServerList is empty."); } _latestMessageIds = new string[Setting.LatestMessageShowCount]; _producerManager = ObjectContainer.Resolve <ProducerManager>(); _consumerManager = ObjectContainer.Resolve <ConsumerManager>(); _messageStore = ObjectContainer.Resolve <IMessageStore>(); _consumeOffsetStore = ObjectContainer.Resolve <IConsumeOffsetStore>(); _queueStore = ObjectContainer.Resolve <IQueueStore>(); _getTopicConsumeInfoListService = ObjectContainer.Resolve <GetTopicConsumeInfoListService>(); _getConsumerListService = ObjectContainer.Resolve <GetConsumerListService>(); _scheduleService = ObjectContainer.Resolve <IScheduleService>(); _binarySerializer = ObjectContainer.Resolve <IBinarySerializer>(); _suspendedPullRequestManager = ObjectContainer.Resolve <SuspendedPullRequestManager>(); _chunkReadStatisticService = ObjectContainer.Resolve <IChunkStatisticService>(); _tpsStatisticService = ObjectContainer.Resolve <ITpsStatisticService>(); _producerSocketRemotingServer = new SocketRemotingServer("EQueue.Broker.ProducerRemotingServer", Setting.BrokerInfo.ProducerAddress.ToEndPoint(), Setting.SocketSetting); _consumerSocketRemotingServer = new SocketRemotingServer("EQueue.Broker.ConsumerRemotingServer", Setting.BrokerInfo.ConsumerAddress.ToEndPoint(), Setting.SocketSetting); _adminSocketRemotingServer = new SocketRemotingServer("EQueue.Broker.AdminRemotingServer", Setting.BrokerInfo.AdminAddress.ToEndPoint(), Setting.SocketSetting); _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(GetType().FullName); _producerSocketRemotingServer.RegisterConnectionEventListener(new ProducerConnectionEventListener(this)); _consumerSocketRemotingServer.RegisterConnectionEventListener(new ConsumerConnectionEventListener(this)); RegisterRequestHandlers(); _nameServerRemotingClientList = Setting.NameServerList.ToRemotingClientList(Setting.SocketSetting).ToList(); }
public override ITunnel Create(string hostName, string virtualHost, string username, string password, IRabbitWatcher watcher) { if (RabbitTunnel.Factory is DependencyInjectionTunnelFactory) { return RabbitTunnel.Factory.Create(hostName, virtualHost, username, password, watcher); } var rabbitWatcher = watcher ?? Global.DefaultWatcher; var connectionFactory = new RabbitMQ.Client.ConnectionFactory { HostName = hostName, VirtualHost = virtualHost, UserName = username, Password = password }; var durableConnection = new DurableConnection(new DefaultRetryPolicy(), rabbitWatcher, connectionFactory); var errorHandler = new ConsumerErrorHandler(connectionFactory, Global.DefaultSerializer, rabbitWatcher); var msgHandlerFactory = new DefaultMessageHandlerFactory(errorHandler, rabbitWatcher); var consumerManager = new ConsumerManager(rabbitWatcher, msgHandlerFactory, Global.DefaultSerializer); return new RabbitTunnelWithPriorityQueuesSupport(consumerManager, rabbitWatcher, new DefaultRouteFinder(), durableConnection, Global.DefaultSerializer, Global.DefaultCorrelationIdGenerator, Global.DefaultPersistentMode); }
public IConsumerManager Create(IConsumerConfiguration configuration, IDependencyResolver resolver) { var logHandler = resolver.Resolve <ILogHandler>(); var consumer = configuration.CustomFactory(new Consumer(configuration, resolver, logHandler), resolver); var consumerWorkerPool = new ConsumerWorkerPool( consumer, resolver, new MiddlewareExecutor(configuration.MiddlewaresConfigurations), configuration, logHandler); var feeder = new WorkerPoolFeeder( consumer, consumerWorkerPool, logHandler); var consumerManager = new ConsumerManager( consumer, consumerWorkerPool, feeder, logHandler); return(consumerManager); }
public override ITunnel Create(string hostName, string virtualHost, string username, string password, IRabbitWatcher watcher) { if (RabbitTunnel.Factory is DependencyInjectionTunnelFactory) { return(RabbitTunnel.Factory.Create(hostName, virtualHost, username, password, watcher)); } var rabbitWatcher = watcher ?? Global.DefaultWatcher; var connectionFactory = new RabbitMQ.Client.ConnectionFactory { HostName = hostName, VirtualHost = virtualHost, UserName = username, Password = password }; var durableConnection = new DurableConnection(new DefaultRetryPolicy(), rabbitWatcher, connectionFactory); var errorHandler = new ConsumerErrorHandler(connectionFactory, Global.DefaultSerializer, rabbitWatcher); var msgHandlerFactory = new DefaultMessageHandlerFactory(errorHandler, Global.DefaultSerializer, rabbitWatcher); var consumerManager = new ConsumerManager(rabbitWatcher, msgHandlerFactory, Global.DefaultSerializer); var tunnel = new RabbitTunnelWithPriorityQueuesSupport(consumerManager, rabbitWatcher, new DefaultRouteFinder(), durableConnection, Global.DefaultSerializer, Global.DefaultCorrelationIdGenerator, Global.DefaultPersistentMode); tunnel.AddSerializerObserver(errorHandler); tunnel.AddSerializerObserver(msgHandlerFactory); tunnel.AddSerializerObserver(consumerManager); return(tunnel); }
public QueryConsumerInfoRequestHandler() { _binarySerializer = IocManager.Instance.Resolve <ISerializer <byte[]> >(); _offsetStore = IocManager.Instance.Resolve <IConsumeOffsetStore>(); _consumerManager = IocManager.Instance.Resolve <ConsumerManager>(); _queueStore = IocManager.Instance.Resolve <IQueueStore>(); }
public QueryConsumerInfoRequestHandler() { _binarySerializer = ObjectContainer.Resolve <IBinarySerializer>(); _offsetManager = ObjectContainer.Resolve <IOffsetManager>(); _consumerManager = ObjectContainer.Resolve <ConsumerManager>(); _queueService = ObjectContainer.Resolve <IQueueService>(); }
public virtual ITunnel Create(string hostName, string virtualHost, string username, string password, IRabbitWatcher watcher) { var rabbitWatcher = watcher ?? Global.DefaultWatcher; var connectionFactory = new RabbitMQ.Client.ConnectionFactory { HostName = hostName, VirtualHost = virtualHost, UserName = username, Password = password }; var durableConnection = new DurableConnection(new DefaultRetryPolicy(), rabbitWatcher, connectionFactory); var errorHandler = new ConsumerErrorHandler(connectionFactory, Global.DefaultSerializer, rabbitWatcher); var msgHandlerFactory = new DefaultMessageHandlerFactory(errorHandler, Global.DefaultSerializer, rabbitWatcher); var consumerManager = new ConsumerManager(rabbitWatcher, msgHandlerFactory, Global.DefaultSerializer); var tunnel = new RabbitTunnel(consumerManager, rabbitWatcher, new DefaultRouteFinder(), durableConnection, Global.DefaultSerializer, Global.DefaultCorrelationIdGenerator, Global.DefaultPersistentMode); tunnel.AddSerializerObserver(errorHandler); tunnel.AddSerializerObserver(msgHandlerFactory); tunnel.AddSerializerObserver(consumerManager); return tunnel; }
public void Should_catch_all_exception_when_dispose_consumers() { // Arrange var autoResetEvent = new AutoResetEvent(false); var model = Substitute.For <IModel>(); var watcher = Substitute.For <IRabbitWatcher>(); watcher.When(w => w.InfoFormat(Arg.Any <string>(), Arg.Any <object[]>())) .Do(callinfo => { throw new Exception(); }); var handlerFactory = Substitute.For <IMessageHandlerFactory>(); var handler = Substitute.For <IMessageHandler>(); handlerFactory.Create(Arg.Any <string>(), Arg.Any <Action <int, MessageDeliverEventArgs> >()).Returns(handler); handler.When(h => h.HandleMessage(Arg.Any <BasicDeliverEventArgs>())) .Do(callInfo => autoResetEvent.Set()); var consumerManager = new ConsumerManager(watcher, handlerFactory, Substitute.For <ISerializer>()); var consumer = consumerManager.CreateConsumer <int>(model, "", x => { }, null); //To make it wait when dispose the BurrowConsumer ((QueueingBasicConsumer)consumer).Queue.Enqueue(new BasicDeliverEventArgs()); // Action autoResetEvent.WaitOne(); consumerManager.ClearConsumers(); // Assert watcher.Received(1).Error(Arg.Any <Exception>()); }
protected override void OnSpawn() { base.OnSpawn(); instance = this; RefreshDiscovered(null); WorldInventory.Instance.OnDiscover += OnWorldInventoryDiscover; Game.Instance.Subscribe(-107300940, RefreshDiscovered); }
public PullMessageRequestHandler() { _consumerManager = ObjectContainer.Resolve <ConsumerManager>(); _suspendedPullRequestManager = ObjectContainer.Resolve <SuspendedPullRequestManager>(); _messageStore = ObjectContainer.Resolve <IMessageStore>(); _queueStore = ObjectContainer.Resolve <IQueueStore>(); _offsetStore = ObjectContainer.Resolve <IConsumeOffsetStore>(); _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(GetType().FullName); }
public override ITunnel Create(string hostName, string virtualHost, string username, string password, IRabbitWatcher watcher) { var rabbitWatcher = watcher ?? _burrowResolver.Resolve <IRabbitWatcher>() ?? Global.DefaultWatcher; var serializer = _burrowResolver.Resolve <ISerializer>() ?? Global.DefaultSerializer; var connectionFactory = new RabbitMQ.Client.ConnectionFactory { HostName = hostName, VirtualHost = virtualHost, UserName = username, Password = password }; var durableConnection = new DurableConnection(_burrowResolver.Resolve <IRetryPolicy>() ?? new DefaultRetryPolicy(), rabbitWatcher, connectionFactory); var abc = new ObjectObserver <IObserver <ISerializer> >(); Func <IConsumerErrorHandler> errorHandler = () => { var handdler = new ConsumerErrorHandler(connectionFactory, serializer, rabbitWatcher); abc.FireEvent(handdler); return(handdler); }; Func <IMessageHandlerFactory> handlerFactory = () => { var factory = new DefaultMessageHandlerFactory(_burrowResolver.Resolve <IConsumerErrorHandler>() ?? errorHandler(), serializer, rabbitWatcher); abc.FireEvent(factory); return(factory); }; Func <IConsumerManager> consumerManager = () => { var manager = new ConsumerManager(rabbitWatcher, _burrowResolver.Resolve <IMessageHandlerFactory>() ?? handlerFactory(), serializer); abc.FireEvent(manager); return(manager); }; var tunnel = new RabbitTunnel(_burrowResolver.Resolve <IConsumerManager>() ?? consumerManager(), rabbitWatcher, _burrowResolver.Resolve <IRouteFinder>() ?? new DefaultRouteFinder(), durableConnection, serializer, _burrowResolver.Resolve <ICorrelationIdGenerator>() ?? Global.DefaultCorrelationIdGenerator, Global.DefaultPersistentMode); abc.ObjectCreated += tunnel.AddSerializerObserver; return(tunnel); }
public PullMessageRequestHandler() { _consumerManager = ObjectContainer.Resolve <ConsumerManager>(); _suspendedPullRequestManager = ObjectContainer.Resolve <SuspendedPullRequestManager>(); _messageService = ObjectContainer.Resolve <IMessageService>(); _queueService = ObjectContainer.Resolve <IQueueService>(); _offsetManager = ObjectContainer.Resolve <IOffsetManager>(); _binarySerializer = ObjectContainer.Resolve <IBinarySerializer>(); _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(GetType().FullName); EmptyResponseData = new byte[0]; }
private void btnStartService_Click(object sender, EventArgs e) { //string localdb = "Database=Demo;uid=admin; pwd=frank;Server=localhost"; //string localdb = "server=192.168.100.7;database=GZPT_Center;uid=sa;pwd=chainway-123"; //string localdb = "Database=gbnav;UserID =db2admin; Password=chainway-db2;Server=192.168.100.51:50000"; //string localdb = "Database =GBNAV; UserID =db2admin; Password =chainway-db2; Server =203.86.28.34:50123"; ConsumerManager manager = new ConsumerManager(); manager.StartConsumer(MQFactory.Consumerconfig[0]); }
public void StartInitialization() { ILoggerFactory connectionLoggerFactory = LoggerFactory.Create(""); IRmqLogger connectionLogger = connectionLoggerFactory.CreateLogger(nameof(ConnectionWrapper)); connection = new ConnectionWrapper(config, connectionLogger); IModel rpcCh = connection.CreateChannel(); rpcChannelPool = channelPoolFactory.CreateChannelPool(rpcCh); IConsumerBinder rpcConsumerBinder = new RpcConsumerBinder(); IConsumerFactory rpcConsumerFactory = new ConsumerFactory( rpcChannelPool.GetChannelWrapper(), rpcConsumerBinder); ILoggerFactory loggerFactory = LoggerFactory.Create(ConsumerType.Rpc.ToString()); IRmqLogger managerLogger = loggerFactory.CreateLogger(nameof(ConsumerManager)); IConsumerManager rpcConsumerManager = new ConsumerManager( rpcConsumerFactory, managerLogger); rpcConsumerManager.InitConsumer(); IMainConsumerEventHandlerFactory rpcMainEventHandlerFactory = ConsumerEventHandlersFactory.Create(rpcConsumerManager, loggerFactory); IConsumerMainEventHandlers rpcConsumerMainEventHandler = rpcMainEventHandlerFactory.CreateMainHandler(); IRmqLogger connectionHandlerLogger = loggerFactory.CreateLogger(nameof(ConnectionEventHandlers)); IConnectionEventsHandlerFactory connectionEventsHandlerFactory = ConnectionEventsHandlerFactory.Create(connectionHandlerLogger, connection); IConnectionEventHandlers connectionEventHandler = connectionEventsHandlerFactory.CreateHandler(); IRmqLogger channelGuardLogger = loggerFactory.CreateLogger(nameof(ChannelGuardService)); this.channelGuardService = new ChannelGuardService( rpcChannelPool, // <--- TODO только rpc? channelGuardLogger, connectionEventHandler, rpcConsumerMainEventHandler); // Подписка на ответы запросов rpc responseMessageHandler = responseMessageHandlerFactory.GetHandler(); rpcConsumerMainEventHandler.AddReceiveHandler(responseMessageHandler.HandleMessage); }
public BrokerController(BrokerSetting setting) { Setting = setting ?? new BrokerSetting(); SuspendedPullRequestManager = new SuspendedPullRequestManager(); ConsumerManager = new ConsumerManager(); _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(GetType().FullName); _messageService = ObjectContainer.Resolve <IMessageService>(); _producerSocketRemotingServer = new SocketRemotingServer("ProducerRemotingServer", Setting.ProducerSocketSetting, new ProducerSocketEventListener(this)); _consumerSocketRemotingServer = new SocketRemotingServer("ConsumerRemotingServer", Setting.ConsumerSocketSetting, new ConsumerSocketEventListener(this)); _clientManager = new ClientManager(this); _messageService.SetBrokerContrller(this); }
void InitSingleton() { if (consumerManager == null) { consumerManager = this; } else if (consumerManager != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); }
private BrokerController(BrokerSetting setting) { Setting = setting ?? new BrokerSetting(); _consumerManager = ObjectContainer.Resolve <ConsumerManager>(); _messageStore = ObjectContainer.Resolve <IMessageStore>(); _offsetManager = ObjectContainer.Resolve <IOffsetManager>(); _queueService = ObjectContainer.Resolve <IQueueService>(); _messageService = ObjectContainer.Resolve <IMessageService>(); _suspendedPullRequestManager = ObjectContainer.Resolve <SuspendedPullRequestManager>(); _producerSocketRemotingServer = new SocketRemotingServer("EQueue.Broker.ProducerRemotingServer", Setting.ProducerIPEndPoint); _consumerSocketRemotingServer = new SocketRemotingServer("EQueue.Broker.ConsumerRemotingServer", Setting.ConsumerIPEndPoint, this); _adminSocketRemotingServer = new SocketRemotingServer("EQueue.Broker.AdminRemotingServer", Setting.AdminIPEndPoint); _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(GetType().FullName); RegisterRequestHandlers(); }
public KafkaConfiguration Build() { var configuration = new KafkaConfiguration(); configuration.AddClusters(this.clusters.Select(x => x.Build(configuration))); var consumerManager = new ConsumerManager(); this.dependencyConfigurator .AddSingleton(typeof(ILogHandler), this.logHandler) .AddSingleton <IConsumerAccessor>(consumerManager) .AddSingleton <IConsumerManager>(consumerManager); return(configuration); }
private ITunnel Create(DurableConnection durableConnection, IRabbitWatcher rabbitWatcher) { var errorHandler = new ConsumerErrorHandler(() => durableConnection.ConnectionFactory, Global.DefaultSerializer, rabbitWatcher); var msgHandlerFactory = new PriorityMessageHandlerFactory(errorHandler, Global.DefaultSerializer, rabbitWatcher); var consumerManager = new ConsumerManager(rabbitWatcher, msgHandlerFactory, Global.DefaultSerializer); var tunnel = new RabbitTunnelWithPriorityQueuesSupport(consumerManager, rabbitWatcher, new DefaultRouteFinder(), durableConnection, Global.DefaultSerializer, Global.DefaultCorrelationIdGenerator, Global.DefaultPersistentMode); tunnel.AddSerializerObserver(errorHandler); tunnel.AddSerializerObserver(msgHandlerFactory); tunnel.AddSerializerObserver(consumerManager); return tunnel; }
private ITunnel Create(IDurableConnection durableConnection, IRabbitWatcher rabbitWatcher) { var errorHandler = new ConsumerErrorHandler(durableConnection, Global.DefaultSerializer, rabbitWatcher); var msgHandlerFactory = new DefaultMessageHandlerFactory(errorHandler, Global.DefaultSerializer, rabbitWatcher); var consumerManager = new ConsumerManager(rabbitWatcher, msgHandlerFactory, Global.DefaultSerializer); var tunnel = new RabbitTunnel(consumerManager, rabbitWatcher, new DefaultRouteFinder(), durableConnection, Global.DefaultSerializer, Global.DefaultCorrelationIdGenerator, Global.DefaultPersistentMode); tunnel.AddSerializerObserver(errorHandler); tunnel.AddSerializerObserver(msgHandlerFactory); tunnel.AddSerializerObserver(consumerManager); return(tunnel); }
private ITunnel Create(DurableConnection durableConnection, ISerializer serializer, IRabbitWatcher rabbitWatcher) { var abc = new ObjectObserver <IObserver <ISerializer> >(); Func <IConsumerErrorHandler> errorHandler = () => { var handdler = new ConsumerErrorHandler(durableConnection, serializer, rabbitWatcher); abc.FireEvent(handdler); return(handdler); }; Func <IMessageHandlerFactory> handlerFactory = () => { var factory = new DefaultMessageHandlerFactory(_burrowResolver.Resolve <IConsumerErrorHandler>() ?? errorHandler(), serializer, rabbitWatcher); abc.FireEvent(factory); return(factory); }; Func <IConsumerManager> consumerManager = () => { var manager = new ConsumerManager(rabbitWatcher, _burrowResolver.Resolve <IMessageHandlerFactory>() ?? handlerFactory(), serializer); abc.FireEvent(manager); return(manager); }; var tunnel = new RabbitTunnel(_burrowResolver.Resolve <IConsumerManager>() ?? consumerManager(), rabbitWatcher, _burrowResolver.Resolve <IRouteFinder>() ?? new DefaultRouteFinder(), durableConnection, serializer, _burrowResolver.Resolve <ICorrelationIdGenerator>() ?? Global.DefaultCorrelationIdGenerator, Global.DefaultPersistentMode); abc.ObjectCreated += tunnel.AddSerializerObserver; return(tunnel); }
private BrokerController(BrokerSetting setting) { Setting = setting ?? new BrokerSetting(); _consumerManager = ObjectContainer.Resolve <ConsumerManager>(); _messageStore = ObjectContainer.Resolve <IMessageStore>(); _consumeOffsetStore = ObjectContainer.Resolve <IConsumeOffsetStore>(); _queueStore = ObjectContainer.Resolve <IQueueStore>(); _suspendedPullRequestManager = ObjectContainer.Resolve <SuspendedPullRequestManager>(); _chunkReadStatisticService = ObjectContainer.Resolve <IChunkStatisticService>(); _producerSocketRemotingServer = new SocketRemotingServer("EQueue.Broker.ProducerRemotingServer", Setting.ProducerAddress, Setting.SocketSetting); _consumerSocketRemotingServer = new SocketRemotingServer("EQueue.Broker.ConsumerRemotingServer", Setting.ConsumerAddress, Setting.SocketSetting); _adminSocketRemotingServer = new SocketRemotingServer("EQueue.Broker.AdminRemotingServer", Setting.AdminAddress, Setting.SocketSetting); _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(GetType().FullName); _consumerSocketRemotingServer.RegisterConnectionEventListener(new ConsumerConnectionEventListener(this)); RegisterRequestHandlers(); _service = new ConsoleEventHandlerService(); _service.RegisterClosingEventHandler(eventCode => { Shutdown(); }); }
public virtual ITunnel Create(string hostName, string virtualHost, string username, string password, IRabbitWatcher watcher) { var connectionFactory = new RabbitMQ.Client.ConnectionFactory { HostName = hostName, VirtualHost = virtualHost, UserName = username, Password = password }; var durableConnection = new DurableConnection(new DefaultRetryPolicy(), watcher, connectionFactory); var errorHandler = new ConsumerErrorHandler(connectionFactory, Global.DefaultSerializer, Global.DefaultWatcher); var consumerManager = new ConsumerManager(watcher, errorHandler, Global.DefaultSerializer, Global.DefaultConsumerBatchSize); return new RabbitTunnel(consumerManager, watcher, Global.DefaultRouteFinder, durableConnection, Global.DefaultSerializer, Global.DefaultCorrelationIdGenerator, Global.DefaultPersistentMode); }
public KafkaConfiguration Build() { var configuration = new KafkaConfiguration(); configuration.AddClusters(this.clusters.Select(x => x.Build(configuration))); this.dependencyConfigurator.AddSingleton <IProducerAccessor>( resolver => new ProducerAccessor( configuration.Clusters .SelectMany(x => x.Producers) .Select( producer => new MessageProducer( resolver, producer)))); var consumerManager = new ConsumerManager(); this.dependencyConfigurator .AddTransient(typeof(ILogHandler), this.logHandler) .AddSingleton <IConsumerAccessor>(consumerManager) .AddSingleton <IConsumerManager>(consumerManager); return(configuration); }
/// <summary> /// Applied after OnSpawn runs. /// </summary> internal static void Postfix(ConsumerManager __instance) { __instance.OnDiscover += TraitReworkUtils.ApplyAllBannedFoods; }
public ConsumerHeartbeatRequestHandler(BrokerController brokerController) { _consumerManager = ObjectContainer.Resolve <ConsumerManager>(); _binarySerializer = ObjectContainer.Resolve <IBinarySerializer>(); }
public QueryConsumerRequestHandler() { _binarySerializer = IocManager.Instance.Resolve <ISerializer <byte[]> >(); _consumerManager = IocManager.Instance.Resolve <ConsumerManager>(); }
static void Main(string[] args) { //var pm = new ProducerManager(new ProducerSetting //{ // BrokerAddress = "127.0.0.1", // BrokerName = "test", // BrokerPort = 8406, // Timeout = 1000, //}); //for (int i = 0; i < 10; i++) //{ // pm.Push(new LindMQ // { // Topic = "zzl", // Body = Lind.DDD.Utils.SerializeMemoryHelper.SerializeToJson(new { Name = "zzl", SortNumber = 10 }) // }); //} //Console.ReadKey(); #region Client-LindMQ var consumer = new ConsumerSetting { BrokenName = "test", BrokenAddress = new System.Net.IPEndPoint(IPAddress.Parse("192.168.2.71"), 8406), Callback = new Dictionary <string, Action <MessageBody> >() { { "zzl", (o) => { Console.WriteLine(o.ToString()); Thread.Sleep(1000); } }, { "zhz", (o) => { Console.WriteLine(o.ToString()); Thread.Sleep(2000); } } } }; var consumerClient = new ConsumerManager(new List <ConsumerSetting> { consumer }); consumerClient.Start(); #endregion Console.ReadKey(); #region Socket-SendQueue //var client2 = new AsyncBinarySocketClient(8192, 8192, 3000, 3000); //client2.RegisterServerNode("127.0.0.1:8404", new System.Net.IPEndPoint(System.Net.IPAddress.Parse("127.0.0.1"), 8404)); //client2.Send("SendQueue", SerializeMemoryHelper.SerializeToBinary("zzl"), res => res.Buffer).ContinueWith(c => //{ // if (c.IsFaulted) // { // throw c.Exception; // } // var entity = SerializeMemoryHelper.DeserializeFromBinary(c.Result) as User; // Console.WriteLine(entity.Name); //}).Wait(); #endregion #region 数据连接 //var client = new DSSBinarySocketClient(8192, 8192, 3000, 3000); //List<Action> actionList = new List<Action>(); //for (int i = 0; i < 100; i++) //{ // actionList.Add(() => // { // #region Socket-DataInsert // //注册服务器节点,这里可注册多个(name不能重复) // client.RegisterServerNode("192.168.2.71:8403", new System.Net.IPEndPoint(System.Net.IPAddress.Parse("192.168.2.71"), 8403)); // client.Send("UserInsert", 1, "zzl", 1, "test" // , SerializeMemoryHelper.SerializeToBinary("hello world!"), res => res.Buffer) // .ContinueWith(c => // { // if (c.IsFaulted) // { // throw c.Exception; // } // Console.WriteLine(DateTime.Now + "result:" + Encoding.UTF8.GetString(c.Result)); // }).Wait(); // Thread.Sleep(1000); // #endregion // }); //} //Parallel.Invoke(actionList.ToArray()); #endregion Console.ReadKey(); }
public GetConsumerIdsForTopicRequestHandler() { _binarySerializer = ObjectContainer.Resolve <IBinarySerializer>(); _consumerManager = ObjectContainer.Resolve <ConsumerManager>(); }
public static void DestroyInstance() { instance = null; }
public DeleteConsumerGroupRequestHandler() { _binarySerializer = ObjectContainer.Resolve <IBinarySerializer>(); _offsetStore = ObjectContainer.Resolve <IConsumeOffsetStore>(); _consumerManager = ObjectContainer.Resolve <ConsumerManager>(); }
public QueryConsumerRequestHandler() { _binarySerializer = ObjectContainer.Resolve <IBinarySerializer>(); _consumerManager = ObjectContainer.Resolve <ConsumerManager>(); }