示例#1
0
 private void Init(RabbitMqMessageFactory messageFactory)
 {
     this.messageFactory = messageFactory;
     this.ErrorHandler   = ex => Log.Error("Exception in Rabbit MQ Server: " + ex.Message, ex);
     RetryCount          = DefaultRetryCount;
     AutoReconnect       = true;
 }
示例#2
0
        public void Can_Send_Email_via_MqClient()
        {
            var mqFactory = new RabbitMqMessageFactory();

            using (var mqClient = mqFactory.CreateMessageQueueClient())
            {
                mqClient.Publish(new EmailContact { ContactId = 1, Subject = "UnitTest MQ Email #1", Body = "Body 1" });
                mqClient.Publish(new EmailContact { ContactId = 1, Subject = "UnitTest MQ Email #2", Body = "Body 2" });
            }
        }
示例#3
0
 public RabbitMqWorker(RabbitMqMessageFactory mqFactory,
                       IMessageHandler messageHandler, string queueName,
                       Action <RabbitMqWorker, Exception> errorHandler,
                       bool autoConnect = true)
 {
     this.mqFactory      = mqFactory;
     this.messageHandler = messageHandler;
     this.QueueName      = queueName;
     this.errorHandler   = errorHandler;
     this.AutoReconnect  = autoConnect;
 }
示例#4
0
 public RabbitMqWorker(RabbitMqMessageFactory mqFactory,
     IMessageHandler messageHandler, string queueName,
     Action<RabbitMqWorker, Exception> errorHandler,
     bool autoConnect = true)
 {
     this.mqFactory = mqFactory;
     this.messageHandler = messageHandler;
     this.QueueName = queueName;
     this.errorHandler = errorHandler;
     this.AutoReconnect = autoConnect;
 }
        public void Can_publish_and_receive_messages_with_MessageFactory()
        {
            using (var mqFactory = new RabbitMqMessageFactory("localhost"))
            using (var mqClient = mqFactory.CreateMessageQueueClient())
            {
                mqClient.Publish(new Hello { Name = "Foo" });
                var msg = mqClient.Get<Hello>(QueueNames<Hello>.In);

                Assert.That(msg.GetBody().Name, Is.EqualTo("Foo"));
            }
        }
示例#6
0
 public RabbitMqProducer(RabbitMqMessageFactory msgFactory)
 {
     this.msgFactory = msgFactory;
 }
 public RabbitMqQueueClient(RabbitMqMessageFactory msgFactory)
     : base(msgFactory)
 {
 }
示例#8
0
 public RabbitMqServer(RabbitMqMessageFactory messageFactory)
 {
     Init(messageFactory);
 }