Find the answer to your Linux question:
Results 1 to 9 of 9
I'm facing a scenario in which i need to block messages from being passed onto a message queue when my code is running. Please suggest me how to proceed....
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2010
    Posts
    19

    need to block messages on a message queue


    I'm facing a scenario in which i need to block messages from being passed onto a message queue when my code is running.
    Please suggest me how to proceed.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,691
    These are Posix queues?
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    May 2010
    Posts
    19

    @Rubberman

    yeah, Its a Posix queue

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,691
    Quote Originally Posted by arunalapati View Post
    I'm facing a scenario in which i need to block messages from being passed onto a message queue when my code is running.
    Please suggest me how to proceed.
    So, you want to block all messages? Of just ones from other processes? Unfortunately I don't see a way to block the queue. So, why do you want to do this? The purpose of a queue is to allow senders to pass data that the consumer is not yet ready to process. Until the queue is unlinked and all open links to it are closed, it will remain persistent in the system. You can even have all the applications that use it terminate, and the data will be maintained by the kernel until the queue is unlinked. Perhaps a bit of a description of your application and what you are really trying to accomplish can enable us to give you better advice.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  6. #5
    Just Joined!
    Join Date
    May 2010
    Posts
    19

    @Rubberman

    I wanted to block the messages coming from other threads under the same process.

    Problem Description:
    I've registered a notifier function using mq_notify(). When a message is added to the queue. My notifier function is invoked and I'm processing the message, removing it from the queue and re-registering the notifier using mq_notify() to process next message.
    But, while processing my message If the message is added to the queue from other thread. My re-registration of the notifier fails. So, I want to block the message queue while processing the message.

    mq_notify() requires the message queue to be empty during registration.

    Hope I've presented a clear picture. Please let me know if any more details are required.

  7. #6
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,691
    Well, I wouldn't do it that way. This is not the purpose of mq_notify. Please try to explain what is your message processing work-flow. I have almost 30 years of experience with message-passing systems, including the implementation of ones that are used to run numerous factories, and most semiconductor FABs, around the world. They can be elegantly simple and efficient, but if you try to apply old RPC thinking to them, you will soon find that you have lost all of that efficiency and more, not to mention gaining a lot of complexity that is totally unnecessary.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  8. #7
    Just Joined!
    Join Date
    May 2010
    Posts
    19

    @Rubberman

    My message processing involves transferring the message to the another PC on Network via a socket. (I've created a thread to handle this)

    Message can be added to Message queue from another thread (based on asynchronous events).

    Please suggest an Optimal way to do this.

  9. #8
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,691
    So, I am still confused why you need to block additional messages while you transfer to the remote system via a socket call. Why can't you just let the asyncronous messages queue up? That is the purpose of message queues - senders are not gated on what the reader does, at least until the maximum quene length is reached. In that case, it is a classic consumer/producer problem, but at least the sender would be informed that the queue is full.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  10. #9
    Just Joined!
    Join Date
    May 2010
    Posts
    19

    @Rubberman

    mq_notify() requires the queue to be empty during registration of a notifier.
    So, If the message arrives while my data transfer through a socket, Then my registration of notifier using mq_notify() fails

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •