question about MessageQueue

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Charles Shao

    question about MessageQueue

    question about MessageQueue

    Hi, friends:

    I try to send a message into MSMQ and then read it out.
    But I find the message is not be removed after being accessed.
    How can I read and remove it ?

    Thanks

    Charles Shao
    =============== =============== =============== =============== ====
    myNewPrivateQue ue1.Send("My message data.",
    MessageQueueTra nsactionType.Si ngle);
    MessageEnumerat or myEnumerator =
    myNewPrivateQue ue1.GetMessageE numerator();

    // Specify that the messages's priority should be read.
    myNewPrivateQue ue1.MessageRead PropertyFilter. Priority = true;

    // Move to the next message and examine its priority.
    while(myEnumera tor.MoveNext())
    {
    // Increase the count if priority is Lowest.
    if(myEnumerator .Current.Priori ty ==
    MessagePriority .Lowest)

    Console.WriteLi ne("Received MSG: " +
    myEnumerator.Cu rrent.Body.ToSt ring());
    }



  • CSharper

    #2
    Re: question about MessageQueue

    Charles,

    The MessageEnumerat or provides a forward-only cursor to enumerate through
    messages in a message queue. In other words, you can view them, but you
    can't remove them. In order to remove them, you need to get a reference to
    the queue the message is in.
    In your case, if myNewPrivateQue ue1 is that reference, you can simply call
    the Receive method like this:

    myNewPrivateQue ue1.Receive();

    Keep in mind that queues are just that, queues. They operate in a FIFO
    (First-in first-out) manner. So when you call receive, you're essentially
    getting the message that has been waiting the longest (and has the highest
    priority as I understand it).

    Hope this helps,

    Dan Cox
    DISCLAIMER: This *should* work. =)


    "Charles Shao" <adadad@263.net > wrote in message
    news:eu4mPa6SFH A.3392@TK2MSFTN GP12.phx.gbl...[color=blue]
    > question about MessageQueue
    >
    > Hi, friends:
    >
    > I try to send a message into MSMQ and then read it out.
    > But I find the message is not be removed after being accessed.
    > How can I read and remove it ?
    >
    > Thanks
    >
    > Charles Shao
    > =============== =============== =============== =============== ====
    > myNewPrivateQue ue1.Send("My message data.",
    > MessageQueueTra nsactionType.Si ngle);
    > MessageEnumerat or myEnumerator =
    > myNewPrivateQue ue1.GetMessageE numerator();
    >
    > // Specify that the messages's priority should be read.
    > myNewPrivateQue ue1.MessageRead PropertyFilter. Priority = true;
    >
    > // Move to the next message and examine its priority.
    > while(myEnumera tor.MoveNext())
    > {
    > // Increase the count if priority is Lowest.
    > if(myEnumerator .Current.Priori ty ==
    > MessagePriority .Lowest)
    >
    > Console.WriteLi ne("Received MSG: " +
    > myEnumerator.Cu rrent.Body.ToSt ring());
    > }
    >
    >
    >[/color]


    Comment

    • Charles Shao

      #3
      Re: question about MessageQueue

      Thank you very much :-)
      I will go to have a try

      "CSharper" <dont@botherme. com> дÈëÓʼþ
      news:8lZbe.1387 33$vL3.55996@bi gnews4.bellsout h.net...[color=blue]
      > Charles,
      >
      > The MessageEnumerat or provides a forward-only cursor to enumerate through
      > messages in a message queue. In other words, you can view them, but you
      > can't remove them. In order to remove them, you need to get a reference to
      > the queue the message is in.
      > In your case, if myNewPrivateQue ue1 is that reference, you can simply call
      > the Receive method like this:
      >
      > myNewPrivateQue ue1.Receive();
      >
      > Keep in mind that queues are just that, queues. They operate in a FIFO
      > (First-in first-out) manner. So when you call receive, you're essentially
      > getting the message that has been waiting the longest (and has the highest
      > priority as I understand it).
      >
      > Hope this helps,
      >
      > Dan Cox
      > DISCLAIMER: This *should* work. =)
      >
      >
      > "Charles Shao" <adadad@263.net > wrote in message
      > news:eu4mPa6SFH A.3392@TK2MSFTN GP12.phx.gbl...[color=green]
      > > question about MessageQueue
      > >
      > > Hi, friends:
      > >
      > > I try to send a message into MSMQ and then read it out.
      > > But I find the message is not be removed after being accessed.
      > > How can I read and remove it ?
      > >
      > > Thanks
      > >
      > > Charles Shao
      > > =============== =============== =============== =============== ====
      > > myNewPrivateQue ue1.Send("My message data.",
      > > MessageQueueTra nsactionType.Si ngle);
      > > MessageEnumerat or myEnumerator =
      > > myNewPrivateQue ue1.GetMessageE numerator();
      > >
      > > // Specify that the messages's priority should be read.
      > > myNewPrivateQue ue1.MessageRead PropertyFilter. Priority = true;
      > >
      > > // Move to the next message and examine its priority.
      > > while(myEnumera tor.MoveNext())
      > > {
      > > // Increase the count if priority is Lowest.
      > > if(myEnumerator .Current.Priori ty ==
      > > MessagePriority .Lowest)
      > >
      > > Console.WriteLi ne("Received MSG: " +
      > > myEnumerator.Cu rrent.Body.ToSt ring());
      > > }
      > >
      > >
      > >[/color]
      >
      >[/color]


      Comment

      Working...