Пример #1
0
 private static void SendMessage(Payment message)
 {   // we ingroned the routing key which was the queue name. instead we sent the exchange name
     // now only queues bound to this exchange will get the messages
     // each subscriber will get all the messages now
     _model.BasicPublish(ExchangeName, "", null, message.Serialize());
     Console.WriteLine(" Payment Sent {0}, £{1}", message.CardNumber, message.AmountToPay);
 }
Пример #2
0
        public static string MakePayment(Payment payment)
        {
            var corrId = Guid.NewGuid().ToString();
            var props  = _channel.CreateBasicProperties();

            props.ReplyTo       = _replyQueueName;
            props.CorrelationId = corrId;

            _channel.BasicPublish("", "rpc_queue", props, payment.Serialize());

            while (true)
            {
                Console.WriteLine("----------------------------------------------------------");
                Console.WriteLine("Payment Made for Card : {0}, for £{1}", payment.CardNumber, payment.AmountToPay);
                Console.WriteLine("Correlation ID = {0}", corrId);

                var ea = _consumer.Queue.Dequeue();
                if (ea.BasicProperties.CorrelationId != corrId)
                {
                    continue;
                }

                var authCode = Encoding.UTF8.GetString(ea.Body);
                Console.WriteLine("Reply Auth Code : {0}", authCode);
                Console.WriteLine("----------------------------------------------------------");
                Console.WriteLine("");

                return(authCode);
            }
        }
Пример #3
0
 private static void SendMessage(Payment message)
 {
     // As mensagens são enviadas para as filas ligada a oe xchange
     _model.BasicPublish(exchange: ExchangeName,
                         routingKey: "",
                         basicProperties: null,
                         body: message.Serialize());
     Console.WriteLine($" Payment Sent {message.CardNumber}, £{message.AmountToPay}");
 }
Пример #4
0
 private static void SendMessage(Payment message)
 {
     // "" envia para o default exchange
     _model.BasicPublish("", QueueName, null, message.Serialize()); // Envia objeto como bytearray
     Console.WriteLine(" [x] Payment Message Sent : {0} : {1} : {2}", message.CardNumber, message.AmountToPay, message.Name);
 }
Пример #5
0
 private static void SendPayment(Payment payment)
 {
     SendMessage(payment.Serialize(), "CardPayment");
     Console.WriteLine(" Payment Sent {0}, ExampleQueue{1}", payment.CardNumber, payment.AmountToPay);
 }
Пример #6
0
 private static void SendMessage(Payment message)
 {
     _model.BasicPublish("", QueueName, null, message.Serialize());
     Console.WriteLine($" Payment Sent {message.CardNumber}, £{message.AmountToPay}");
 }
Пример #7
0
 private static void SendMessage(Payment message)
 {
     _model.BasicPublish(ExchangeName, "", null, message.Serialize());
     Console.WriteLine(" Payment Sent {0}, £{1}", message.CardNumber, message.AmountToPay);
 }
Пример #8
0
 private static void SendMessage(Payment message)
 {
     _model.BasicPublish("", QueueName, null, message.Serialize());
     Console.WriteLine(" [x] Payment Message Sent : {0} : {1} : {2}", message.CardNumber, message.AmountToPay, message.Name);
 }
Пример #9
0
 private static void SendMessage(Payment message)
 {
     _channel.BasicPublish(exchange: "", routingKey: QueueName, basicProperties: null, body: message.Serialize());
     Console.WriteLine(" Payment Sent {0}, ExampleQueue{1}", message.CardNumber, message.AmountToPay);
 }
Пример #10
0
 private static void SendMessage(Payment message)
 {
     //We are publishing directly to an and exchange any queues that have been bound to that exchange will receive the message
     //No need for routingKey Vs Default exchange (which bears the name of the queue!)
     _channel.BasicPublish(exchange: ExchangeName, routingKey: "", basicProperties: null, body: message.Serialize());
     Console.WriteLine(" Payment Sent {0}, ExampleQueue{1}", message.CardNumber, message.AmountToPay);
 }
Пример #11
0
 private static void SendMessage(Payment payment)
 {
     _channel.BasicPublish(exchange: "", routingKey: QueueName, basicProperties: null, body: payment.Serialize());
     Console.WriteLine(" [x] Payment Message Sent : {0} : {1} : {2}", payment.CardNumber, payment.AmountToPay, payment.Name);
 }
Пример #12
0
 private static void SendMessage(Payment message)
 {   // serializing and sending message
     // we using default exchange here, look at first param how it was left empty
     _model.BasicPublish("", QueueName, null, message.Serialize());
     Console.WriteLine(" [x] Payment Message Sent : {0} : {1} : {2}", message.CardNumber, message.AmountToPay, message.Name);
 }