Monitor your services Remotely


Today i want to discuss if a service is installed in the machine.how to check the Services are properly working or not.If we want to continuously monitor the service.What we need to do? In this article i will give detailed description with snippet of code lines and real output images.

Scenario we need to monitor the services :
Suppose when a service is installed in your computer to complete the task and schedule it at night time we are unable to know the status of the service whether service is doing the required task or not.So for that we need to monitor the service even we are at remote location.So for that we need try and catch all the exceptions raised in the Service and sent to message queue.

Why we need a Queue to monitor the service :

Flat files or xml Files are very tedious because opening and writing the files may struck lead to unresponsive Hence it is difficult to write in the file and we can not able to monitor it remotely.So we need to choose another alternative way to know the exceptions raised by the service.And it should exists in all computers as a component that component is none other than Message Queue.


what Message queue dll we need to Use
In General Message queues that exists in the asp.net is system.Messagequeue With this dll it is very complex to retrieve the Messages from the remote system.So we need a special dll we can use to retrieve the Messages from Message queues.So there exists a COM component in our Microsoft Visual studio that Component Object Model dll is Messagequeue3.0 Object Library

see the below picture in my remote computer some private Message queues exist now my task is to retrieve those Messages from the Message queue.

msmqmessages


Now the below picture will see the code with real time images.

Before that we need to add one dll that is Microsoft Message Queue 3.0 Object Library present in the Com component otherwise download from google
add add a reference. after adding this reference dll in your project we need to write the following code

msmqoutgoingacess

First of all we need to write the following Code


queueFormatName = @"DIRECT=TCP:IPADDRESS\Private$\PrivateOrders";


Steps to work with Messagequeue3.0 Object Library

Step 1: We need to create the queue for that we need to Create the instance of the queue.

MSMQ.MSMQQueueInfo info = new MSMQ.MSMQQueueInfo();


step 2: We need to write specified format of the Message Queue

queueFormatName = @"DIRECT=TCP:ipadress\Private$\PrivateOrders";
info.FormatName = queueFormatName;


step 3: We need to open the Message queue with Control access

MSMQ.MSMQQueue mq = info.Open((int)(MSMQ.MQACCESS.MQ_PEEK_ACCESS), (int)MSMQ.MQSHARE.MQ_DENY_NONE);


Step 4 :
my queue name is Private Orders.So i want to retrieve the messages from the private orders

MessageQueueCoding

step6

Retrive Message queue
see the debug from the Microsoft Visual studio debugging

retrieve message queue

Output Results in the List Box :

Retrivations Message queue

If you are Using peekcurrent function will point out first message in queue that means You are fetching the queue which exists in the remote computer and removing the message from the queue.

Still you can fail to retrieve the messages from the Message queue.than manually set the access operations to the queue by opening the Computer management .


Attachments

Article by srirama
A Good advice from parent to a Child , Master to a Student , Scholar to an Ignorant is like a doctor prescribed pill it is bitter to take but when they take it will do all good for them --- Bhushan

Follow srirama or read 73 articles authored by srirama

Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: