public void ResourceUnknownTest()
        {
            int actualTerminationTime   = 10;
            SubscriptionHandler Handler = new SubscriptionHandler(this, true);

            Handler.SetPolicy(new EventsVerifyPolicy(true));
            bool Unsubscribed = false;

            RunTest(
                () =>
            {
                Handler.SetAddress(GetEventServiceAddress());
                Handler.Subscribe(null, actualTerminationTime);
                SubscriptionHandler.Unsubscribe(Handler);
                Unsubscribed = true;

                TestErrorStep(() =>
                {
                    Unsubscribe request = new Unsubscribe();
                    Handler.GetProxy().Unsubscribe(request);
                },
                              ValidateUnsubscribeFault);
            },
                () =>
            {
                if (!Unsubscribed)
                {
                    SubscriptionHandler.Unsubscribe(Handler);
                }
            });
        }
예제 #2
0
        /// <summary>
        /// Releases subscription manager (via unsubscribe or via timeout)
        /// </summary>
        protected void ReleaseSubscriptionManager(int timeout)
        {
            System.Diagnostics.Debug.WriteLine("EventTest.Release() ");
            BeginStep("Delete Subscription Manager");
            bool unsubscribeByRequest = false;

            try
            {
                if (_subscriptionManagerClient != null)
                {
                    LogStepEvent("Send unsubscribe request");
                    Unsubscribe request = new Unsubscribe();
                    _subscriptionManagerClient.Unsubscribe(request);
                    unsubscribeByRequest = true;
                }
                else
                {
                    LogStepEvent("Reference to Subscription Manager has not been obtained");
                }
            }
            catch (Exception exc)
            {
                LogStepEvent(string.Format("Failed to unsubscribe through request. Error received: {0}", exc.Message));
            }

            if (!unsubscribeByRequest)
            {
                LogStepEvent("Wait until Subscription Manager is deleted by timeout");
                Sleep(timeout);
            }
            StepPassed();
        }
예제 #3
0
        /// <summary>
        /// Sends un-subscription request to Market Data Server
        /// </summary>
        /// <param name="security">Contains symbol information</param>
        /// <param name="providerName">Name of the provider on which to unsubscribe</param>
        public void Unsubscribe(Security security, string providerName)
        {
            // Create unsubscription message
            Unsubscribe unsubscribe = SubscriptionMessage.TickUnsubscription("", security, providerName);

            _marketDataService.Unsubscribe(unsubscribe);
        }
예제 #4
0
        private void HandleUnsubscribe(Unsubscribe x)
        {
            unsuscribed++;
            if (_subscribers.ContainsKey(x.Id))
            {
                _subscribers.Remove(x.Id);
            }

            if (_scores.ContainsKey(x.Avatar))
            {
                _scores.Remove(x.Avatar);
            }
            if (_avatars.ContainsKey(x.Id))
            {
                _avatars.Remove(x.Id);
            }

            Broadcast(x);

            if (unsuscribed == 2)
            {
                start = true;
            }
            else
            {
                start = false;
            }

            StartOrWait();
        }
예제 #5
0
 /// <summary>
 /// Unsubscribe Market data message
 /// </summary>
 public bool UnsubscribeTickData(Unsubscribe request)
 {
     try
     {
         if (IsConnected())
         {
             Session.SendToTarget(
                 MarketDataRequest(request.Id, request.Security, SubscriptionType.UnsubscribeSnapshotUpdate, 1),
                 this._quoteSessionId);
             if (Logger.IsDebugEnabled)
             {
                 Logger.Debug("Successful - " + request, _type.FullName, "UnsubscribeTickData");
             }
             return(true);
         }
         else
         {
             if (Logger.IsDebugEnabled)
             {
                 Logger.Debug("Failed - " + request, _type.FullName, "UnsubscribeTickData");
             }
             return(false);
         }
     }
     catch (Exception exception)
     {
         Logger.Error(exception.ToString(), _type.FullName, "UnsubscribeTickData");
     }
     return(false);
 }
예제 #6
0
        internal void GivenMultipleSubscribeAndUnsubscribe_HandlesCorrectly()
        {
            // Arrange
            var receiver2 = new MockComponent(this.container, "2");

            var subscribe1 = new Subscribe <Type>(
                typeof(Tick),
                this.receiver.Mailbox,
                Guid.NewGuid(),
                StubZonedDateTime.UnixEpoch());

            var subscribe2 = new Subscribe <Type>(
                typeof(Tick),
                receiver2.Mailbox,
                Guid.NewGuid(),
                StubZonedDateTime.UnixEpoch());

            var unsubscribe = new Unsubscribe <Type>(
                typeof(Tick),
                receiver2.Mailbox,
                Guid.NewGuid(),
                StubZonedDateTime.UnixEpoch());

            // Act
            this.dataBus.Endpoint.SendAsync(subscribe1).Wait();
            this.dataBus.Endpoint.SendAsync(subscribe2).Wait();
            this.dataBus.Endpoint.SendAsync(unsubscribe).Wait();
            this.dataBus.Stop().Wait();

            // Assert
            Assert.Equal(1, this.dataBus.Subscriptions.Count);
        }
예제 #7
0
        private void OnMessage(Unsubscribe <Type> message)
        {
            var type = message.Subscription;

            if (type == this.BusType)
            {
                this.Unsubscribe(message, this.subscriptionsAll);
                return;
            }

            if (!type.IsSubclassOf(this.BusType))
            {
                this.Logger.LogError(
                    LogId.Component,
                    $"Cannot unsubscribe from {type.Name} type messages " +
                    $"(only all {this.BusType.Name} or type of {this.BusType.Name} messages).");
                return;
            }

            this.Unsubscribe(message, this.subscriptions[type]);

            if (this.subscriptions[type].Count == 0)
            {
                // No longer subscribers for this type
                this.subscriptions.Remove(type);
            }
        }
예제 #8
0
        /// <summary>
        /// Sends TradeHub Unsubscribe Message to MQ Exchange on the depending routing key
        /// </summary>
        /// <param name="unsubscribe">TradeHub Unsubscribe Message</param>
        /// <param name="appId">Application ID to uniquely identify the running instance</param>
        public void SendTickUnsubscriptionMessage(Unsubscribe unsubscribe, string appId)
        {
            try
            {
                if (Logger.IsDebugEnabled)
                {
                    Logger.Debug("Unsubscribe message recieved for publishing", _type.FullName, "SendTickUnsubscriptionMessage");
                }

                string routingKey;
                if (_mdeMqServerparameters.TryGetValue(MdeMqServerParameterNames.SubscribeRoutingKey, out routingKey))
                {
                    Message <Unsubscribe> unsubscribeMessage = new Message <Unsubscribe>(unsubscribe);
                    unsubscribeMessage.Properties.AppId = appId;

                    // Send Message for publishing
                    PublishMessages(unsubscribeMessage, routingKey);
                }
                else
                {
                    Logger.Info("Unsubscribe message not sent for publishing as routing key is unavailable.", _type.FullName,
                                "SendTickUnsubscriptionMessage");
                }
            }
            catch (Exception exception)
            {
                Logger.Error(exception, _type.FullName, "SendTickUnsubscriptionMessage");
            }
        }
        public void Unsubscribe(String[] topics)
        {
            Unsubscribe uunsubscribe = new Unsubscribe(null, topics);

            _timers.Store(uunsubscribe);
            _client.Send(uunsubscribe);
        }
        /// <summary>
        /// Unsubscribe Market Data
        /// </summary>
        public bool UnsubscribeTickData(Unsubscribe request)
        {
            try
            {
                BWStock bwStock = _session.GetStock(request.Security.Symbol);

                //bwStock.OnLevel1Update2 -= OnLevelOneUpdate;
                bwStock.OnLevel1Update3 -= OnLevelOneUpdate;
                //bwStock.OnTrade2 -= OnTradeUpdate;
                bwStock.OnTrade3 -= OnTradeUpdate;
                bwStock.Unsubscribe();

                if (Logger.IsInfoEnabled)
                {
                    Logger.Info("Unsubscribing market data request for: " + request.Security.Symbol, _type.FullName,
                                "UnsubscribeTickData");
                }

                return(true);
            }
            catch (Exception exception)
            {
                Logger.Error(exception, _type.FullName, "UnsubscribeTickData");
                return(false);
            }
        }
예제 #11
0
        public async Task ExecuteAsync(string clientId, IPacket input, IMqttChannel <IPacket> channel)
        {
            if (input.Type != MqttPacketType.Unsubscribe)
            {
                return;
            }

            Unsubscribe   unsubscribe = input as Unsubscribe;
            ClientSession session     = _sessionRepository.Read(clientId);

            if (session == null)
            {
                throw new MqttException(ServerProperties.SessionRepository_ClientSessionNotFound(clientId));
            }

            foreach (string topic in unsubscribe.Topics)
            {
                ClientSubscription subscription = session.GetSubscriptions().FirstOrDefault(s => s.TopicFilter == topic);

                if (subscription != null)
                {
                    session.RemoveSubscription(subscription);
                }
            }

            _sessionRepository.Update(session);

            await channel.SendAsync(new UnsubscribeAck( unsubscribe.PacketId ));
        }
        public UnsubscribeResponse Unsubscribe([System.Xml.Serialization.XmlElementAttribute("Unsubscribe", Namespace = "http://docs.oasis-open.org/wsn/b-2")] Unsubscribe Unsubscribe1)
        {
            if (Application["consumer"] == null)
            {
                SoapFaultSubCode subCode =
                    new SoapFaultSubCode(new XmlQualifiedName("ResourseUnknown", "http://www.onvif.org/ver10/error"));

                SoapException exception = new SoapException("Invalid Argument",
                                                            new XmlQualifiedName("Sender",
                                                                                 "http://www.w3.org/2003/05/soap-envelope"),
                                                            subCode);
                throw exception;
            }

            Application["consumer"] = null;

            UnsubscribeResponse response = new UnsubscribeResponse();

            if (actionHeader == null)
            {
                actionHeader = new ActionHeader();
            }
            actionHeader.Value = "http://docs.oasis-open.org/wsn/bw-2/SubscriptionManager/UnsubscribeResponse";


            return(response);
        }
예제 #13
0
        public void UnsubscribeTest()
        {
            EndpointReferenceType subscriptionReference = null;
            bool unsubscribed = true;

            RunTest <object>(
                new Backup <object>(
                    () =>
            {
                return(null);
            }),
                () =>
            {
                EnsureNotificationProducerClientCreated();

                SubscribeResponse subscribeResponse = CreateStandardSubscription();
                unsubscribed = false;

                if (subscribeResponse == null)
                {
                    return;
                }

                subscriptionReference = subscribeResponse.SubscriptionReference;

                Unsubscribe request = new Unsubscribe();

                UnsubscribeResponse unsubscribeResponse = Unsubscribe(request);

                unsubscribed = true;

                Renew renew           = new Renew();
                renew.TerminationTime = "PT10S";

                RunStep(
                    () =>
                {
                    _subscriptionManagerClient.Renew(renew);
                    unsubscribed = false;
                },
                    "Renew - negative test",
                    new ValidateTypeFault(ValidateResourseUnknownFault));
            },
                (o) =>
            {
                if (!unsubscribed)
                {
                    if (subscriptionReference != null)
                    {
                        CreateSubscriptionManagerClient(subscriptionReference);
                    }
                    //
                    // Use default timeout of 10 seconds.
                    // Really timeout passed in Subscribe request may be different.
                    //
                    ReleaseSubscriptionManager();
                }
            });
        }
예제 #14
0
        public void TestBuildUnsubscribe()
        {
            var unsub = new Unsubscribe {
                Node = "princely_musings", Jid = "*****@*****.**", SubId = "abcd"
            };

            unsub.ShouldBe(Resource.Get("Xmpp.PubSub.unsubscribe1.xml"));
        }
 /// <summary>
 /// Overriden to provides additional funtionality for base class function 'Stop()'
 /// </summary>
 protected override void OnStop()
 {
     foreach (var subscribe in _subscriptionList)
     {
         Unsubscribe unsubscribe = SubscriptionMessage.TickUnsubscription(_idGenerator.NextTickId(), subscribe.Security, subscribe.MarketDataProvider);
         Unsubscribe(unsubscribe);
     }
 }
예제 #16
0
 private Proto.Msg.Unsubscribe UnsubscribeToProto(Unsubscribe unsubscribe)
 {
     return(new Proto.Msg.Unsubscribe
     {
         Key = this.OtherMessageToProto(unsubscribe.Key),
         Ref = Akka.Serialization.Serialization.SerializedActorPath(unsubscribe.Subscriber)
     });
 }
예제 #17
0
        private void HandleUnsubscribe(Unsubscribe x)
        {
            PictureBox avatar = (PictureBox)Program.myForm.Controls.Find(key: x.Avatar, searchAllChildren: false).FirstOrDefault();

            Program.myForm.Controls.Remove(avatar);
            Label lbl = (Label)Program.myForm.Controls.Find(key: $"Lbl{x.Avatar}", searchAllChildren: false).FirstOrDefault();

            Program.myForm.Controls.Remove(lbl);
        }
예제 #18
0
        private async Task UnsubscribeTable(Table table)
        {
            var msg = new Unsubscribe
            {
                tab_id = table,
            };

            await base.SendRequestAsync(new FTEMessage(MsgType.REQ_UNSUBSCRIBE, msg));
        }
예제 #19
0
 private void Handle(Unsubscribe unsubscribe)
 {
     _logger.LogInformation("Unsubscribing {Projection}", unsubscribe.Projection);
     _handlers.Remove(unsubscribe.Projection);
     if (_handlers.Count == 0)
     {
         _lastProcessedMessagePosition = null;
     }
 }
예제 #20
0
        public async Task UnsubscribeAsync(params string[] topics)
        {
            if (disposed)
            {
                throw new ObjectDisposedException(GetType().FullName);
            }

            try {
                topics = topics ?? new string[] { };

                var packetId    = packetIdProvider.GetPacketId();
                var unsubscribe = new Unsubscribe(packetId, topics);

                var ack = default(UnsubscribeAck);
                var unsubscribeTimeout = TimeSpan.FromSeconds(configuration.WaitTimeoutSecs);

                await SendPacketAsync(unsubscribe)
                .ConfigureAwait(continueOnCapturedContext: false);

                ack = await packetListener
                      .PacketStream
                      .ObserveOn(NewThreadScheduler.Default)
                      .OfType <UnsubscribeAck> ()
                      .FirstOrDefaultAsync(x => x.PacketId == packetId)
                      .Timeout(unsubscribeTimeout);

                if (ack == null)
                {
                    var message = string.Format(Properties.Resources.Client_UnsubscribeDisconnected, Id, string.Join(", ", topics));

                    tracer.Error(message);

                    throw new MqttClientException(message);
                }
            } catch (TimeoutException timeEx) {
                Close(timeEx);

                var message = string.Format(Properties.Resources.Client_UnsubscribeTimeout, Id, string.Join(", ", topics));

                tracer.Error(message);

                throw new MqttClientException(message, timeEx);
            } catch (MqttClientException clientEx) {
                Close(clientEx);
                throw;
            } catch (Exception ex) {
                Close(ex);

                var message = string.Format(Properties.Resources.Client_UnsubscribeError, Id, string.Join(", ", topics));

                tracer.Error(message);

                throw new MqttClientException(message, ex);
            }
        }
예제 #21
0
 private void btnUnsubscribe_Click(object sender, EventArgs e)
 {
     SafeInvoke(() =>
     {
         _host.Close();
         Unsubscribe request = new Unsubscribe();
         _subscriptionManager.Unsubscribe(request);
         tcSubscription.SelectedTab = tbSubscribe;
         StopTimer();
     });
 }
예제 #22
0
        /// <inheritdoc />
        public void Unsubscribe <T>(Mailbox subscriber, Guid id, ZonedDateTime timestamp)
        {
            var subscription = typeof(T);
            var message      = new Unsubscribe <Type>(
                subscription,
                subscriber,
                id,
                timestamp);

            this.Send(subscription, message);
        }
예제 #23
0
        public void OnLoaded()
        {
            //绑定实时参数
            var onlineCpmsDict = App.Store.GetState().CpmState.OnlineCpmsDict;

            CpmsTab.BindSource(MachineCode, onlineCpmsDict[MachineCode]);

            //绑定报警
            var alarmsDict = App.Store.GetState().AlarmState.AlarmsDict;

            AlarmTab.BindSource(MachineCode, alarmsDict[MachineCode]);

            //绑定任务
            var mqTaskDict = App.Store.GetState().DMesState.MqSchTasksDict;

            SchTaskTab.BindSource(MachineCode, mqTaskDict[MachineCode]);

            //初始化人员卡
            var mqEmpRfids = App.Store.GetState().DMesState.MqEmpRfidDict;

            SchTaskTab.InitEmployees(mqEmpRfids[MachineCode]);

            //初始化来料
            var scanMaterialDict = App.Store.GetState().DMesState.MqScanMaterialDict;

            if (scanMaterialDict.TryGetValue(MachineCode, out var material))
            {
                ScanMaterialTab.Update(material);
            }
            //绑定485通讯状态
            var com485Dict = App.Store.GetState().CpmState.Com485StatusDict;
            var status     = com485Dict.Where(c => MachineConfig.MachineCodeToIpsDict[MachineCode].Contains(c.Key))
                             .Select(c => c.Value).ToList();

            Com485Tab.BindSource(MachineCode, status);

            //回填参数
            //var dpms = App.Store.GetState().DpmStore.DpmsDict;
            //DpmsTab.BindSource(dpms[MachineCode]);

            //绑定制程质检
            unsubscribe += ProcessCheckTab.BindSource(MachineCode);

            ////绑定曲线参数界面
            CpmDetailTab.BindSource(MachineCode, onlineCpmsDict[MachineCode]);



            //绑定选中的tab
            ViewStore = App.Store.GetState().ViewStoreState.DMewCoreViewDict[MachineCode];

            unsubscribe += App.Store.Subscribe(actionExecDict, false);
            App.Store.Dispatch(new SysActions.CloseLoadingSplash());
        }
        public UnsubscribeResponse Unsubscribe([System.Xml.Serialization.XmlElementAttribute("Unsubscribe", Namespace = "http://docs.oasis-open.org/wsn/b-2")] Unsubscribe Unsubscribe1)
        {
            SoapHeaderProcessing(unknownHeaders);

            ParametersValidation validation = new ParametersValidation();
            UnsubscribeResponse  result     = (UnsubscribeResponse)ExecuteGetCommand(validation, PullPointSubscriptionServiceTest.UnsubscribeTest);

            actionHeader.actionValue = "http://docs.oasis-open.org/wsn/bw-2/SubscriptionManager/UnsubscribeResponse";

            return(result);
        }
        /// <summary>
        /// Manages incoming unsubcription request for the subscribed Tick Data
        /// </summary>
        /// <param name="unsubscribe">Contains info for the Tick data to be unsubscribed</param>
        public void UnsubscribeTickData(Unsubscribe unsubscribe)
        {
            if (_asyncClassLogger.IsDebugEnabled)
            {
                _asyncClassLogger.Debug(
                    "Tick un-subscription request received for: " + unsubscribe.Security.Symbol,
                    _type.FullName, "UnsubscribeTickData");
            }

            _dataHandler.UnsubscribleSymbol(unsubscribe);
        }
예제 #26
0
        public void when_writing_invalid_unsubscribe_packet_then_fails(string jsonPath)
        {
            jsonPath = Path.Combine(Environment.CurrentDirectory, jsonPath);

            UnsubscribeFormatter formatter   = new UnsubscribeFormatter();
            Unsubscribe          unsubscribe = Packet.ReadPacket <Unsubscribe>(jsonPath);

            AggregateException ex = Assert.Throws <AggregateException>(() => formatter.FormatAsync(unsubscribe).Wait());

            Assert.True(ex.InnerException is MqttProtocolViolationException);
        }
예제 #27
0
        /// <inheritdoc />
        public void Unsubscribe <T>(
            Mailbox subscriber,
            Guid id,
            ZonedDateTime timestamp)
            where T : Message
        {
            var type    = typeof(T);
            var message = new Unsubscribe <Type>(type, subscriber, id, timestamp);

            this.SendToBus(type, message);
        }
예제 #28
0
        /// <summary>
        /// Creates Tick unsubscription message
        /// </summary>
        /// <param name="id">Unique ID which was used for subscription</param>
        /// <param name="security">TradeHub Security containing info regarding the symbol</param>
        /// <param name="marketDataProvider">Name of market data provider to be used</param>
        /// <returns>TradeHub Unsubscribe object</returns>
        public static Unsubscribe TickUnsubscription(string id, Security security, string marketDataProvider)
        {
            // Create new tick unsubscription object
            Unsubscribe unsubscribe = new Unsubscribe
            {
                Id                 = id,
                Security           = security,
                MarketDataProvider = marketDataProvider
            };

            return(unsubscribe);
        }
        private static Unsubscribe getUnsubscribeMessage(NetMessage message)
        {
            NetUnsubscribe netUnsub = message.Action.UnsbuscribeMessage;

            Unsubscribe unsubscribe = new Unsubscribe();

            unsubscribe.Action_id        = netUnsub.ActionId;
            unsubscribe.Destination      = netUnsub.Destination;
            unsubscribe.Destination_type = translate(netUnsub.DestinationType);

            return(unsubscribe);
        }
예제 #30
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        /// <remarks>As this method uses SubscriptionManager client, care should be taken that client is created.
        /// It's not posisble to create it here since Subscribe method should be called first to get endpoint address.</remarks>
        protected UnsubscribeResponse Unsubscribe(Unsubscribe request)
        {
            UnsubscribeResponse response = null;

            RunStep(() =>
            {
                response = _subscriptionManagerClient.Unsubscribe(request);
            }, "Send unsubscribe request");


            return(response);
        }
 public void DistributedPubSubMediator_must_receive_proper_UnsubscribeAck_message()
 {
     Within(TimeSpan.FromSeconds(15), () =>
     {
         RunOn(() =>
         {
             var user = CreateChatUser("u111");
             var topic = "sample-topic-14";
             var s1 = new Subscribe(topic, user);
             Mediator.Tell(s1);
             ExpectMsg<SubscribeAck>(x => x.Subscribe.Equals(s1));
             var uns = new Unsubscribe(topic, user);
             Mediator.Tell(uns);
             ExpectMsg<UnsubscribeAck>(x => x.Unsubscribe.Equals(uns));
         }, _first);
         EnterBarrier("after-15");
     });
 }