コード例 #1
0
        /** Called by the Listener to process a received message. See if this
         * is a response and correlate with requests if it is, otherwise add
         * to the received messages queue. This is called by Listener.processMessage()
         * which is invoked in its own thread, so we don't need to spawn any new
         * threads here.
         *
         * @param Received message
         */
        internal void receive(Sendable s)
        {
            if (s.SoapAction.Contains("service:Acknowledgment") || s.SoapAction.Contains("service:MessageError"))
            {
                // Asynchronous ack/nack. Remove from request list and exit.
                //
                EbXmlMessage m = (EbXmlMessage)s;
                if (!requests.Remove(m.Header.ConversationId))
                {
                    // Log receipt of ack/nack that doesn't belong to us...
                    // Note: This may be legitimate in a clustered MHS or if in- and out-bound
                    // nodes are separate.
                    //
                    EventLog logger = new EventLog("Application");
                    logger.Source = LOGSOURCE;
                    StringBuilder sbe = new StringBuilder("Unexpected response ");
                    sbe.Append(s.SoapAction);
                    sbe.Append(" with conversation id ");
                    sbe.Append(m.Header.ConversationId);
                    sbe.Append(" that was not sent from here.");
                    logger.WriteEntry(sbe.ToString(), EventLogEntryType.Information);
                }

                depersist(m.Header.ConversationId);
                return;
            }
            ISpineHandler h = null;

            try
            {
                h = handlers[s.SoapAction];
            }
            catch (KeyNotFoundException)
            {
                EventLog logger = new EventLog("Application");
                logger.Source = LOGSOURCE;
                StringBuilder sbe = new StringBuilder("Unknown SOAP action ");
                sbe.Append(s.SoapAction);
                sbe.Append(" using DefaultFileSaveSpineHandler");
                logger.WriteEntry(sbe.ToString(), EventLogEntryType.FailureAudit);
                h = defaultSpineHandler;
            }
            try
            {
                h.handle(s);
            }
            catch (Exception e)
            {
                EventLog logger = new EventLog("Application");
                logger.Source = LOGSOURCE;
                StringBuilder sbe = new StringBuilder("Exception handling  ");
                sbe.Append(s.SoapAction);
                sbe.Append(" : ");
                sbe.Append(e.ToString());
                logger.WriteEntry(sbe.ToString(), EventLogEntryType.FailureAudit);
            }
        }
コード例 #2
0
 /**
  * Registers a handler for a received Spine message, agains the SOAPaction under which it is
  * delivered.
  */
 public void addHandler(string s, ISpineHandler h)
 {
     handlers.Add(s, h);
 }
コード例 #3
0
 /**
  * Registers a handler for a received Spine message, agains the SOAPaction under which it is
  * delivered.
  */
 public void addHandler(string s, ISpineHandler h)
 {
     handlers.Add(s, h);
 }
コード例 #4
0
        /**
         * Singleton constructor.
         */
        private ConnectionManager()
        {
            getPasswordProvider();
            requests            = new Dictionary <string, Sendable>();
            expiryHandlers      = new Dictionary <string, IExpiredMessageHandler>();
            handlers            = new Dictionary <string, ISpineHandler>();
            synchronousHandlers = new Dictionary <string, ISynchronousResponseHandler>();
            itkTrunkHandler     = new ITKTrunkHandler();
            handlers.Add("urn:nhs:names:services:itk/COPC_IN000001GB01", itkTrunkHandler);
            handlers.Add("\"urn:nhs:names:services:itk/COPC_IN000001GB01\"", itkTrunkHandler);
            loadCertificate();
            messageDirectory = (string)Registry.GetValue(CONNECTION_MANAGER_REGSITRY_KEY, MESSAGE_DIRECTORY_REGVAL, "");
            if (messageDirectory.Length == 0)
            {
                EventLog logger = new EventLog("Application");
                logger.Source = LOGSOURCE;
                logger.WriteEntry("No message directory provided - only in-memory persistence available", EventLogEntryType.Warning);
            }
            // Make sure messageDirectory is terminated with a path delimiter, because we're going
            // to need to add message ids to it when we call depersist() to delete persisted messages
            // on expiry or explicit transmission result.
            //
            if (!messageDirectory.EndsWith("\\"))
            {
                messageDirectory = messageDirectory + "\\";
            }

            myIp = (string)Registry.GetValue(CONNECTION_MANAGER_REGSITRY_KEY, MY_IP_REGVAL, "");
            if (myIp.Length == 0)
            {
                myIp = null;
                EventLog logger = new EventLog("Application");
                logger.Source = LOGSOURCE;
                logger.WriteEntry("No local IP address provided - will use first non-localhost interface", EventLogEntryType.Warning);
            }
            expiredDirectory = (string)Registry.GetValue(CONNECTION_MANAGER_REGSITRY_KEY, EXPIRED_DIRECTORY_REGVAL, "");
            if (expiredDirectory.Length == 0)
            {
                EventLog logger = new EventLog("Application");
                logger.Source = LOGSOURCE;
                logger.WriteEntry("No expired message directory provided - administrative handling of unsent messages NOT available", EventLogEntryType.Warning);
            }
            sdsConnection = new SDSconnection();
            try
            {
                retryCheckPeriod = Int64.Parse((string)Registry.GetValue(CONNECTION_MANAGER_REGSITRY_KEY, RETRY_TIMER_PERIOD_REGVAL, ""));
            }
            catch { }

            string nulldefault = (string)Registry.GetValue(CONNECTION_MANAGER_REGSITRY_KEY, USE_NULL_DEFAULT_SYNCHRONOUS_HANDLER_REGVAL, "");

            if (nulldefault.ToLower().StartsWith("y"))
            {
                defaultSynchronousResponseHandler = new NullSynchronousResponseHandler();
            }
            else
            {
                defaultSynchronousResponseHandler = new DefaultFileSaveSynchronousResponseHandler();
            }
            defaultSpineHandler = new DefaultFileSaveSpineHandler();

            persistDurations = loadReceivedPersistDurations();
            if (retryCheckPeriod != 0)
            {
                retryProcessorTimer = new Timer(processRetries, null, retryCheckPeriod, retryCheckPeriod);
            }
        }
コード例 #5
0
        /**
         * Singleton constructor.
         */
        private ConnectionManager()
        {
            getPasswordProvider();
            requests = new Dictionary<string, Sendable>();
            expiryHandlers = new Dictionary<string, IExpiredMessageHandler>();
            handlers = new Dictionary<string, ISpineHandler>();
            synchronousHandlers = new Dictionary<string, ISynchronousResponseHandler>();
            itkTrunkHandler = new ITKTrunkHandler();
            handlers.Add("urn:nhs:names:services:itk/COPC_IN000001GB01", itkTrunkHandler);
            handlers.Add("\"urn:nhs:names:services:itk/COPC_IN000001GB01\"", itkTrunkHandler);
            loadCertificate();
            messageDirectory = (string)Registry.GetValue(CONNECTION_MANAGER_REGSITRY_KEY, MESSAGE_DIRECTORY_REGVAL, "");
            if (messageDirectory.Length == 0)
            {
                EventLog logger = new EventLog("Application");
                logger.Source = LOGSOURCE;
                logger.WriteEntry("No message directory provided - only in-memory persistence available", EventLogEntryType.Warning);
            }
            // Make sure messageDirectory is terminated with a path delimiter, because we're going
            // to need to add message ids to it when we call depersist() to delete persisted messages
            // on expiry or explicit transmission result.
            //
            if (!messageDirectory.EndsWith("\\"))
                messageDirectory = messageDirectory + "\\";

            myIp = (string)Registry.GetValue(CONNECTION_MANAGER_REGSITRY_KEY, MY_IP_REGVAL, "");
            if (myIp.Length == 0)
            {
                myIp = null;
                EventLog logger = new EventLog("Application");
                logger.Source = LOGSOURCE;
                logger.WriteEntry("No local IP address provided - will use first non-localhost interface", EventLogEntryType.Warning);
            }
            expiredDirectory = (string)Registry.GetValue(CONNECTION_MANAGER_REGSITRY_KEY, EXPIRED_DIRECTORY_REGVAL, "");
            if (expiredDirectory.Length == 0)
            {
                EventLog logger = new EventLog("Application");
                logger.Source = LOGSOURCE;
                logger.WriteEntry("No expired message directory provided - administrative handling of unsent messages NOT available", EventLogEntryType.Warning);
            }
            sdsConnection = new SDSconnection();
            try
            {
                retryCheckPeriod = Int64.Parse((string)Registry.GetValue(CONNECTION_MANAGER_REGSITRY_KEY, RETRY_TIMER_PERIOD_REGVAL, ""));
            }
            catch { }

            string nulldefault = (string)Registry.GetValue(CONNECTION_MANAGER_REGSITRY_KEY, USE_NULL_DEFAULT_SYNCHRONOUS_HANDLER_REGVAL, "");
            if (nulldefault.ToLower().StartsWith("y"))
                defaultSynchronousResponseHandler = new NullSynchronousResponseHandler();
            else
                defaultSynchronousResponseHandler = new DefaultFileSaveSynchronousResponseHandler();
            defaultSpineHandler = new DefaultFileSaveSpineHandler();

            persistDurations = loadReceivedPersistDurations();
            if (retryCheckPeriod != 0)
                retryProcessorTimer = new Timer(processRetries, null, retryCheckPeriod, retryCheckPeriod);
        }