Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Reading Message from MSMQ and DIsplaying

Reading Message from MSMQ and DIsplaying

Scheduled Pinned Locked Moved C#
data-structureshelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    honeyss
    wrote on last edited by
    #1

    Hi, I want to display the messages from Queue in consoleapplication.I am able to read the queues.But while displaying, if i had 6 messages in queue and in that i am able to display only 3.Please help me out in solving this. My code is as follows: string QueueName = ".\\Private$\\TestQ"; MessageQueue.EnableConnectionCache = false; //// open the selected message queue this.messageQueue = new MessageQueue(QueueName, QueueAccessMode.Receive); while (true) { System.Messaging.Message message = new System.Messaging.Message(); MessageQueueTransaction msgTx = new MessageQueueTransaction(); MessageDetails messageDetails = null; try { msgTx.Begin(); message.Formatter = new BinaryMessageFormatter(); message = messageQueue.Receive(new TimeSpan(0, 0, 0, 10), msgTx); if (message.Body != null) { messageDetails = (MessageDetails)message.Body; Console.WriteLine(messageDetails.ApplicationName + "\t" + messageDetails.ThreadName + "\t" + messageDetails.Status + "\t" + messageDetails.TimeStamp); } msgTx.Commit(); messageQueue.BeginReceive(); } Thanks in Advance

    J 1 Reply Last reply
    0
    • H honeyss

      Hi, I want to display the messages from Queue in consoleapplication.I am able to read the queues.But while displaying, if i had 6 messages in queue and in that i am able to display only 3.Please help me out in solving this. My code is as follows: string QueueName = ".\\Private$\\TestQ"; MessageQueue.EnableConnectionCache = false; //// open the selected message queue this.messageQueue = new MessageQueue(QueueName, QueueAccessMode.Receive); while (true) { System.Messaging.Message message = new System.Messaging.Message(); MessageQueueTransaction msgTx = new MessageQueueTransaction(); MessageDetails messageDetails = null; try { msgTx.Begin(); message.Formatter = new BinaryMessageFormatter(); message = messageQueue.Receive(new TimeSpan(0, 0, 0, 10), msgTx); if (message.Body != null) { messageDetails = (MessageDetails)message.Body; Console.WriteLine(messageDetails.ApplicationName + "\t" + messageDetails.ThreadName + "\t" + messageDetails.Status + "\t" + messageDetails.TimeStamp); } msgTx.Commit(); messageQueue.BeginReceive(); } Thanks in Advance

      J Offline
      J Offline
      Jimmanuel
      wrote on last edited by
      #2

      is messageQueue subscribed to receive the callback from the BeginReceive() call? if not that'll probably discard every other message in the queue.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups