« What's in a class/method name? | Main | SQL Server 2005 SP 2 Released »

MSMQ - Sending messages to remote private queues

Recently a friend was facing issues in sending messages to a private msmq queue on a remote machine. I had worked on this about 4-5 years back and I recalled that I was able to work with remote private queues. So I decided to give it a try again.

Following are things that I found.

1. When working with remote queues, the queue name in the format machinename\private$\queuename doesn't work. This results in an "invalid queue path" error.

2. The queue name has to be mentioned as "FormatName:Direct=OS:machinename\\private$\\queuename". This is necessary since the queue access is internally done using the format name syntax only. The other friendly representation is converted to the FormatName and then used. When working with remote queues, unless there is an AD to resolve the queue name, the friendly name won't work. Check out documentation for details.

For Eg.

    MessageQueue rmQ = new MessageQueue
                                    ("FormatName:Direct=OS:machinename\\private$\\queue");
    rmQ.Send("sent to regular queue - Atul");

3. Further to previous point, note that FormatName is case sensitive. If you mention the earlier string as "FORMATNAME:Direct=OS:machinename\\private$\\queuename", it won't work. Surprisingly, there is no error thrown in this case. "FormatName" part of the string seems to be the only case sensitive part. Others can appear in different case. For eg. You can write "DIRECT". 

4. In case you want to use the machine's IP address the syntax will be "FormatName:Direct=TCP:ipaddress\\private$\\queuename".

For Eg.

    MessageQueue rmQ = new MessageQueue
                                     ("FormatName:Direct=TCP:121.0.0.1\\private$\\queue");
    rmQ.Send("sent to regular queue - Atul");

5. The transactional properties of the queue instance you create in code should match with that of the queue you are trying to send the message to. So in the earlier examples, I was sending message to a non-transactional queue. To send to a transactional queue, the code would be

    MessageQueue rmTxnQ = new MessageQueue
                                            ("FormatName:Direct=OS:machinename\\private$\\queue");
    rmTxnQ.Send("sent to Txn queue - Atul", MessageQueueTransactionType.Single);

If the transactional properties don't match, the message will not be delivered. The surprising part is again, I didn't get any error, and the message just disappeared

6. Finally, when you send messages to remote queue, a temporary outgoing queue is created on your own machine. This is used in case the remote queue is unavailable. If you go to the computer Management console (compmgmt.msc), and expand the Services and Applications / Message Queuing / Outgoing Queues, you would see these queues. The right side of the console should show the details including the state (connected or not) and the IP address(es) for the next hop(s).

1

TrackBack

Listed below are links to weblogs that reference MSMQ - Sending messages to remote private queues:

» MSMQ - Envoyer un message à une queue distante from Le blog de Fabien Dehopré
J’ai trouvé un article interessant concernant l’envoi de message sur un queue (MSMQ) distante. Ca faisait une semaine que j’essayais, en vain, de me connecter à une queue sur un des serveurs de développement. En fait, je n’é... [Read More]

Comments

Accidently landed here but good to know that infy got blog for MS category.
Gudoos guys..keep sharing..I've subscribed for this feed.
Mahes~

Very good really helped..Thanks.

Can you please help me on MSMQ - Recieving messages from remote private queues

Thanks! I've been looking for this info for hours. Just what I needed.

@Anupama, the basics remain the same for sending and receving. Instead of MessageQueue.Send, you will have to use the Receive method. Note that when working with Private queues, it is very important that the you get the name right since there is no domain server to help resolve the remote queue names, as happens in case of public queues

Thanks a bunch! I've been stuck on this for quite a while.

Thanks a lot. I have been looking for this all day long

Can you please help me how to read remote private queues in MSMQ 3.0 installed in workgroup mode in windows 2003

Harish: The reading from remote private queue should work in the opposite manner. I will try this and post an update as soon as I can.

I have published a new blog on receiving messages from remote private queue. Check it out here - http://infosysblogs.com/microsoft/2007/05/msmq_receiving_messages_from_r.html

In point 5, you mention that if the transactional properties don't match then the message disappears. Is it possible to determine the "Transactional" property of a direct format queue? I'm moving to transactional queues but my queue writers need to be able to write to both types of queue during the conversion. Direct format queues are also required because I've got queues in multiple domains.

BTW, I found your article really useful. I believe it confirms that queue properties are cached in AD and are not readily available when using the direct format.

David: The Transactional property works for local queues but doesn't work for remote queues even with direct format names. That means the developers need to be aware of transactional nature of the queue.

This isn't all that bad since transactional or not is a design decision and will be done upfront and hence when it comes to implementation, you would already be aware of how it behaves.

One other round about way could be to deploy web service on the remote machine which can make a local call and check the transactional nature and revert the value and you can invoke these web services remotely.

Hi,
I am working on MSMQ 3.0 and Win2k3. I have a question. I have a application running on Machine A and receiving queue on machine B. Lets say i have given invalid queue name or invalid machine name, when application sends a message to queue on Machine B, No exception is thrown and no ack is returned in Administrator queue. How to handle this situation. Please explain.
Thanks
Chidige

Chidige: Unfortunately, catching such errors with Send isn't possible since MSMQ uses local MSMQ infrastructure to pass on the information to the remote queue. If it doesn't finds it, it will think that the computer or the queue is down.

I have found one option that works for me. You can do a Peek to check for message and if the queue doesn't exists, it will throw up an error. Here's a sample code

MessageQueue rmQ = new MessageQueue("FormatName:Direct=OS:SERVER\\private$\\remote1");
try
{
rmQ.Peek(new TimeSpan(0, 0, 1));
//queue exists, so lets send the message
rmQ.Send("sent to regular queue - Atul");
}
catch (MessageQueueException ex)
{
if(ex.MessageQueueErrorCode == MessageQueueErrorCode.QueueNotFound)
MessageBox.Show("Sorry.. No queue with that name");
}

The Peek will cause validation of the queue and will throw an exception if queue is not found. Since our intention is to just validate the queue presence, I have kept a 1 sec timeout. Hope this helps.

Actually 'DIRECT' is also case sensitive. (as I found out the hard way). strangely it does'nt seem to matter for local computer.

@Abhinav: Thanks for the udpate. However in the examples mentioned above, I have tried with both DIRECT and Direct and both work for me (and they are for remote computers).

Great information! I just found out another issue when trying to send message to a remote queue:

The remote queue must at least have "ANONYMOUS LOGON" send message permission in the queue security settings, otherwise no exception will throw, but your message disappears.

And it is strange, even I set Message. AttachSenderId = true, no sender id in message when recieved. Anyone knows why?

I stumbled across this site when I encountered an odd error. My .Net 1.1 app could write transactionaly to any private que on my machine but one. What intrigued me about your post was the fact that no exception was thrown and yet no message was on the destination queue nor any dead letter or other junk queue. This appears to be really serious issue. We send thousands of messages an hour in our app, and we cannot afford to loose one. That's why we're using a transactional disk based queueing mechanism. The fact that a call can fail yet give no indication of failure is monumental in any decision to continue using a trusted subsystem. I can always fix what can be tested and identified, but invisible non-errored errors are a bit of a problem. In your case, case sensitivity of the formatname was the problem. In my case, that was not the issue. My format name was correct and the queuename itself was pulled from a system generated list. Deleting the queue and re-adding fixed the issue (the same unchanged program worked fine), but the concern remains. I know that this queue was working a week ago, because I was testing this very app against. Any input from anyone about this anomaly would be greatly appreciated.

Hi,
i am using msmq for handling notification.i have a question.i have got 4 to 5 application sending messages to message queue server.Each application wants to get acknowledgment for the messages that particular application send(not all acknowledgments).when i am using administration queue all the acknowledgments are sent there.how can each application fetch acknowledgment for its messages?

The code did not work for me, error says- Format name is invalid. I tried using all the formats given in the posting. Finally one seems to woking for me. Here it is:

mq = New System.Messaging.MessageQueue("FormatName:Direct=http://10.56.13.91/msmq/Private$/testQ1")

How do we enable cross server communication with MSMQ [Public or Private] within the same Domain.

Hi, The code works perfect for the OS and TCP format but I am not able to get the HTTP-version to work. Is there a specific configuration that needs to be done for a remote private queue via HTTP?
Also, if I use the format posted by Ritesh (http://ipaddress/msmq/...) my message disappears. It is not in the outgoing queue and it is not handled in the destination queue. Anyone has an idea what I am missing?

@Vicky, what OS are you working on? Note that the HTTP feature of MSMQ works on XP and Windows 2003 onwards and requires the MSMQ Http support to be installed.

You may want to check the documentation on Microsoft site - http://www.microsoft.com/windowsserver2003/technologies/msmq/default.mspx. In the Technical Overview section you will find two articles, one for HTTP and one for HTTPS.

Hope that helps.

I am trying to connect remote machine using MQueue.Path = "FormatName:DIRECT=OS:libxplkvmz6h\\private$\\tmsmq"
I am not getting any error message. I couldn't find message on remote machine too. Please help me.

@Vamsi, I am assuming that you have already ensured connectivity to the remote machine by doing a ping to that machine.

You may want to check point 5 in my post above to ensure that you are following the right transactional properties also when sending the message to the queue.

@Atul, I am able to ping the machine to which i am sending message. I have checked my code and i am sending to transaction queue and followed all steps which you have mentioned. Code i have written
public void OffLineGeniusCall()
{
try
{
// MessageQueue MQueue = new MessageQueue("LIBXPL3CW669.aceins.com\\Private$\\HigherPriorityQueue");
// MessageQueue MQueue = new MessageQueue(ConfigurationManager.AppSettings["HigherPriorityQueue"].ToString());
//MessageQueue MQueue = new MessageQueue("libxplkvmz6h\\highpriorityqueue");
MessageQueue MQueue = new MessageQueue();
MQueue.Path = "FormatName:PRIVATE=553dd1a5-cc51-4f73-a96d-1f009abac025";

//MessageQueue MQueue = new MessageQueue(@"FormatName:DIRECT=HTTP://172.20.212.30\private$\higherpriorityqueue");
//MessageQueue MQueue = new MessageQueue(@"FormatName:DIRECT=OS:libxplkvmz6h\Public\highpriorityqueue");
//MessageQueue MQueue = new MessageQueue(@"FormatName:DIRECT=TCP://172.20.212.30\private$\higherpriorityqueue");

// create the message and set the base properties
System.Messaging.Message Msg = new System.Messaging.Message();

//DataRow row = geniusDataSet.OffLineMessage.NewOffLineMessageRow();
//row[0] = "PolicyId";
//row[1] = "PolicyTxnId";
//row[2] = "GeniusFeedType";
//row[3] = "NumberOfFail";
//geniusDataSet.Tables[0].Rows.Add(row);
Msg.Priority = MessagePriority.Normal;
Msg.Recoverable = true;
Msg.Formatter = new System.Messaging.BinaryMessageFormatter();
Msg.Body = "Testing MSMQ";
Msg.AttachSenderId = true;
MQueue.Send(Msg,MessageQueueTransactionType.Single);
MQueue.Close();
Label1.Text = "Message sent.";
}
catch (Exception ex)
{
Label1.Text = ex.Message.ToString();
}

}

I have webapplication running on server A and MSMQ installed on server B. Can i send message from server A with out having MSMQ installed on it.

@Atul, still I am unable to send messages to server. Please help.

@Krishna, you will need MSMQ installed on both machines.

@Vamsi, a couple of things
1. Hope there isn't a problem in message creation. Can you try with a simple string message?

2. Looking at the code, I see lot of commented lines and it looks like you are using the following line as queue path
MQueue.Path = "FormatName:PRIVATE=553dd1a5-cc51-4f73-a96d-1f009abac025";

This format works for Public queues but not private queues.

What should work for you is
FormatName:DIRECT=OS:libxplkvmz6h\private$\highpriorityqueue

Note that i have replaced public with private$

3. As an additional check, you may want to view the security properties on the queue to see if the account using which you are sending the message has write access or not. Usually Everyone has write access, but just cross-verify it.

Atul, Thank you very much for your answer. I tried with FormatName:DIRECT=OS:libxplkvmz6h\private$\highpriorityqueue and it works now. Problem i faced is due to firewall blocking.

I am using recoverable messages (non transactional). I have 2 questions:

1. If the remote queue is down, will the messages be lost that are sent during remote end being down?

2. Is there any way I can check if recoverable clause was set (without looking at the code just from msmq admin)?

Atul, the purpose of MSMQ is that it should allow handling of messages even when the remote end is down. In such a case, the messages are stored on sending machine in a temporary queue that is dynamically created.

The transactional property is more useful for writing to queue or reading from queue. If some error happens during that time, the message will still be available in the queue (if say trying to read) and you can re-read it.

thanks a lot. the original post solved my problem.

Hi, Hope to get help from you on problem of memory leaking.

We implement a messaging systems. The server receives message from clients and stores it in MSMQ. It then forward the message to another destination. The program of routing message first enable the MSMQ: MQAutoReceive(q2)
MQAutoReceive (MessageQueue objQName, //) {...//
//......
objQName = new MessageQueue(".\\Private$\\" + qNameToPtTo);
objQName.Formatter = new XmlMessageFormatter(new Type[] { typeof(byte[]) });
objQName.ReceiveCompleted += new ReceiveCompletedEventHandler(nameOfHandler);
objQName.UseJournalQueue = useJournal;
objQName.MessageReadPropertyFilter.ArrivedTime = true;
objQName.BeginReceive();
//......}

The handler of completed message receiving like this:
q2ReceiveCompleted(object p_source, ReceiveCompletedEventArgs p_objAsyncResult)
{
//..........
try{
q2 = ((MessageQueue)(p_source));
m2 = q2.EndReceive(p_objAsyncResult.AsyncResult);

if (m2.ArrivedTime.AddSeconds(msgValidity) Hi, Hope to get help from you on problem of memory leaking.

We implement a messaging systems. The server receives message from clients and stores it in MSMQ. It then forward the message to another destination. The program of routing message first enable the MSMQ: MQAutoReceive(q2)
MQAutoReceive (MessageQueue objQName, //) {...//
//......
objQName = new MessageQueue(".\\Private$\\" + qNameToPtTo);
objQName.Formatter = new XmlMessageFormatter(new Type[] { typeof(byte[]) });
objQName.ReceiveCompleted += new ReceiveCompletedEventHandler(nameOfHandler);
objQName.UseJournalQueue = useJournal;
objQName.MessageReadPropertyFilter.ArrivedTime = true;
objQName.BeginReceive();
//......}

The handler of completed message receiving like this:
q2ReceiveCompleted(object p_source, ReceiveCompletedEventArgs p_objAsyncResult)
{
//..........
try{
q2 = ((MessageQueue)(p_source));
m2 = q2.EndReceive(p_objAsyncResult.AsyncResult);

if (m2.ArrivedTime.AddSeconds(msgValidity) < DateTime.Now)
{
q2.Refresh();
q2.BeginReceive();
return;
}

m2.TimeToReachQueue = new TimeSpan(0, 0, TIME_TO_REACH_Q);
m2.AdministrationQueue = q2AdminQ;
m2.AcknowledgeType = AcknowledgeTypes.FullReachQueue;
m2.UseJournalQueue = true;
//.........................
}
catch {

}
finally {
q2.Refresh();
q2.BeginReceive();
}

We have very serious problem of memory leaking. We dont really comprehend it as the message in queue is removed (EndReceive), but still memory is growing.

Hope to get help from you.

Thank you.

Jimmy, it will be difficult to say that the memory leak in the program is happening due to message queue usage only. You may want to use tools like CLR Profiler or Windbg to try and pin point the problem

Hi Atul, I have one issue. I am accessing queue on remote machine which is domain controller. But there is exception like "A connection with Active Directory cannot be established. Verify that there are sufficient permissions to perform this operation".

Most of the time it works but sometimes, it gives such exception.

If there is permission issue, can u give steps to set the permission in Active Directory to access the public queue.

Can u help me?

Hi, we use NET profiler to trace and obviously it comes from queue message. Moreover, the memory usage increased by time as message sent/received.

Can I ask you a question? What happened to message in temp queue which is created to send to remote machine. They will be deleted/or kept ?

Jimmy, messages in temp queue that gets create while remote server is down, are fowarded when the remote queue is up again and are deleted from the temp queue.

Prashant, I am sorry, but I haven't experimented with public queue and AD. You may have to check the MSDN documentation around the same to find out how to set up security.

But if it was a security/permission issue, it should have never worked. I am surprised that it works sometimes and doesn't sometimes.

Hi,
No problem atul.
Thanks for the time.

I have the following scenario:

CompA is running IIS6 with the web application. There is a file called usersettings.config. In here is the line that tells it where the remote message queue is compB: add key="MessageQueueServerConnectionString value="FormatName:DIRECT=OS:{0}"/>

Both servers are on the domain and using PRIVATE queue. In the web app when initiating the process to send to the remote queue on compB get the message: "Remote computer is not available." Does anybody have any ideas?

Your connection string has a placeholder. How is that being filled? If you do something like MessageQueue.GetPrivateQueuesByMachine(), and the remote machine is down at that time, you will get this error. See my other blog with details on this here.

Prashant,

I am getting the same problem as you are? Did something work out for you?

Note that the double backslashes in the queue name are only required in a C#/C++ environment. In VB, only one backslash is required.

I am trying to send message through http and it's not getting to its destination. If I use tcp then there is no problem. My code for sending message through http is this
objMessageQueue = new MessageQueue("FormatName:Direct=http://xxx.xxx.xx.xx/msmq/private$/incoming");
objMessageQueue.Send("Example","Test");

Message just sits on outgoing queue forever.

Is it possible to delete a private queue on a remote machine?
Have tried using the FormatName structure but doesnt work.

Gani, haven't tried it. Will try and get back, but my general take will be that queue creation and deletion operations should be typically outside of application logic and more of installation/uninstallation routines.

Zahid, have you installed the MSMQ Http Support? It isn't installed by default and is necessary for being able to access the queues over Http.

Hi Atul, first of all thank you for posting this article and answering all the comments. I have a problem with msmq when I am trying to use it with 2 computers that connect to one another. First of all, I am programing with visual basic 6 (not c#) and I have 2 applications that use the queue. Every application in one computer - one is sending to the queue and one is reading from it. I used the syntax that you posted here-"FormatName:Direct=OS:machinename\\private$\\queuename" with convertion to vb6 and it doesn't work, it keeps telling me "invalid queue path". I already have all the code for sending and receiving from the queue and it works if I send the messages to the local computer by the syntax: objQueueInfo.PathName= ".\private$\queuename.

Do I have to add a definition of the formatName or something like that?

Avi, from your machine 1 are you able to ping to the other machine using machine name? Can you try using IP addres of the other machine instead of machine name?

Atul, both the machines are communicating and the ping works very well. I also tried to use the ip address and it's not working. Both the computers have xp professional.

I defined the queue not by code but through the computer managment->private queue->new. My problem is to define the queue in a way that both machines will be able to use it. What will be the msmqQueueInfo.PathName?

Avi, that is strange. Is there any additional event log entry that you get at this time?

What happens if say you keep the Machine B off and then try to post the message? If all is well, it should create an outbound queue on Machine A, which you can view from computer mgmt console.

Having defined the queue via computer mgmt console is just fine and should not cause any issue.

BTW, is the queue transactional and you using the right setting for it?

Atul. thanks a lot for your patience :-)

At the beginning, I used one computer with a non-transactional queue and 2 applications (both of them in the computer) - one is sending to the queue and the other is pulling from it, and it works very well. Now, I am trying to use 2 computers (that connected one to another correctly both with xp professional) with the 2 applications: one application in computer A that sends to the queue and the other, in computer B, that pulls from the queue. I defined the queue in computer A through the computer mgmt and when I send to the queue it works. The problem is when I am trying to pull from computer B and this is not working no matter what syntax I use to create the queue. It keeps telling me "invalid queue path". Where do I need to create the queue, in computer A or in B? I tried to use a transactional queue and that doesn't work even for the sending. I will be grateful if you can resolve the problem.

Avi, the queue can be in either A or B and really is your choice. You can try creating it in B and then try sending message from A and read locally in B.

In case you are reading from B a message in A's queue, you can check this other blog of mine - http://www.infosysblogs.com/microsoft/2007/05/msmq_receiving_messages_from_r.html

If this doesn't help, can you post sample code used for app in A and that in B.

Hi Atul, well nothing has changed and it's still not working. So I am bringing here the code that I use. Like I told you before I use Visual Basic 6.0 and I created the queue named restaurant)through the comp. mgmt ->create new private queue.

Private Sub Class_Initialize()
Set objQueueInfo = New MSMQ.MSMQQueueInfo
objQueueInfo.PathName = "DIRECT=OS:aa\private$\restaurant"
'objQueueInfo.PathName = ".\private$\restaurant"
End Sub


Public Sub sendToMsmq(OrderNumber As Integer)
On Error GoTo ERROR_HANDLER
Set objQueue = objQueueInfo.Open(MQACCESS.MQ_SEND_ACCESS, MQSHARE.MQ_DENY_NONE)
'set the message
Set objMessage = New MSMQ.MSMQMessage
With objMessage
.Label = CStr(OrderNumber)
.SenderIdType = MQMSG_SENDERID_TYPE_NONE
.Send objQueue
End With
Set objMessage = Nothing
ERROR_HANDLER:
End Sub


Public Sub ListenToMSMQ()
Set objEvent = New MSMQ.MSMQEvent
Set objQueue = objQueueInfo.Open(MQACCESS.MQ_RECEIVE_ACCESS, MQSHARE.MQ_DENY_NONE) objQueue.EnableNotification objEvent, , 86400000
End Sub

You have used

objQueueInfo.PathName = "DIRECT=OS:aa\private$\restaurant"

try changing that to

objQueueInfo.PathName = "FormatName:Direct=OS:aa\private$\restaurant"

And I am assuming that you don't have to use "\\" in the string as we need to do in C# (unless we use @)

Also am not sure why you are doing

Set objQueue = objQueueInfo.Open(MQACCESS.MQ_SEND_ACCESS, MQSHARE.MQ_DENY_NONE)

Why create the extra local variable. Why not directly work on objQueueInfo object. And finally I hope MSMQQueueInfo is the right object to work with. In C# I work with MessageQueue

Hi all,

I'm trying to set up my MSMQ for a webservice since one week and impossible to send and receive message !!!

I read a lot of forums and MSMQ documentation to solve my problem but don't find any answer. I hope someone can help me?

Here is my situation.

- Queues are on Server1 with Active Directory
- Webservice on Server2 in Workgroup mode

When I post a message with Webservice to Server1 private queue, using "FormatName:DIRECT=TCP:XX.XX.XX.XX\private$\tonavision" to connect to the queue (Visual Basic), the message is stored into Server2 Outgoing Queue with "Wainting to connect..." status. And it's never delivered to the final queue on server1 !!!!!

I controlled security settings on queues (everyone total control), I ping server1 IP from server2 and server1 send response, but impossible to send and receive message with MSMQ?

I don't know if I'm doing something wrong ? Have someone any ideas to help me ?

Here is a sample of my test application which one try to send msg. I execute it from Server2 to send message to server1 :

Imports System.Xml
Imports System
Imports System.Messaging


Public Class Form1
Public glbMsgId As String

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


End Sub

Public Function GetCustomerInfos(ByVal CustomerNo As String) As XmlDocument 'NavDS
InitMSMQ()

'-----------------------
'Create XML File
'-----------------------
Dim XCustInfo As XmlDocument = New XmlDocument()
Dim Declar As XmlDeclaration = XCustInfo.CreateXmlDeclaration("1.0", Nothing, Nothing)
Dim RootNode As XmlElement = XCustInfo.CreateElement("Root")
Dim CmdNode As XmlElement = XCustInfo.CreateElement("Command")
Dim ToDoAtt As XmlAttribute = XCustInfo.CreateAttribute("ToDo")
Dim CustAtt As XmlAttribute = XCustInfo.CreateAttribute("CustomerNo")
Dim msg As New System.Messaging.Message

'Create Attributes
ToDoAtt.Value = "GetCustomerInfos"
CustAtt.Value = CustomerNo

'Insert Attributes values
CmdNode.Attributes.Append(ToDoAtt)
CmdNode.Attributes.Append(CustAtt)

'Apply Structure Nodes & Child Node
XCustInfo.AppendChild(Declar)
XCustInfo.AppendChild(RootNode)
RootNode.AppendChild(CmdNode)

'-----------------------------
'Prepare message
'-----------------------------
msg.Label = "GetCustomerInfos"
msg.Body = XCustInfo
'-----------------------------
'Send XML to Navision via MSQM
'-----------------------------
msqToNavision.Send(msg, "Navision MSMQ-BA") 'GetIniParameter("MSMQTransaq"))
glbMsgId = msg.Id

Return XCustInfo

End Function

Private Sub InitMSMQ()
Me.msqFromNavision = New System.Messaging.MessageQueue
Me.msqToNavision = New System.Messaging.MessageQueue
'
'mqFromNavision
'
Me.msqFromNavision.DefaultPropertiesToSend.UseAuthentication = False
Me.msqFromNavision.DefaultPropertiesToSend.UseJournalQueue = True
Me.msqFromNavision.DefaultPropertiesToSend.UseTracing = True
Me.msqFromNavision.MessageReadPropertyFilter.LookupId = True
Me.msqFromNavision.Path = "FormatName:DIRECT=TCP:XX.XXX.XX.XXX\fromnavision"
' '
'mqToNavision
'
Me.msqToNavision.DefaultPropertiesToSend.UseAuthentication = False
Me.msqToNavision.DefaultPropertiesToSend.UseJournalQueue = True
Me.msqToNavision.DefaultPropertiesToSend.UseTracing = True
Me.msqToNavision.MessageReadPropertyFilter.LookupId = True
Me.msqToNavision.Path = "FormatName:DIRECT=TCP:XX.XXX.XX.XXX\tonavision"

End Sub
Private Sub btPostMSMQ_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btPostMSMQ.Click
GetCustomerInfos(CustNo.ToString)
End Sub
Private Sub btReceive_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btReceive.Click
ReceiveCustomerInfos()

End Sub
End Class

Hi,

My problem is that I'm not able to send message to a remote private queue.

I've manually created queue on the 2 machines named "testjeff", set the rights for full access to that queue to everyone.

Here is my code:

Dim rmQ As New MessageQueue("FormatName:DIRECT=TCP:192.9.200.225\\private$\\testjeff")

rmQ.Send("Testing")

But I'm still getting invalid path error!

Hi, I have been developing a client-server application with VB6 under WinXP Professional using MSMQ 3.0.
Everything works fine, except when I first start up the clients, they are able to send messages to the server, but when the server replies it doesn't "find" the remote private queues (I am using a workgroup) so they start to pile up for like 2 minutes until they are finally delivered. I am using the Direct=TCP:IPADDRESS approach to send the messages but I don't know what else to check to fix this.

I was reading the MSMQ best practices where it says "MSMQ is designed optimally for sending remotely and receiving locally", that means If I have environment as below:

Windows Server A: Has the Remote Application running on it .
Windows Server B: Has MSMQ and BizTalk Server 2006 installed on it, where in the BizTalk's MSMQ adapter can do transactional read/write using the local Queue.

But then I would probably need to have a Web Service which would write messages to the MSMQ queue remotely on Windows Server B, but then I am not sure will it cater to the reliable messaging mechanism as I am adding one more layer on top of MSMQ.... I am bit confused here now whether I should use transactional reads or not


Please share your thoughts on the same ...

Very helpfull article and comments.
My issue was that the queue did not have "ANONYMOUS LOGON" set.

Hi Atul, first of all thank you for posting this article. I'm working on MSMQ from sending Messages from Machine A and the Messages are storing in the Queue of Machine B. I'm reading that messages which are in Machine B from Machine A using Format Name. My doubt is(According to ur article, we can access remote queues using Format names)how we can identify the remote queue whether it exists or not with out format name. Format name generates automatically while creating MessageQueue. At that time we didnt have Format Name. Can you please tell how to create or identify the queues in remote computer. Presently I'm working with C# and i'm using transactional queues. Is it possible to access remote queues with out format name? and also how we can create the queue in Machine B from Machine A? I will be thankful if u can resolve my problem.

Murali, if not using a full MSMQ setup along with AD, you cannot use friendly names and have to work with formatted names. See my point 2 above for more details.

Hi Atul,
Can u tell the format how to access the queues of network systems using friendly names in AD

Hi Atul,

FormatName is not case-sensitive. I tried it using in all cases and succeeded when the server was local.
However when I tried accessing a remote private queue, I got exception "The specified format name does not support the requested operation. For example, a direct queue format name cannot be deleted."
I have tried setting all necessary permissions.
Any help is appreciated.

Sumit, couple of points:

The blog is 3 years old and at that time our experiments clearly showed that "FormatName" part of the string was case sensetive and this blog is also clearly for remote private queues and not local queues.

I don't clearly recall, but mostly it was .net 2.0 with Windows XP and Windows 2003 is what we were working on at that time. Some behavior may have changed by now. Unfortunately I don't have the bandwidth to check on this at this time.

I am having the same problem reading from a remote queue. I got the following error
"The specified format name does not support the requested operation. For example, a direct queue format name cannot be deleted." My queues are all non-transactional and private. It works perfectly fine on the local machine. I tried point no. 1, but for me, the reverse is true. I got "Format name is invalid" when i used the path naming style you suggested.

Hello there,

We tried to use the "Peek" method on a remote queue to check if it is there. But encounter error "Remote computer is not available".

try
{
string path = "FormatName:DIRECT=TCP:190.168.1.1\private$\test
";

MessageQueue mq = new System.Messaging.MessageQueue(path);

mq.Peek(new TimeSpan(0, 0, 1));
}
catch (MessageQueueException ex)
{
if (ex.MessageQueueErrorCode == MessageQueueErrorCode.QueueNotFound)
{ MessageBox.Show("Sorry.. No queue with that name");
}
else
{
MessageBox.Show(ex.Message); }
}

The remote queue to be connected has access rights given to 'Everyone'.

Local queue (eg. .private$\test) is ok.

Is there some other permission to be set for the 'Peek' method?

Thanks,
Ben

Thanks much. Point #5 helped me. Send method did not throw any error and the message was not being delivered. After reading your post, I was able to resolve the issue.

Point# 6 really helped us to solve our mystery issue.Thanks for the great tip!!

Hi All!
I have the problem like Prashant wrote at April 3, 2008 3:00 PM.
While I’m trying to send messages from MS SQL to public queue on remote computer I have some problem:

A .NET Framework error occurred during execution of user-defined routine or aggregate "SendNotificationToOutgoingQueue":
System.Messaging.MessageQueueException: A connection with Active Directory cannot be established. Verify that there are sufficient permissions to perform this operation.

Most of the time it works but sometimes, it gives such error. For example, I had this problem 73 times while I was trying to sent 40000 messages (total running time: 24min).
If I reduce count of messages or manually reduce sending speed it works stability.
How to solve this problem?

Thanks,
Oleg

Hi all,

Can any one tel me how to access the remote MSMQ queue from linux machine, is that possible, can u tel me which so files i need to use..

Thanks in advance

Hi Atul,

Is it possible to delete a private queue on a remote machine?
I am able to read the private msg queues created in a remote machine but when trying to delete the queue it fails. How to solve it?

I have gps devices conifured to port 1801 tcp. I read that MSMQ is listening o 1801. Where can I find the datapackets ? Will it be in the outgoing queue? I am new to MsMq. My machine runs windows XP and configured as wokgroup . Any suggestions will be of great help. Thankyou

Dear all, appreciate all your comments and questions. Please note that I no longer work on MSMQ and have very limited bandwidth to check things on this and revert on the queries

Hi,

can you please tell me how to connect tibco ems for sending and recieving messages through ssis ?

Hi, Thank you a lot! it worked now! :)

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Please key in the two words you see in the box to validate your identity as an authentic user and reduce spam.

Subscribe to this blog's feed

Follow us on

Blogger Profiles

Infosys on Twitter