How to send information to a message queue
-
Hi there. I need to have some ASP page that sends and places information in a message queue, and also how to make the opposite, read from a message queue. (using windows message queuing.) Thanks in advance, Pedro Roriz
-
Hi there. I need to have some ASP page that sends and places information in a message queue, and also how to make the opposite, read from a message queue. (using windows message queuing.) Thanks in advance, Pedro Roriz
To accomplish this, you need to use the System.Messaging namespace. The process is fairly simple to use and implement. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemmessaging.asp HTH, Bill P. Oakland, CA
-
To accomplish this, you need to use the System.Messaging namespace. The process is fairly simple to use and implement. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemmessaging.asp HTH, Bill P. Oakland, CA
Hi! Thanks for the quick answer. I've managed to place a message in the queue, but now, trying to read it is being a little more complicated. I've searched the web for many pieces of code, tried a lot of possible ways, but always end up the same way: Set qQueue = Server.CreateObject ("MSMQ.MSMQQueueInfo") Set qMessage = Server.CreateObject ("MSMQ.MSMQMessage") qQueue.FormatName = "DIRECT=OS:pedro-roriz\aspq" Set qReceive = qQueue.Open(2,0) Set qMessage = qReceive.Receive (0 , true , true , 100) -- Here i get a error: Access is denied I went to my queue, and turned all permissions on to every user group that i found there...still nothing. Any help? Thanks Pedro Roriz
-
Hi! Thanks for the quick answer. I've managed to place a message in the queue, but now, trying to read it is being a little more complicated. I've searched the web for many pieces of code, tried a lot of possible ways, but always end up the same way: Set qQueue = Server.CreateObject ("MSMQ.MSMQQueueInfo") Set qMessage = Server.CreateObject ("MSMQ.MSMQMessage") qQueue.FormatName = "DIRECT=OS:pedro-roriz\aspq" Set qReceive = qQueue.Open(2,0) Set qMessage = qReceive.Receive (0 , true , true , 100) -- Here i get a error: Access is denied I went to my queue, and turned all permissions on to every user group that i found there...still nothing. Any help? Thanks Pedro Roriz
It looks like to me that you are trying to do it in client-side script. Is this correct? If that is the case, then I believe that you need to make sure that the MACHINENAME\IUSR_MACHINENAME account needs to have access to the queue, which I have heard is not a good idea. If you are using ASP.NET, then I would send and recieve the messages in the code-behind and do it that way. Much safer, IMHO. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemmessagingmessagequeueclassreceivetopic.asp This is what I found on MSDN for receiving a message. HTH, Bill P. Oakland, CA
-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCM/MU/B dpu s--:-- a32 C++++$ ULH+++ P+++ L++ E+ W+++$ N++ o K? w++++$ O-- M V-- PS+ PE+ Y++ PGP++ t++@ 5++@ X++ R+@ tv b++ DI++ D+++>++++ G++ e++ h---- r+++ y++++ -----END GEEK CODE BLOCK-----
-
It looks like to me that you are trying to do it in client-side script. Is this correct? If that is the case, then I believe that you need to make sure that the MACHINENAME\IUSR_MACHINENAME account needs to have access to the queue, which I have heard is not a good idea. If you are using ASP.NET, then I would send and recieve the messages in the code-behind and do it that way. Much safer, IMHO. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemmessagingmessagequeueclassreceivetopic.asp This is what I found on MSDN for receiving a message. HTH, Bill P. Oakland, CA
-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCM/MU/B dpu s--:-- a32 C++++$ ULH+++ P+++ L++ E+ W+++$ N++ o K? w++++$ O-- M V-- PS+ PE+ Y++ PGP++ t++@ 5++@ X++ R+@ tv b++ DI++ D+++>++++ G++ e++ h---- r+++ y++++ -----END GEEK CODE BLOCK-----
no, the code is being writen in server side. As for the code, it's in asp, not using asp.net. Just can't figure out why he keeps complaining! Thanks anyway. Pedro Roriz
-
no, the code is being writen in server side. As for the code, it's in asp, not using asp.net. Just can't figure out why he keeps complaining! Thanks anyway. Pedro Roriz
Hmmm, is the queue an authenticated queue? try turning off authentication on the queue and then see what happens. HTH, Bill P. Oakland, CA
-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCM/MU/B dpu s--:-- a32 C++++$ ULH+++ P+++ L++ E+ W+++$ N++ o K? w++++$ O-- M V-- PS+ PE+ Y++ PGP++ t++@ 5++@ X++ R+@ tv b++ DI++ D+++>++++ G++ e++ h---- r+++ y++++ -----END GEEK CODE BLOCK-----
-
Hmmm, is the queue an authenticated queue? try turning off authentication on the queue and then see what happens. HTH, Bill P. Oakland, CA
-----BEGIN GEEK CODE BLOCK----- Version: 3.21 GCM/MU/B dpu s--:-- a32 C++++$ ULH+++ P+++ L++ E+ W+++$ N++ o K? w++++$ O-- M V-- PS+ PE+ Y++ PGP++ t++@ 5++@ X++ R+@ tv b++ DI++ D+++>++++ G++ e++ h---- r+++ y++++ -----END GEEK CODE BLOCK-----
the default for the queue was already with authenticated turned off. In the general tag, i have: Limit message storage to (kb) turned off Authenticated off Nontransactional queue Privacy level set to optional and base priority to 0.
-
the default for the queue was already with authenticated turned off. In the general tag, i have: Limit message storage to (kb) turned off Authenticated off Nontransactional queue Privacy level set to optional and base priority to 0.
I changed the code for the open method. Instead of using FormatName, I used PathName and Label. Now the error message is: "The queue does not exist, or you do not have sufficient permissions to perform the operation. " Any help? Thanks! Set qQueue = Server.CreateObject ("MSMQ.MSMQQueueInfo") Set qMessage = Server.CreateObject ("MSMQ.MSMQMessage") 'qQueue.FormatName = "DIRECT=OS:pedro-roriz\Testqueue2" qQueue.PathName = ".\TestQueue2" qQueue.Label = "Testqueue2" Set qReceive = qQueue.Open(2,0) If qReceive = Nothing then Response.write "Nothing opened" else Set qMessage = qReceive.Receive (0 , true , true , 100) if Not qMessage is Nothing then Response.Write "Body = " + qMessage.body else Response.Write "empty" end if end if
-
I changed the code for the open method. Instead of using FormatName, I used PathName and Label. Now the error message is: "The queue does not exist, or you do not have sufficient permissions to perform the operation. " Any help? Thanks! Set qQueue = Server.CreateObject ("MSMQ.MSMQQueueInfo") Set qMessage = Server.CreateObject ("MSMQ.MSMQMessage") 'qQueue.FormatName = "DIRECT=OS:pedro-roriz\Testqueue2" qQueue.PathName = ".\TestQueue2" qQueue.Label = "Testqueue2" Set qReceive = qQueue.Open(2,0) If qReceive = Nothing then Response.write "Nothing opened" else Set qMessage = qReceive.Receive (0 , true , true , 100) if Not qMessage is Nothing then Response.Write "Body = " + qMessage.body else Response.Write "empty" end if end if
Finally i got to receive the message from the queue. I'm placing here the code, just in case anyone needs it. Thanks for all the help Bill! dim body Set qQueue = Server.CreateObject ("MSMQ.MSMQQueueInfo") Set qMessage = Server.CreateObject ("MSMQ.MSMQMessage") qQueue.FormatName = "PUBLIC=fc3ebf19-bd12-4dfa-8029-e0062a5c7b2f" 'u get this ID in the properties of your queue Set qReceive = qQueue.Open(1,0) If qReceive.isopen then 'Response.write "
opened
" end if Set qMessage = qReceive.Receive (0 , true , true , 100) if Not qMessage is Nothing then body = qMessage.body Response.Write "
" + Body + "
" else Response.Write "Empty Queue" end if