Writing a reply to a message queue

matthewlmatthewl Member Posts: 11
Hi,

I'm using two messages queues as a way of sending commands to Navision so that it can send back some data.

I have a .NET application that creates a simple XML packet that is pushed onto a request queue. I have a form in Navision that when run, parses incoming messages and sends a reply to the reply queue if required.

However, when it comes to sending a reply back on the reply queue, I get the following message:

The call to member Send failed. MSMQBusAdapter.MSMQBusAdapter.1 returned the following message: The queue could not be used to write messages. Check access rights, validity and settings

This message appears when I call the Send method for the Navision Communication Component.

The code I am using to send a reply is the following which is in the MessageReceived event for the Navision Communication Component:
CREATE(XMLDocRequest);
CREATE(XMLDocReply);

InMsg := InMessage; 
InStreamQueue := InMsg.GetStream();
XMLDocRequest.load(InStreamQueue);
ProcessRequest(XMLDocRequest,XMLDocReply,ReplyReqd);

IF ReplyReqd THEN BEGIN
  OutMsg := InMsg.CreateReply();
  OutStreamQueue := OutMsg.GetStream();
  XMLDocReply.save(OutStreamQueue);
  OutMsg.Send(0);  // Debugger breaks here with error message.
  CLEAR(OutMsg);
END;

InMsg.CommitMessage; 
CLEAR(InMsg); 

CLEAR(XMLDocReply);
CLEAR(XMLDocRequest);

Any help or pointers with this would be greatly appreciated!

Thanks,

Matthew

Answers

  • jlandeenjlandeen Member Posts: 524
    The first thing I would check is the permissions on the Message Queues. By default I think everyone gets read access but not write. You have to make sure that the user executing Navision (in the case of NAS the Log On User setup for the service) has write permissions to the Queue.

    Normally I always start by granting everyone full permissions on both message queues for testing (just so everything works) then as you're ready to put the Web Service/.Net/Com/Whatever Application into production make sure to tighten security as requied.
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
  • matthewlmatthewl Member Posts: 11
    Hi jlandeen,

    I'm running the .NET application and Navision on my development PC so I'm simply allowing both of these applications to talk directly to the queue without NAS.

    I've checked the permissions for the reply queue and all available groups or users have the necessary permissions to send a message.
  • jlandeenjlandeen Member Posts: 524
    Ok well sounds like you've checked the simple things.

    Next things to look into is how are you sending the message - do you have the correlation ID and the message labels setup correctly?

    Another thing...are you trying to use the same Message Queue for reading & writing? If so you may want to try splitting it out into 1 queue per direction per nas.
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
  • matthewlmatthewl Member Posts: 11
    Solved!

    I have managed to get a reply writing to the correct queue. When sending the message through to Navision you have to specify the response queue that the message will reply to in the original message. Simply specifying the reply queue in Navision isn't enough.

    So I amended my C# application to specify the response queue like so:
    MessageQueue mqRequest = new MessageQueue(this.MQRequest);
    Message me = new Message();
    me.Label = "Navision MSMQ-BA";
    me.CorrelationId = corelationId;
    me.ResponseQueue = new MessageQueue(this.MQReply);
    

    Top tip: You can see more properties for a message on the message queue by viewing the message in the server explorer in Visual Studio rather than using the Computer Management console.

    Thanks for the suggetions jlandeen. Finally got there in the end!
  • jlandeenjlandeen Member Posts: 524
    Hey that's a great tip...I don't think I've used the VS Solution Explorer to look into a Queue but I will the next time I write one of those types of apps ;)
    Jeff Landeen - Sr. Consultant
    Epimatic Corp.

    http://www.epimatic.com
Sign In or Register to comment.