MSMQ Error

I have a network where MSMQ PEC is installed on NT Server.I run a service on server where i create a queue on another machine which is independent client.
im able to create the queue but while opening it gives me access denied .
any body help pls??
ashish
ashishn90Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ArvindtnCommented:
It would be more helpful if you show the part of the code used to open the queue.
0
ashishn90Author Commented:
The code is
try
{
m_pQueueInfo->Create();
}
catch (_com_error& e)
{
 if (e.Error() == MQ_ERROR_QUEUE_EXISTS)
{}
else if(e.Error() == MQ_ERROR_ACCESS_DENIED)
{
FILE *fp = fopen("C:\\Click-Logs\\MSMQ.txt","a+");
fprintf(fp,"MQ_ERROR_ACCESS_DENIED  Error\n");
close(fp);
CoUninitialize();
}
try
{
m_pQueue = m_pQueueInfo->Open(MQ_RECEIVE_ACCESS, MQ_DENY_NONE);
}
catch (_com_error& e)
{
if(e.Error() == MQ_ERROR_ACCESS_DENIED)
{
FILE *fp = fopen("C:\\Click-Logs\\MSMQ.txt","a+");
fprintf(fp,"MQ_ERROR_ACCESS_DENIED  Error");
fclose(fp);
}
else
{
FILE *fp = fopen("C:\\Click-Logs\\MSMQ.txt","a+");
fprintf(fp,"Cannot open the queue");
fclose(fp);
}

CoUninitialize();
return FALSE;
}

I get a error in Open catch block.This code is presnt in a service which runs on NT Server which is PEC for MSMQ.Queue is created on another machine on network which is independent client.It does not allow to open
Ashish  
0
ArvindtnCommented:
m_pQueue = m_pQueueInfo->Open(MQ_RECEIVE_ACCESS, MQ_DENY_NONE);

The II parameter u used to open the queue is wrong, It should be MQ_DENY_RECEIVE_SHARE

I have explained the parameter taken by MQOpenQueue() and their implications for a better undesrtanding. MQOpenQueue() is a C-API provided by MSMQ.

MQOpenQueue() Takes four parameter.

I Parameter - FormatName - Got using MQCreateQueue() / MQPathNameToFormatName()

II Parameter - dwAccess - The Possible values it can take is.

MQ_PEEK_ACCESS - Message can be looked at, they cannot be removed from the queue.

MQ_SEND_ACCESS - Message can be sent to the Queue, The messages on the queue cannot be looked at or removed.

MQ_RECEIVE_ACCESS - Message can be looked at or removed from the queue.

III Parameter - ShareMode - The Value it takes depends on the II Parameter. The possible values are.

MQ_DENY_NONE - Other program may open the Queue while this one has it open. This required in case of
dwAccess = MQ_PEEK_ACCESS or
           MQ_SEND_ACCESS

MQ_DENY_RECEIVE_SHARE - Only this program can receive messages from the queue. If another process has the queue open for MQ_RECEIVE_ACCESS, whether it is shared or not, the program will not able to open the queue.

Syntax to open the queue to receive message should be

MQOpenQueue(wcFormatName,
            MQ_RECEIVE_ACCESS,
            MQ_DENY_RECEIVE_SHARE,
            &hQueue );
0
ArvindtnCommented:
If u still have problems message me
0
ArvindtnCommented:
m_pQueue = m_pQueueInfo->Open(MQ_RECEIVE_ACCESS, MQ_DENY_NONE);

The II parameter u used to open the queue is wrong, It should be MQ_DENY_RECEIVE_SHARE

I have explained the parameter taken by MQOpenQueue() and their implications for a better undesrtanding. MQOpenQueue() is a C-API provided by MSMQ.

MQOpenQueue() Takes four parameter.

I Parameter - FormatName - Got using MQCreateQueue() / MQPathNameToFormatName()

II Parameter - dwAccess - The Possible values it can take is.

MQ_PEEK_ACCESS - Message can be looked at, they cannot be removed from the queue.

MQ_SEND_ACCESS - Message can be sent to the Queue, The messages on the queue cannot be looked at or removed.

MQ_RECEIVE_ACCESS - Message can be looked at or removed from the queue.

III Parameter - ShareMode - The Value it takes depends on the II Parameter. The possible values are.

MQ_DENY_NONE - Other program may open the Queue while this one has it open. This required in case of
dwAccess = MQ_PEEK_ACCESS or
           MQ_SEND_ACCESS

MQ_DENY_RECEIVE_SHARE - Only this program can receive messages from the queue. If another process has the queue open for MQ_RECEIVE_ACCESS, whether it is shared or not, the program will not able to open the queue.

Syntax to open the queue to receive message should be

MQOpenQueue(wcFormatName,
            MQ_RECEIVE_ACCESS,
            MQ_DENY_RECEIVE_SHARE,
            &hQueue );
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.