c# - How can you read the count of an MSMQ on another machine? -
My program is successfully using the .NET MessageQueue class to read from an MSMQ I queue user is configurable , And sometimes on a local machine, and sometimes on a remote machine. The user can specify the remote machine with the name or IP address and the queue name (and I am using only "private" queues).
The queue I want the user to be in, but there is no way to do this. This is not a count (or similar) property to give me easily in the MessageQueue class.
To get the count, I am using Display Control and Display Content category sections - but only to work for me on the local machine (although I am not completely sure that I I'm using it correctly).
My question is how to read the calculation (number of messages) from an MSMQ remote machine?
I use the following method to count the message (works for both local and remote queues Is),
var machineName = "mymachine01"; Var formatName = "FormatName: DIRECT = OS: mymachine01 \ Personal $ \ ftpreceived": try {var msmqManagement = new MSMQ.MSMQManagement (); MsmqManagement.Init (machine name, empty, formatName); Return (UIT) MSM One Management Message count; } Hold (COMException) {// if the queue is not active or does not exist. If (ex.ErrorCode ==-1072824316) {return 0; } throw; }
Note: If the queue is not present or not active, then the MSMQ Management API recognizes the same error, in this case 0 returns.
Note: If the machine name value is zero, it will look at the queue on the local machine.
Note: If the machine-name variable is different from the machinename part of the format name, then it quotes the "Outgoing" message with the format name given on the machine specified by the name of the machine. Active means that there are 1 or more messages in it, or it has a message in the previous n (it is not sure how big is N)) seconds, after that time the queue is considered inactive goes.
Comments
Post a Comment