Exemple #1
0
        static void Main(string[] args)
        {
            try
            {
                var mq = new MessageQueue
                {
                    PaymentMessage = new PaymentMessage()
                    {
                        Id              = Guid.NewGuid(),
                        AccountNumber   = GetRandomNumber(10000000, 99999999).ToString(),
                        Amount          = GetRandomNumber(5000, 100000),
                        ReferenceNumber = "Salary",
                    }
                };

                //send serialise object to a Queue,
                //reason for using json object was to receive a message as a string and not an object.
                string message = JsonConvert.SerializeObject(mq);

                Print(message);

                ManageRabbitMQ.Send(QUEUE_NAME, message);


                Print("New Payment Message has been sent");
            }
            catch (Exception ex)
            {
                Print(ex.Message);
            }
            finally
            {
                Console.Read();
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            try
            {
                Console.Write("Please enter name:");

                string name = Console.ReadLine();

                var mq = new MessageQueue
                {
                    Message = $"Hello my name is, {name}"
                };

                //send serialise object to a Queue,
                //reason for using json object was just experimenting.
                ManageRabbitMQ.Send(QUEUE_NAME, JsonConvert.SerializeObject(mq));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Console.Read();
            }
        }