MSMQ send blocking?

G

Guest

Hi all:

I'm try to create a private message queue to communicate between my service
and any client that wants to display the data. Everything seems ok until I
try to send a message to the queue where the Send call blocks forever!!
Please help... here is my code:

m_queuePath = @".\Private$\myQueue";

// Start the Message queue
if (MessageQueue.Exists(m_queuePath))
m_msmq = new MessageQueue(m_queuePath);
else
m_msmq = MessageQueue.Create(m_queuePath,true);


// So far so good, the queue gets created... then

if (m_msmq != null)
{
Message m = new Message(new Object(),new BinaryMessageFormatter());
m_msmq.Send(m,"SomeObject",MessageQueueTransactionType.Single);// Blocks
}

I tried this with and without transactions with the same results.


Best regards,
Ed;;
 
W

Willy Denoyette [MVP]

Ed A said:
Hi all:

I'm try to create a private message queue to communicate between my
service
and any client that wants to display the data. Everything seems ok until I
try to send a message to the queue where the Send call blocks forever!!
Please help... here is my code:

m_queuePath = @".\Private$\myQueue";

// Start the Message queue
if (MessageQueue.Exists(m_queuePath))
m_msmq = new MessageQueue(m_queuePath);
else
m_msmq = MessageQueue.Create(m_queuePath,true);


// So far so good, the queue gets created... then

if (m_msmq != null)
{
Message m = new Message(new Object(),new BinaryMessageFormatter());
m_msmq.Send(m,"SomeObject",MessageQueueTransactionType.Single);// Blocks
}

I tried this with and without transactions with the same results.


Best regards,
Ed;;

Nothing wrong with the code, it should work. How do you know it blocks? Did
you try this from a simple console program?

Willy.
 
B

Bill Butler

Ed A said:
I have a trace statement after the send line that never gets called...

Put a try catch block around it to make sure it is not throwing an exception
that is getting silently eaten.

I could be wrong, but I think that is why Willy suggested tthe Console App.
Windows Forms apps can sometimes eat exceptions silently

Bill
 
W

Willy Denoyette [MVP]

Ed A said:
I have a trace statement after the send line that never gets called...

:

That doesn't mean it blocks, like Bill said, it's possible that send throws
an exception that gets eaten.
Do as I suggest, try from a console application first, and move forward once
you got that working and wrap your code in a try/catch block.


Willy.
 
G

Guest

Thanks... after I wraped my code with a try/catch block I found out that the
object I was sending was not flagged as serializable... now it seems to be
working.

I got another problem though, since my service is creating the queue it
seems that I don't have permissions to read it from my application.
I tried doing:
m_msmq.SetPermissions("MyMachine",MessageQueueAccessRights.ChangeQueuePermissions);

or

m_msmq.SetPermissions("MyMachine",MessageQueueAccessRights.FullControl);

but that didn't get me anywhere!! How can I create the queue with
permissions to read/write to anyone in the administrator group?

Thanks
Ed;;
 
W

Willy Denoyette [MVP]

Ed A said:
Thanks... after I wraped my code with a try/catch block I found out that
the
object I was sending was not flagged as serializable... now it seems to be
working.

I got another problem though, since my service is creating the queue it
seems that I don't have permissions to read it from my application.
I tried doing:
m_msmq.SetPermissions("MyMachine",MessageQueueAccessRights.ChangeQueuePermissions);

or

m_msmq.SetPermissions("MyMachine",MessageQueueAccessRights.FullControl);

but that didn't get me anywhere!! How can I create the queue with
permissions to read/write to anyone in the administrator group?

Thanks
Ed;;


It makes little sense to grant fullcontrol to the machine account, the
aplication doesn't run with machine account credentials. What you need is to
do is specify an individual user in the form DOMAIN\\user where DOMAIN can
be a domain name or a local machine name, or a (local) group name like
"users". Note that you can set multiple permissions for the same queue.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top