In the below class I have a public method called ProcessMessage. This method is responsible for processing the incoming messages. Processing a message involves different stage. I want to decorate this class in such a way that I can publish performance counter values from each stage of the message processing.
I know I can override the ProcessMessage method and rewrite the logic once again with publishing performance counter values. But is there any better way / pattern which I can apply, so that I don’t have to duplicate the logic once again in the decorated class.
public class MessageProcessor
{
public void ProcessMessage()
{
ConvertReceivedMessage();
SendToThirdParty();
ReceiveResponse();
ConvertResponseMessage();
SendResponseToClient();
}
private void ConvertReceivedMessage()
{
//here I want to publish the performance counter value from the decorated class
}
private void SendToThirdParty()
{
//here I want to publish the performance counter value from the decorated class
}
private void ReceiveResponse()
{
//here I want to publish the performance counter value from the decorated class
}
private void ConvertResponseMessage()
{
//here I want to publish the performance counter value from the decorated class
}
private void SendResponseToClient()
{
//here I want to publish the performance counter value from the decorated class
}
}
Thanks.
Aucun commentaire:
Enregistrer un commentaire