A message processor is the class that you will create to handle a message when the framework off loads a message that it has been received for you to deal with.

One of the good things about the message processor pattern is that each listener you create can have a different message processor. This means that if you are stubbing out an application in two different test scenarios you can use a different message processor for each scenario if you require different logic for each test.

In the message processor you must implement the IMessageProcessor interface. There are three elements to this interface:
  • ReturnsResponse
  • Execute
  • ExecuteWithResponse

Each processor can only handle either one way messages or messages with a response/acknowledgement. The ReturnsResponse property is used to indicate which your processor does. Once you have indicated this behaviour then you must implement code in one of the Execute methods and in the other simply throw a not supported or not implemented exception.

In the interface you will be dealing with messages are strings which is going to be the raw HL7 data. You wont need to worry about any MLLP specifics. If you want to you can use the HL7Message class in the framework to help you to work with the HL7 data.

Below is a sample of a message processor.

Sample Message Processor

public class HISMessageProcessor : IMessageProcessor
        string IMessageProcessor.ExecuteWithResponse(string message)
            //This is not needed
            throw new NotImplementedException();

        void IMessageProcessor.Execute(string message)
            var testEventsLogger = new DiagnosticsEventLogger(Helpers.Config.TestEventsQueuePath);
            testEventsLogger.RaiseEvent("HIS received message", message);

            AppFx.BizSpec.Helpers.IO.FileHelper.WriteToFile("HIS_MessageReceivedFromBizTalk.txt", message);

            var hl7Message = new HL7Message(message);
            testEventsLogger.RaiseEvent("HIS processed message", hl7Message.ToString());   

        bool IMessageProcessor.ReturnsResponse
            get { return false; }

Last edited Apr 21, 2014 at 1:08 AM by michaelstephenson, version 1