• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 441
  • Last Modified:

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
0
ashishn90
Asked:
ashishn90
  • 4
1 Solution
 
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

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now