public void TestTransactionalLowLevel() { var template = new RabbitTemplate(); var connectionFactory = new CachingConnectionFactory(); connectionFactory.Port = BrokerTestUtils.GetPort(); template.ConnectionFactory = connectionFactory; var blockingQueueConsumer = new BlockingQueueConsumer(connectionFactory, new DefaultMessagePropertiesConverter(), new ActiveObjectCounter<BlockingQueueConsumer>(), AcknowledgeModeUtils.AcknowledgeMode.Auto, true, 1, queue.Name); blockingQueueConsumer.Start(); connectionFactory.Dispose(); // TODO: make this into a proper assertion. An exception can be thrown here by the Rabbit client and printed to // stderr without being rethrown (so hard to make a test fail). blockingQueueConsumer.Stop(); Assert.IsNull(template.ReceiveAndConvert(queue.Name)); }
/// <summary> /// Creates the consumer. /// </summary> /// <param name="accessor">The accessor.</param> /// <returns>The consumer.</returns> /// <remarks></remarks> private BlockingQueueConsumer CreateConsumer(RabbitAccessor accessor) { var consumer = new BlockingQueueConsumer(accessor.ConnectionFactory, new ActiveObjectCounter<BlockingQueueConsumer>(), AcknowledgeModeUtils.AcknowledgeMode.AUTO, true, 1, 0, queue.Name); consumer.Start(); return consumer; }
/// <summary>Creates the consumer.</summary> /// <param name="accessor">The accessor.</param> /// <returns>The consumer.</returns> private BlockingQueueConsumer CreateConsumer(RabbitAccessor accessor) { var consumer = new BlockingQueueConsumer(accessor.ConnectionFactory, new DefaultMessagePropertiesConverter(), new ActiveObjectCounter<BlockingQueueConsumer>(), AcknowledgeModeUtils.AcknowledgeMode.Auto, true, 1, queue.Name); consumer.Start(); // wait for consumeOk... var n = 0; while (n++ < 100) { if (consumer.ConsumerTag == null) { try { Thread.Sleep(100); } catch (ThreadInterruptedException e) { Thread.CurrentThread.Interrupt(); break; } } } return consumer; }