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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. (MSMQ) Whats the Best Way to Poll a Queue?

(MSMQ) Whats the Best Way to Poll a Queue?

Scheduled Pinned Locked Moved .NET (Core and Framework)
questioncsharpcssdata-structuresperformance
1 Posts 1 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.
  • V Offline
    V Offline
    Vlad Gabovich
    wrote on last edited by
    #1

    This question is directed towards MSMQ in .NET (System.Messaging.MessageQueue, etc), but is relevant to messaging in general. Suppose I have a lot of messages coming through some queue (~1000 msgs/sec), and some function ProcessMessage(Message msg) that I want to invoke to process each message. There are two ways to read these messages asynchronously (MSMQ/.NET): 1. Begin a thread (or Timer thread) that periodically polls the queue (MessageQueue.Receive()), retrieves a new message, calls ProcessMessage(). 2. Call the asynchronous MessageQueue.BeginReceive() to which you pass your callback function (as delegate). Then when a new message comes, the MessageQueue will automatically call your callback function. The difference in performance is unclear to me. In the second case, it seem you have to do less work, since you get notified automatically when a message arrives instead of having to write a thread that checks this; however, there is more flexibility in the first approach, because you control exactly how the check for new messages is performed, how often, etc. But I am really only interested in performance, and though I am going to write some simple examples to test this, I am not sure that they will be representative of what happens under a real load. Does anybody have thoughts on this? Thanks! -Vlad

    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