private void startOutboundProcessing(object state) { OutboundHandler outboundHandler = (OutboundHandler)state; try { outboundHandler.Begin(); } catch (Exception ex) { ErrorLogger.LogError(ex, "startOutboundProcessing(object state)", outboundHandler.getApplicationName()); } }
public static void handleProcessingForOutboundHandler(Configuration masterConfig, OutboundHandler outboundHandler) { // to control some basic CPU handling settings Config outboundConfig = new Config(); // load each of the configurations into their own objects List <Application> applications = masterConfig.applications; List <Communication> communications = masterConfig.communications; List <WebserviceObject> webserviceObjects = masterConfig.webserviceObjects; List <WebserviceInstance> webserviceInstances = masterConfig.webserviceInstances; List <WebservicePropertySet> webserviceProperties = masterConfig.webservicePropertySets; List <MessageGroup> messageGroups = masterConfig.messageGroups; List <MessageGroupInstance> messageGroupInstances = masterConfig.messageGroupInstances; // continue to read the table while (true) { applications.ForEach(delegate(Application app) { if (app.name == outboundHandler.getApplicationName()) { // get the unprocessed message count for the application List <MessageBucket> brokerInformation = MessageBucketDAO.GetUnprocessedMessageHeaderInstancesByApplication(app); // set the MOD from config file. var options = new ParallelOptions { MaxDegreeOfParallelism = outboundConfig.MaxDegreeOfParallelism }; // parallel For each Parallel.ForEach(brokerInformation, options, broker => { // get the message header and message MessageHeaderInstance messageHeaderInstance = broker.messageHeaderInstance; Message message = broker.message; // srub the input of bad stuff string hl7Scrubbed = HL7MessageUtility.scrubHL7MessageForParse(message.hl7Raw); // make the hl7 message HL7Message hl7Message = HL7MessageDAO.getMessage(hl7Scrubbed); // locally retrieve the communication object from memory Communication communication = ConfigurationUtility.GetIncomingWebserviceCommunication(app, communications); // locally retrieve the webservice instance object from memory WebserviceInstance webserviceInstance = ConfigurationUtility.GetIncomingWebserviceInstance(communication, webserviceInstances); // locally retrieve the web service objects from memory List <WebserviceObject> wsObjects = ConfigurationUtility.GetIncomingWebserviceObjects(webserviceInstance, webserviceObjects); // determine the message type Generic.MessageType messageType = HL7MessageUtility.getMessageType(hl7Message, hl7Scrubbed); switch (messageType) { // to handle a new message add message type then its own handler case Generic.MessageType.ADT: break; case Generic.MessageType.ORM: handleProcessingForORM(wsObjects, webserviceProperties, hl7Message, messageGroupInstances, messageGroups, app, message); break; case Generic.MessageType.ORU: handleProcessingForORU(wsObjects, webserviceProperties, hl7Message, messageGroupInstances, messageGroups, app, message); break; case Generic.MessageType.SIU: break; case Generic.MessageType.UNKNOWN: break; default: break; } // update the table to processed MessageBucketDAO.UpdateProcessedFlagAndMessageLog(messageHeaderInstance, message, true); // update broker stats handleBrokerStatUpdate(message, communication); }); } }); // provide blocking if there is no data to process. Thread.Sleep(1000); } }