예제 #1
0
        protected override void OnApplicationDeleted(string appKey)
        {
            Debug.Print("ListenerAdapter[" + ProtocolName + "]::OnApplicationDeleted(" + appKey + ")");

            try
            {
                App app = null;
                lock (appManager)
                {
                    // CSDMain 190118
                    // In some cases WAS will send us duplicated notification for the deletion of a same appKey
                    if (!appManager.Apps.ContainsKey(appKey))
                    {
                        return;
                    }
                    app = appManager.Apps[appKey];
                }

                if (app.PendingAction != null)
                {
                    app.PendingAction.MergeFromDeletedAction();
                }
                else
                {
                    if (app.MessageQueue.HasStartedQueueInstances)
                    {
                        // Creae a new action
                        app.SetPendingAction(AppAction.CreateDeletedAction());
                        ScheduleClosingListenerChannelInstances(app);
                    }
                    else
                    {
                        CompleteDeleteApp(app);
                    }
                }
            }
            catch (Exception exception)
            {
                HandleUnknownError(exception);
            }
        }
예제 #2
0
        bool Cleanup(bool closeInstances)
        {
            Debug.Print("ListenerAdapter[" + ProtocolName + "]::Cleanup()");
            canDispatch = false;
            bool completeSelf = true;

            if (closeInstances)
            {
                List <App> existingApps    = new List <App>();
                List <App> removeApps      = new List <App>();
                List <App> delayRemoveApps = new List <App>();
                lock (appManager)
                {
                    if (appManager.AppsCount != 0)
                    {
                        // cleanup for activation service stop: tell WAS about it
                        existingApps.AddRange(appManager.Apps.Values);
                        foreach (App app in existingApps)
                        {
                            if (app.MessageQueue.HasStartedQueueInstances)
                            {
                                delayRemoveApps.Add(app);
                            }
                            else
                            {
                                removeApps.Add(app);
                            }
                        }

                        existingApps.Clear();
                    }
                }

                if (removeApps.Count != 0)
                {
                    foreach (App app in removeApps)
                    {
                        RemoveApp(app);
                    }
                }

                if (delayRemoveApps.Count != 0)
                {
                    foreach (App app in delayRemoveApps)
                    {
                        if (app.PendingAction != null)
                        {
                            app.PendingAction.MergeFromDeletedAction();
                        }
                        else
                        {
                            // Create a new action
                            app.SetPendingAction(AppAction.CreateDeletedAction());
                            CloseAllListenerChannelInstances(app);
                        }
                    }

                    completeSelf = false;
                }
            }
            else
            {
                lock (appManager)
                {
                    appManager.Clear();
                }
            }

            return(completeSelf);
        }