473,738 Members | 2,492 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reconnecting to a remote MessageQueue when it has to reboot

I have a VB.Net application that runs as a Windows Service and
monitors a MessageQueue on another machine. At times that machine
will have to be rebooted, so I've been working on how to get my
Service to re-establish the connection after the remote machine is
back.

I found that as soon as the remote machine goes down, the
BeginReceive() method and the ReceiveComplete d() event handler start
throwing an exception, for QueueNotAvailab le, which is very
reasonable. I figured I would catch the exception, tell the
CurrentThread to sleep for, say, 5 seconds, then instantiate the
MessageQueue object again, set its Formatter, add the handler, and
call BeginReceive again. I thought it should continue throwing the
same exception and reinstantiating itself until the remote
MessageQueue is on again.

But now I find that after the new MessageQueue is up (which I can see
in my debugging log) the EndReceive() method called inside the
ReceiveComplete d() throws another exception - "An invalid handle
was passed to the function." I thought maybe the new MessageQueue
instance was null or somehow not right, but I've put debug lines in
to check the MessageQueue properties and the properties of the
AsyncResult passed to EndReceive(), and they are all non-null, so I
figure that's not the problem.

Any clues?
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 20 '05 #1
5 5752
I found there's apparently a cache for handles, so I called
ClearConnection Cache() before reinstantiating the MessageQueue
object, but then the next call to BeginReceive() threw an exception
saying "Remote computer not available" as if the connection cache
stored EVERYTHING needed, not just handles but remote machine name.

So it'g getting to be a circular problem.

By the way, in case it's not clear:

The remote machine has a private Queue on it, that messages from that
machine's processes send messages to. My app is on this machine, and
instantiates a
MessageQueue(na me_of_that_priv ate_queue_on_th e_remote_machin e).
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 20 '05 #2
felecha,
I've just started using MSMQ, so I don't have all the specifics.

Are you working with a public or private queue? I was under the impression
that MSMQ will hide the fact that a remote public queue is not available
from you.

Have you tried asking in one of the MSMQ specific newsgroups?

microsoft.publi c.msmq.*

Hope this helps
Jay

"felecha" <fe*******@yaho o-dot-com.no-spam.invalid> wrote in message
news:40******** **@Usenet.com.. .
I have a VB.Net application that runs as a Windows Service and
monitors a MessageQueue on another machine. At times that machine
will have to be rebooted, so I've been working on how to get my
Service to re-establish the connection after the remote machine is
back.

I found that as soon as the remote machine goes down, the
BeginReceive() method and the ReceiveComplete d() event handler start
throwing an exception, for QueueNotAvailab le, which is very
reasonable. I figured I would catch the exception, tell the
CurrentThread to sleep for, say, 5 seconds, then instantiate the
MessageQueue object again, set its Formatter, add the handler, and
call BeginReceive again. I thought it should continue throwing the
same exception and reinstantiating itself until the remote
MessageQueue is on again.

But now I find that after the new MessageQueue is up (which I can see
in my debugging log) the EndReceive() method called inside the
ReceiveComplete d() throws another exception - "An invalid handle
was passed to the function." I thought maybe the new MessageQueue
instance was null or somehow not right, but I've put debug lines in
to check the MessageQueue properties and the properties of the
AsyncResult passed to EndReceive(), and they are all non-null, so I
figure that's not the problem.

Any clues?
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Nov 20 '05 #3
It's a private queue on a remote machine.

The system we're building is an alerting system. When there's a
disaster, first-responders are alerted and a conferencing system goes
into action. The main control system resides on a host that has no
human interface, but runs on Windows XP Pro. That's where the Queue
is located, on that remote machine. The host communicates with the
human-interfacing software through that queue. I'm writing the
Administration Station application that will be on a regular desktop.
the Admin person can change configuration for the system and then
have the system reset itself. It's during the reset that the Queue
goes down. When it finishes its reset, I need to be able to get back
to receiving messages from the host queue.

How do I get to that newsgroup? I tried just using the links I found
to it, but they go nowhere. I generally use Opera as a browser, and
it says Server not found. IE6 tells me I need to install newsreader
software. I don't know about that.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 20 '05 #4
felecha,
It's a private queue on a remote machine. I suspect this may be the issue, however I only open private queues on the
local machine...
How do I get to that newsgroup? I tried just using the links I found
to it, but they go nowhere. I generally use Opera as a browser, and
it says Server not found. IE6 tells me I need to install newsreader
software. I don't know about that. How are you accessing this group?

Remember I gave you the root of a number of groups...

Here is the list on Google:

http://groups.google.com/groups?hl=e...ft.public.msmq

I would think either:
microsoft.publi c.msmq.networki ng
microsoft.publi c.msmq.programm ing
microsoft.publi c.msmq.setup

Can answer your question.

Hope this helps
Jay

"felecha" <fe*******@yaho o-dot-com.no-spam.invalid> wrote in message
news:40******** **@Usenet.com.. . It's a private queue on a remote machine.

The system we're building is an alerting system. When there's a
disaster, first-responders are alerted and a conferencing system goes
into action. The main control system resides on a host that has no
human interface, but runs on Windows XP Pro. That's where the Queue
is located, on that remote machine. The host communicates with the
human-interfacing software through that queue. I'm writing the
Administration Station application that will be on a regular desktop.
the Admin person can change configuration for the system and then
have the system reset itself. It's during the reset that the Queue
goes down. When it finishes its reset, I need to be able to get back
to receiving messages from the host queue.

How do I get to that newsgroup? I tried just using the links I found
to it, but they go nowhere. I generally use Opera as a browser, and
it says Server not found. IE6 tells me I need to install newsreader
software. I don't know about that.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Nov 20 '05 #5
Well I have stuff to learn still, I guess. I was able to get to the
groups directly through the google link, but earlier attempts gave
messages saying I needed newsreader software, which I don't know
about.

Anyway, I did see a post at one of the groups that led me to
msmqfaq.doc, where I found something that pretty much confirms me in
my conclusion about my problem. The items says:

4. An attempt to read from a remote queue fails with error
“invalid-handle.” Why?
This probably occurred because the remote computer has restarted, and
you use a cached queue handle that is no longer valid.
In core MSMQ, a local application uses a handle of the local MSMQ
service when reading from a remote queue, and the local MSMQ service
in turn has a remote queue handle from the remote computer. If the
remote computer restarts, the remote queue handle used by the local
MSMQ service is no longer valid. The standard workaround for this is
to close and reopen the queue. However, by default this workaround
does not work in the Microsoft .NET Framework, and the Close method
of the MessageQueue object does not close the queue handle. This is
because the .NET Framework uses a connections cache that caches queue
handles. To close a queue handle, either disable the connections
cache, or call ClearConnection Cache.

Well, it looks like the cache is the issue, but ... I already tried
disabling and clearing, and both steps led to other exceptions being
thrown.

Last night I tried another idea -- in the catch for the exception when
the remote queue goes down, I send an MSMQ Message to a LOCAL queue
that I set up, with a second little app running that has a
MessageQueue object that listens to THAT queue, and simply calls
ServiceControll er.Stop and ServiceControll er.Start on my Service, in
effect "rebooting" my Service in response to the reboot of the remote
machine. It keeps rebooting the Service every 5 seconds until the
remote queue comes up and then the connection is established and we
go on just fine.

It works consistently so far, but I still hope I can solve the cache
problem internally in the Service somehow. Creating apps to control
other apps bothers me.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3581
by: Bihari Srinivasan | last post by:
I am using two PCs, say PC-1 and PC-2 in a networked environment (TCP/IP). Both of these run Windows 2000. PC-1 is a development platform and PC-2 is a remote debug platform. I have a very simply console application written in VB.NET that is built on PC-1 using VisualStudio.NET. I set the VisualStudio.NET debugging environment to execute the application on PC-2. This works as long as pcAnywhere is NOT installed on PC-2 (it does not...
1
1985
by: Anibal David Acosta F. | last post by:
I want to access to MessageQueue from a remote machine, the path ".\private$\myQueue" only works locally, and the path "\\myServer\private$\myQueue" doesn't works. Do you know how can I access? some example? Thanks
3
5099
by: Gerhard Swart | last post by:
Hi all. I'm writing a queue browser that reads queues from a specified machine and then display the data that's on the queue. I am using the MessageQueue Class in .Net(C#). I get the problem that I can't read the journal private queue on a remote machine. I don't know if this is possible though. I have tried all the possible options but can't seem to get it to work. The code that I tried is: MessageQueue _mq = new MessageQueue(...
6
11483
by: deepak | last post by:
I have to create message queue at remote machin. My code works properly when i use console application in c#. But it throws exception whenever i try it on web application in c#. My code is MessageQueue.Create("FormatName:DIRECT=OS:MachineName\\QueueName"); or MessageQueue.Create("MachineName\\QueueName");
4
2295
by: Ash | last post by:
Is there a built in classes in .NET to make it easy to read/write MSMQ messages to/from remote queues? If not then what is the best way to implement it?
0
2133
by: Marcus | last post by:
Hello All, I am trying to create a private MSMQ message queue on a remote application server from an asp.net application using the following code: Dim queue As MessageQueue queue = MessageQueue.Create("FormatName:DIRECT=OS:AppServer\private$\" & Me.TextBox1.Text)
2
2169
by: felecha | last post by:
I'm stumped. I'm working on an application in VB.Net that uses System.Messaging.MessageQueue to listen for messages sent to a private queue on a remote machine. Both machines are in the same Workgroup in a small private LAN. The messaging is working fine, but since the remote machine is used as a control system and has to be rebooted when there is a configuration change, I have to handle the remote queue going down and coming back up...
0
1465
by: chi.chung.ko | last post by:
Dear Pals local:Windows XP Sp2 server:Windows 2K3 Sever R2 When Use to Receive MessageQueue On Server System.Messaging.MessageQueue IQ = new MessageQueue(); IQ.Path = "FormatName:DIRECT=TCP:192.168.1.203\\public" return_msg = IQ.Receive();
1
2829
by: dif1754 | last post by:
My Windows DB2 Server 9.x is connected, via federation, to a remote AS/ 400 system: I created several nicknames to remote tables and I can query them. Problem is, during the night, my remote AS/400 is rebooted and DB2 Server cannot connect back to it. Is there any DB2 parameter I must set to reconnect automatically to the remote federated AS/400.
0
8968
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9473
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9334
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9259
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9208
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8208
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6750
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.