public virtual Subscription GetSubscription(NotificationHandler notificationHandler) { Subscription subs = new Subscription(this.SubscriptionName, notificationHandler.ActionType); subs.OnMessage += notificationHandler.OnMessageHandler; return subs; }
public virtual void AddPreRequisites() { PreRequisite preReq = new PreRequisite("Subscription"); preReq.Runnable = () => { foreach (TestClientInfo tci in this.ConsumersInfo) { int expectedMessages = 0; if (this.SubscribeDestinationType != NetAction.DestinationType.TOPIC) { if ((ProducersInfo.Count % ConsumersInfo.Count) != 0) throw new Exception(String.Format("When not using TOPIC subscriptions, publishers ({0}) must be multiple of consumers ({1}).", ProducersInfo.Count, ConsumersInfo.Count)); expectedMessages = ProducersInfo.Count / ConsumersInfo.Count; Console.WriteLine("In here.."); } else { expectedMessages = ProducersInfo.Count; } Console.WriteLine("expectedMessages: {0}", expectedMessages); NotificationHandler notificationHandler = new NotificationHandler(tci.brokerClient, this.SubscribeDestinationType, expectedMessages); tci.notificationHandler = notificationHandler; tci.brokerClient.Subscribe(GetSubscription(notificationHandler)); } preReq.Sucess = true; preReq.Done = true; Thread.Sleep(1000);// giving time to subscribe. Not critical, so there's no need for something more sophisticated. }; this.AddPrequisite(preReq); }