/// <summary> /// Creates the pool. /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="maxGrowSize">Maximum size of the grow.</param> /// <returns></returns> public IRMQPool CreatePool(IRMQConfigurationManager configuration, int maxGrowSize = 3) { var senderReceiverFactory = CreateSenderReceiverFactory(); var pool = new RMQPool(configuration, senderReceiverFactory, maxGrowSize); return(pool); }
static void SimplePoolTest() { var configManager = CreateConfigurationManager(); var consumerFactory = new RMQConsumerFactory(new RMQConnectionFactory()); var producerFactory = new RMQProducerFactory(new RMQConnectionFactory()); var subscriberFactory = new RMQSubscriberFactory(new RMQConnectionFactory()); var publisherFactory = new RMQPublisherFactory(new RMQConnectionFactory()); var factory = new RMQSenderReceiverFactory(consumerFactory, producerFactory, subscriberFactory, publisherFactory); using (var rmqPool = new RMQPool(configManager, factory, 5)) { using (var producer = rmqPool.Get <IRMQProducerText>("connection", "MY_RMQ_TEST")) { producer.Instance.Send("Simple test"); } } }
static void PoolThreadTest() { var configManager = CreateConfigurationManager(); var consumerFactory = new RMQConsumerFactory(new RMQConnectionFactory()); var producerFactory = new RMQProducerFactory(new RMQConnectionFactory()); var subscriberFactory = new RMQSubscriberFactory(new RMQConnectionFactory()); var publisherFactory = new RMQPublisherFactory(new RMQConnectionFactory()); var factory = new RMQSenderReceiverFactory(consumerFactory, producerFactory, subscriberFactory, publisherFactory); using (var rmqPool = new RMQPool(configManager, factory, 2)) { for (var i = 0; i < 10; i++) { var t = new Thread(PoolThreadTestThread); t.Start(new Tuple <RMQPool, int>(rmqPool, i)); } Console.WriteLine("Waiting for Tasks to complete..."); Console.ReadKey(); Console.WriteLine("Show have terminated."); } }