/// <summary> /// Register and Start TopicSubscriber /// </summary> /// <param name="brokerURL">ActiveMQ URL</param> /// <param name="destination">ActiveMQ Column Name</param> /// <param name="dele">delegate object</param> /// <returns>TopicSubscriber(Registered and Started )</returns> private TopicSubscriber RegisterTopicSubscriber(string brokerURL, string destination, MessageReceivedDelegate <string> dele) { TopicSubscriber subscriber = new TopicSubscriber(brokerURL, destination); subscriber.Start(); subscriber.OnMessageReceived += dele; return(subscriber); }
public void Subscribe(string topic, EventHandler <TopicArgs> handler) { TopicSubscriber topicSubscriber = new TopicSubscriber(topic, factory); topicSubscriber.Start(); topicSubscriber.TopicMessageEvent += msgParser => handler(msgParser.EndPoint, new TopicArgs(msgParser)); }
public void Subscribe <T>(string topic, Action <T> handler) { TopicSubscriber topicSubscriber = new TopicSubscriber(topic, factory); topicSubscriber.Start(); topicSubscriber.TopicMessageEvent += delegate(IMessageParser msgParser) { // msgsReceived.Add(msgParser.ParseObject()); }; }
public IDisposable Subscribe(string topicPattern, Action <string, object> messageConsumer) { var topicSubscriber = new TopicSubscriber(topicPattern, MessageParserFactory); topicSubscriber.TopicMessageEvent += messageParser => { object o = messageParser.ParseObject(); messageConsumer(messageParser.Topic, o); }; topicSubscriber.Start(); return(topicSubscriber); }
public void SetUp() { this.subscribers = new List <IMessageReceiver>(); // for (int i = 0; i < 4; i++) { TopicSubscriber subscriber = new TopicSubscriber(BROKER, TOPIC_NAME); // Add event subscriber.OnMessageReceived += ( message => log.Info(subscriber.ConsumerId + ": " + message) ); subscriber.ConsumerId = CONSUMER_ID + "#" + (i + 1); subscriber.Start(); // Add to Subscribers subscribers.Add(subscriber); } }
public void SetUp() { this.ctx = ContextRegistry.GetContext(); this.publisher = ctx["topicPublisher"] as IMessageSender; this.subscribers = new List <IMessageReceiver>(); // for (int i = 0; i < 4; i++) { TopicSubscriber subscriber = ctx["topicSubscriber"] as TopicSubscriber; subscriber.ConsumerId = subscriber.ConsumerId + (i + 1); // Add event subscriber.OnMessageReceived += ( message => log.Info(subscriber.ConsumerId + ": " + message) ); subscriber.Start(); log.Debug("Start topic subscriber with Consumer ID: [" + subscriber.ConsumerId + "]"); subscribers.Add(subscriber); } }