Пример #1
0
        private void OnUnprovision(string msg, string reply, string subject)
        {
            Logger.Debug(Strings.UnprovisionRequestDebugLogMessage, ServiceDescription(), msg);

            SimpleResponse response = new SimpleResponse();

            UnprovisionRequest unprovision_req = new UnprovisionRequest();

            unprovision_req.FromJsonIntermediateObject(JsonConvertibleObject.DeserializeFromJson(msg));
            string name = unprovision_req.Name;

            // Create a service credentials object with a name set, so we can run this operation in parallel for different service instances.
            ServiceCredentials credentials = new ServiceCredentials();

            credentials.Name = name;

            credentials.ServiceWorkFactory.StartNew(
                () =>
            {
                try
                {
                    ServiceCredentials[] bindings = unprovision_req.Bindings;

                    bool result = this.Unprovision(name, bindings);

                    if (result)
                    {
                        this.NodeNats.Publish(reply, null, EncodeSuccess(response));
                    }
                    else
                    {
                        this.NodeNats.Publish(reply, null, EncodeFailure(response));
                    }
                }
                catch (Exception ex)
                {
                    Logger.Warning(ex.ToString());
                    NodeNats.Publish(reply, null, EncodeFailure(response, ex));
                }
            });
        }
Пример #2
0
        private void OnUnprovision(string msg, string reply, string subject)
        {
            Logger.Debug(Strings.UnprovisionRequestDebugLogMessage, ServiceDescription(), msg);

            SimpleResponse response = new SimpleResponse();

            UnprovisionRequest unprovision_req = new UnprovisionRequest();
            unprovision_req.FromJsonIntermediateObject(JsonConvertibleObject.DeserializeFromJson(msg));
            string name = unprovision_req.Name;

            // Create a service credentials object with a name set, so we can run this operation in parallel for different service instances.
            ServiceCredentials credentials = new ServiceCredentials();
            credentials.Name = name;

            credentials.ServiceWorkFactory.StartNew(
                () =>
                {
                    try
                    {
                        ServiceCredentials[] bindings = unprovision_req.Bindings;

                        bool result = this.Unprovision(name, bindings);

                        if (result)
                        {
                            this.nodeNats.Publish(reply, null, EncodeSuccess(response));
                            this.capacity += CapacityUnit();
                        }
                        else
                        {
                            this.nodeNats.Publish(reply, null, EncodeFailure(response));
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Warning(ex.ToString());
                        nodeNats.Publish(reply, null, EncodeFailure(response, ex));
                    }
                });
        }