473,385 Members | 1,824 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Open existing MSMQ

Hi,

one stupid question? How can i be sure that i have valid queue:

using System;
using System.Messaging;

// . . .

MessageQueue q = new MessageQueue( ".\\Private$\\myQueue" );

// Can i call send!?!?
q.Send( "Hello!" );

Is there a way to open existing queue?
thc

Kimmo Laine
Nov 15 '05 #1
3 1984
You can check a queue existance using the MessageQueue.Exists method.

Then you know whether the queue can be used.
--
Cezary Nolewajka
mailto:c.*********************@no-sp-am-eh-mail.com
remove all "no-sp-am-eh"s to reply
"Kimmo Laine" <reply.to@newsgroup> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,

one stupid question? How can i be sure that i have valid queue:

using System;
using System.Messaging;

// . . .

MessageQueue q = new MessageQueue( ".\\Private$\\myQueue" );

// Can i call send!?!?
q.Send( "Hello!" );

Is there a way to open existing queue?


thc

Kimmo Laine

Nov 15 '05 #2

From MSDN: "Exists is an expensive operation. Use it only when it is
necessary within the application."

Is there another way to do it?
Kimmo Laine
"Cezary Nolewajka" <c.*********************@no-sp-am-eh-mail.com> wrote in
message news:uc**************@TK2MSFTNGP12.phx.gbl...
You can check a queue existance using the MessageQueue.Exists method.

Then you know whether the queue can be used.
--
Cezary Nolewajka
mailto:c.*********************@no-sp-am-eh-mail.com
remove all "no-sp-am-eh"s to reply
"Kimmo Laine" <reply.to@newsgroup> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,

one stupid question? How can i be sure that i have valid queue:

using System;
using System.Messaging;

// . . .

MessageQueue q = new MessageQueue( ".\\Private$\\myQueue" );

// Can i call send!?!?
q.Send( "Hello!" );

Is there a way to open existing queue?
thc

Kimmo Laine

Nov 15 '05 #3
True. That is why you should do that only once - when application or service starts.

A trick to use is to do a Peek (TimeSpan.Zero) on the MQ you want to test and see if and what exception (if at all) you receive.

In case of an non-existant queue, the MessageQueueException has the MessageQueueErrorCode property set to "QueueNotFound" value.

If there are no messages in the queue, you will get a timeout exception, so you will know that the queue exists.
If there are any messages, then you will not receive any exceptions.

--
Cezary Nolewajka
mailto:c.*********************@no-sp-am-eh-mail.com
remove all "no-sp-am-eh"s to reply
"Kimmo Laine" <reply.to@newsgroup> wrote in message news:Ow**************@TK2MSFTNGP11.phx.gbl...

From MSDN: "Exists is an expensive operation. Use it only when it is
necessary within the application."

Is there another way to do it?


Kimmo Laine


"Cezary Nolewajka" <c.*********************@no-sp-am-eh-mail.com> wrote in
message news:uc**************@TK2MSFTNGP12.phx.gbl...
You can check a queue existance using the MessageQueue.Exists method.

Then you know whether the queue can be used.


--
Cezary Nolewajka
mailto:c.*********************@no-sp-am-eh-mail.com
remove all "no-sp-am-eh"s to reply


"Kimmo Laine" <reply.to@newsgroup> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,

one stupid question? How can i be sure that i have valid queue:

using System;
using System.Messaging;

// . . .

MessageQueue q = new MessageQueue( ".\\Private$\\myQueue" );

// Can i call send!?!?
q.Send( "Hello!" );

Is there a way to open existing queue?
thc

Kimmo Laine


Nov 15 '05 #4

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

Similar topics

3
by: Vai2000 | last post by:
hi all, I have a winsvc which reads of messages out an MSMQ. Can someone help with this problem. If my server goes down and comes back up my WinSvc doesn't picks up messages accumulated in the...
10
by: Jet Leung | last post by:
Hi all, Where is the MSMQ use for? For example, I have a client program to control the database and how can I use MSMQ in my program? When I should use it? For example I have a method to insert...
4
by: SRLoka | last post by:
I have an application that has five threads. All five threads write to the same MSMQ. All five threads are using the same global instance to send data to the MSMQ server(on same machine)....
5
by: DBC User | last post by:
Hello, Is there an alternative approach to MSMQ for delivering messages? I am planning to develop an app which I don't want clients to install MSMQ (or do anything otherthan install my app). I...
0
by: yonirabin | last post by:
Hello, I am building a system in C# 2.0 using the master - worker design pattern The system is supposed to work as follows: 1. The Master sends Command objects to the workers 2. All Commands are...
3
by: yonirabin | last post by:
Hello, I am building a system in C# 2.0 using the master - worker design pattern The system is supposed to work as follows: 1. The Master sends Command objects to several workers 2. All Commands...
11
by: Jon Davis | last post by:
Can a solution built in C# utilize MSMQ and/or MTS? If so, does this make the training material I already have on MSMQ and MTS in the context of VB6 an appropriate prerequisite foundation before...
1
by: Florence Tissot | last post by:
We are seeing some kind of resource leak in our performance lab running an ASP.NET (2.0) application that sends and receives messages from 2 public MSMQ queues. Here's a brief summary of what are...
1
jackb
by: jackb | last post by:
Structure of my application is: 1. Message is dispatched to an application 2. That application puts the message in a private queue 3. Another application reads messages from this queue and...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.