private static void SendContactObjectAsMessage(bool sendObject)
        {
            var     queueName = ConfigurationManager.AppSettings["StronglyTypedQueue"];
            Contact contact   = new Contact()
            {
                FirstName = "Rajesh", Id = 100, LastName = "Mishra", Guid = new Guid()
            };

            Message myMessage = new Message();

            if (sendObject)
            {
                //myMessage.Formatter = new XmlMessageFormatter(new Type[] { typeof(Contact) });
                myMessage.Formatter = new BinaryMessageFormatter();
                myMessage.Body      = contact;
                myMessage.Label     = "Contact";
            }
            else
            {
                myMessage.Formatter = new BinaryMessageFormatter();
                myMessage.Body      = "This is string Message " + DateTime.Now.ToString();
                myMessage.Label     = "StringMessage";
            }
            myMessage.UseJournalQueue     = true;
            myMessage.UseDeadLetterQueue  = true;
            myMessage.Recoverable         = true;
            myMessage.AdministrationQueue = new MessageQueue(ConfigurationManager.AppSettings["AckQueueName"].ToString());
            myMessage.AcknowledgeType     = AcknowledgeTypes.PositiveArrival | AcknowledgeTypes.FullReceive;
            IMSMQFacoty queueOperation = new MSMQFacoty();

            queueOperation.EnqueMessage("StronglyTypedQueue", myMessage);
            Console.WriteLine("Message Sent");
            Console.ReadLine();
        }
Esempio n. 2
0
        internal static void SendMessage()
        {
            IMSMQFacoty queueOperation = new MSMQFacoty();

            queueOperation.EnqueMessage("Queue", string.Format("Test message coming from ClientA at {0}", DateTime.UtcNow));
            Console.ReadLine();
        }
 internal static void SendMessage()
 {
     try
     {
         int         count          = 10;
         IMSMQFacoty queueOperation = new MSMQFacoty();
         Console.Write("Enter message for processing : ");
         for (int index = 0; index < count; index++)
         {
             string message = Console.ReadLine();
             queueOperation.EnqueMessage("CorrelationRequest", message);
         }
         Console.WriteLine("{0} messages sent for processing", count);
         Console.ReadLine();
     }
     catch (Exception ex)
     {
         logger.LogError(ex.Message);
         throw;
     }
 }