1,105,633 Community Members

send msg to class

Member Avatar
anisha.silva
Posting Whiz in Training
260 posts since May 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

hi,
i have a class handler and a class health monitor. i have 2 instanses of the handler class as primary and secondary. in the start of the appliacation the primary and th secondary handler is set. what i want to do is once the primary is set up every one minute i need to send a msg to the health monitor updating the status.

how do i do it in C# asp.net

appreicate a reply

thanks

LastMitch
Deleted Member
 
0
 

@anisha.silva

i have 2 instanses of the handler class as primary and secondary. in the start of the appliacation the primary and th secondary handler is set. what i want to do is once the primary is set up every one minute i need to send a msg to the health monitor updating the status.

Read this and used the example:

http://msdn.microsoft.com/en-us/library/system.web.mail.mailmessage.aspx

Member Avatar
JorgeM
IT Addict
6,416 posts since Dec 2011
Reputation Points: 581 [?]
Q&As Helped to Solve: 963 [?]
Skill Endorsements: 172 [?]
Moderator
Featured
Sponsor
 
0
 

I dont beleive that anisha.silva is asking about email messages. This seems to be related to MVC if I am not mistaken. unfortunately, I do not have experience in this area.

LastMitch
Deleted Member
 
0
 

MVC

You mean ASP.net MVC? It's bit hard to understand his questions sometimes without any code just what code he wants.

Read this:

http://msdn.microsoft.com/en-us/library/bb398933%28v=vs.100%29.aspx

and this

http://support.microsoft.com/kb/308001

Member Avatar
anisha.silva
Posting Whiz in Training
260 posts since May 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Diagram i have attached a picture
so what i am trying to implement is the arrow going from hander to health monitor and from health monitor to the proxy

i was not asking about email messaging,

LastMitch - the link you provided me is to monitor a web application, but i want to monitor just one class in my applicatin

how i ddin't make you'll confuse

Attachments
LastMitch
Deleted Member
 
0
 

LastMitch - the link you provided me is to monitor a web application, but i want to monitor just one class in my applicatin

Nice diagram!

So you want to monitor One Class in the Application.

Have you try to create Alert by sending a message to the Admin?

Like for example, if there is some activity in that One Class and it will alert you by sending an message to the Admin to let you know that there is some activity in that One Class?

So it's kinda like monitor that One Class.

Is this something you are looking for?

Member Avatar
anisha.silva
Posting Whiz in Training
260 posts since May 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

well actually i want to monitor 3 classes in the diagram, Handler, Result Engine and the Query Engine,
If i implemnt it for one class it is the same concept for the others too.

alert? how do i do that

what i am tryin to figure out is, say the Hander class do some processing, and suddenly it fails and there is no one to do the processing.so there should be some mechanism to track it. so that is y i am trying to make it, so that when it fails the Health monitor knows that it didn't send a msg in after 1 min(as an ex i gave 1 min), so then the health monitor, tell the proxy to being the second instanse of the handler up, and to handle the processing.

is it clear?

Member Avatar
hometownnerd
Junior Poster in Training
50 posts since Sep 2007
Reputation Points: 13 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 4 [?]
 
1
 

Another thing to consider, simplistic but could be good enough is to have the classes place date and time in the database and have your health monitors check for the date and time. Again, very simple, but it could let you know the process is still running or not. I do that for an app I have running on a server and seems to work fine.

LastMitch
Deleted Member
 
0
 

well actually i want to monitor 3 classes in the diagram, Handler, Result Engine and the Query Engine,

Like what hometownnerd suggest place date and time in the database have the health monitors check for the date and time looks good in the long run.

Base on your code you want three and maybe in the future you need to add another code for the new one. By having a query it will keep the code in tact.

Member Avatar
anisha.silva
Posting Whiz in Training
260 posts since May 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

so want to make sure that i understood it.
So i should have 3 db tables in the database. and for example say 1 min, the Handler, result engin and the query engin should add a record to the db.

if is does not have a record in the db the haelth monitor figures out that the componenets have failed and bring the other instanse of the componenet up.

is this what hometownnerd suggested?

LastMitch
Deleted Member
 
0
 

I think hometownnerd mention 1 database and creating a query for health monitors to fetch the id.

So i should have 3 db tables in the database

You have 3 database or 3 tables relating to Handler, Result Engine and the Query Engine?

And each database has Handler, Result Engine and the Query Engine in it?

Member Avatar
anisha.silva
Posting Whiz in Training
260 posts since May 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

no no, sry
i was asking whether i should have 1 database and 3 tables for each class or

1 database with one table?

LastMitch
Deleted Member
 
0
 

i was asking whether i should have 1 database and 3 tables for each class or

1 database and 3 tables (Handler - 1 , Result Engine - 2 ,Query Engine - 3).

I think in long run this is the a better option if you need to update or add another class to the website.

Member Avatar
anisha.silva
Posting Whiz in Training
260 posts since May 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

hmm

so basically what i should do is add a record to the database updating the status of each class and then the health monitor checks the database regularly,

this method in the sense of performance and cost is expensive right? (because database access)
is there another way that i can do this increasing the performance?

if not i could use the database method
thanks

Member Avatar
hometownnerd
Junior Poster in Training
50 posts since Sep 2007
Reputation Points: 13 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 4 [?]
 
1
 

I would make a single table that would house all 3 of the handlers....in your table have a field called monitor, field called lastcheck....then row 1 could have handler in monitor field, row 2 could have result engine in monitor field and row 3 could have query engine in monitor field....then have class update lastcheck with now() anytime it fires depending on which class it would update the correct row. You could even start with the class updating the lastcheck field when it starts the run then have another field called status that could be populated at the end of the class with some sort of status to let you know the class started and completed. Simple and only needs a single table and could grow as handlers are needed and can even add other fields if you want to track other things in the class, like variables etc as the class fires.

Hope that helps,
Larry

Member Avatar
anisha.silva
Posting Whiz in Training
260 posts since May 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

so shoudn'there be a global timing system among the health monitor and the oth 3 calsses, how does it work

Member Avatar
hometownnerd
Junior Poster in Training
50 posts since Sep 2007
Reputation Points: 13 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 4 [?]
 
0
 

Yes you would need some sort of timer running on the system. Not sure what kind of system you have and what the ability of the servers are to determine what kind of timer you could potentially use, there are plenty of timer classes out there and you could have it fire when the app starts and then have the timer call itself after the set amount of time once it has completed firing. You could create 3 timers with different names so they would be independent. As far as code is concerned, not sure, but will look around. I use VB.Net for my server heartbeat app and I just placed 2 timers on the form to perform the datetime insert.

hope that helps a bit,
Larry

Member Avatar
hometownnerd
Junior Poster in Training
50 posts since Sep 2007
Reputation Points: 13 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 4 [?]
 
1
 

Here is a timer class for c#...I do not write c#, but it seems similar to the standard timer control....

using System;
using System.Timers;

class myApp
{
public static void Main()
{
Timer myTimerHandler = new Timer(); //this creates the timer control
myTimerHandler.Elapsed += new ElapsedEventHandler( TimeEventHandler ); //this builds the event that will fire when the timer trips....event is called "TimeEventHandler"
myTimerHandler.Interval = 1000; //this is the number of milliseconds between firings...1000 = 1 second....if you set this too low MAKE SURE YOU STOP THE TIMER first thing in the event
myTimerHandler.Start(); //this starts the timer so you can then watch the event

Timer myTimerResult = new Timer(); //this creates the timer control
myTimerResult.Elapsed += new ElapsedEventHandler( TimeEventResult ); //this builds the event that will fire when the timer trips....event is called "TimeEventResult"
myTimerResult.Interval = 1000; //this is the number of milliseconds between firings...1000 = 1 second....if you set this too low MAKE SURE YOU STOP THE TIMER first thing in the event
myTimerResult.Start(); //this starts the timer so you can then watch the event

Timer myTimerQuery = new Timer(); //this creates the timer control
myTimerQuery.Elapsed += new ElapsedEventHandler( TimeEventQuery ); //this builds the event that will fire when the timer trips....event is called "TimeEventQuery"
myTimerQuery.Interval = 1000; //this is the number of milliseconds between firings...1000 = 1 second....if you set this too low MAKE SURE YOU STOP THE TIMER first thing in the event
myTimerQuery.Start(); //this starts the timer so you can then watch the event


 }

public static void TimeEventHandler( object source, ElapsedEventArgs e )
{
myTimerHandler.Stop();//I think this is what you would do to stop the timer
// this is where you could call the class monitor

myTimerHandler.Start();//need to restart the timer before you leave the timer so it will fire again
  }
 }

 public static void TimeEventResult( object source, ElapsedEventArgs e )
{
myTimerHandler.Stop();//I think this is what you would do to stop the timer
// this is where you could call the class monitor

myTimerHandler.Start();//need to restart the timer before you leave the timer so it will fire again
  }
 }

 public static void TimeEventQuery( object source, ElapsedEventArgs e )
{
myTimerHandler.Stop();//I think this is what you would do to stop the timer
// this is where you could call the class monitor

myTimerHandler.Start();//need to restart the timer before you leave the timer so it will fire again
  }
 }

This may work for you...creates 3 timers and 3 events to handle the 3 monitor checks. I am not 100% sure in the code, but seems sound. One thing to keep an eye on is setting the interval too short where timers will fire again before the last timer has completed its work. That is why I placed the Stop and Start in the event. I pulled this from http://www.codeguru.com/csharp/sample_chapter/article.php/c7763/Working-with-a-Timer-in-C-The-Basics.htm

Let me know,
Larry

Member Avatar
anisha.silva
Posting Whiz in Training
260 posts since May 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

hey

in the method TimeEventHandler(), line myTimerHandler is underlined saying it is not identified in the current context, it gives the same msg to TimeEventResult() and TimeEventQuery()

how do i dolve this?
also how does the myApp communicate in updating the timer?i don't understand it.

appreciate a reply
thanks

Member Avatar
hometownnerd
Junior Poster in Training
50 posts since Sep 2007
Reputation Points: 13 [?]
Q&As Helped to Solve: 6 [?]
Skill Endorsements: 4 [?]
 
0
 

Ok...here is updated class....like I said I am not a C# developer so it was rough around the edges...

using System;
using System.Timers;


    public class Class1
    {
        private static System.Timers.Timer myTimerHandler = new System.Timers.Timer(); //this creates the timer control
        private static System.Timers.Timer myTimerResult = new System.Timers.Timer(); //this creates the timer control
        private static System.Timers.Timer myTimerQuery = new System.Timers.Timer(); //this creates the timer control

public static void Main()
{

myTimerHandler.Elapsed += new ElapsedEventHandler( TimeEventHandler ); //this builds the event that will fire when the timer trips....event is called "TimeEventHandler"
myTimerHandler.Interval = 1000; //this is the number of milliseconds between firings...1000 = 1 second....if you set this too low MAKE SURE YOU STOP THE TIMER first thing in the event
myTimerHandler.Start(); //this starts the timer so you can then watch the event
myTimerResult.Elapsed += new ElapsedEventHandler( TimeEventResult ); //this builds the event that will fire when the timer trips....event is called "TimeEventResult"
myTimerResult.Interval = 1000; //this is the number of milliseconds between firings...1000 = 1 second....if you set this too low MAKE SURE YOU STOP THE TIMER first thing in the event
myTimerResult.Start(); //this starts the timer so you can then watch the event
myTimerQuery.Elapsed += new ElapsedEventHandler( TimeEventQuery ); //this builds the event that will fire when the timer trips....event is called "TimeEventQuery"
myTimerQuery.Interval = 1000; //this is the number of milliseconds between firings...1000 = 1 second....if you set this too low MAKE SURE YOU STOP THE TIMER first thing in the event
myTimerQuery.Start(); //this starts the timer so you can then watch the event
 }
public static void TimeEventHandler( object source, ElapsedEventArgs e )
{
myTimerHandler.Stop();//I think this is what you would do to stop the timer
// this is where you could call the class monitor
myTimerHandler.Start();//need to restart the timer before you leave the timer so it will fire again

 }
 public static void TimeEventResult( object source, ElapsedEventArgs e )
{

     myTimerResult.Stop();//I think this is what you would do to stop the timer
// this is where you could call the class monitor
    myTimerResult.Start();//need to restart the timer before you leave the timer so it will fire again

 }
 public static void TimeEventQuery( object source, ElapsedEventArgs e )
{
    myTimerQuery.Stop();//I think this is what you would do to stop the timer
// this is where you could call the class monitor
myTimerQuery.Start();//need to restart the timer before you leave the timer so it will fire again
  }

    }

As far as what is actually going to do the updating, I am unclear about what is doing the monitoring yet, the app that will be doing using the timers to update the DB will be running all of the time and you will start the timers on start and then the 3 timeevents will fire every however often and they will be in charge of sending the info to the db. You would put the health checks in those 3 timers to strobe the datetime etc into the DB. As far as deciding on the health, you would need to figure out how to do that based on your setup and the apps you have running, something must be running already to do the class work, this would be another layer on that. Not sure what you want to check yet.

Let me know,
Larry

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: