private void removeConsumer(String clientId) { NMSConsumer consumer = (NMSConsumer)_consumers[clientId]; consumer.stop(); consumer.MessageHandler -= onMessage; _consumers.Remove(clientId); log.Debug(string.Format("Removed Consumer for Client ID: {0}", clientId)); }
public override object Manage(CommandMessage commandMessage) { NMSConsumer _consumer; String subscriptionId = (String)commandMessage.clientId; String clientId = FluorineContext.Current.ClientId; object result = base.Manage(commandMessage); switch (commandMessage.operation) { case CommandMessage.SubscribeOperation: lock (SyncRoot) { if (_consumers.Contains(clientId)) { removeConsumer(clientId); } IMessageConsumer consumer = (commandMessage.HeaderExists(CommandMessage.SelectorHeader)) ? _session.CreateConsumer(_destination, (String)commandMessage.GetHeader(CommandMessage.SelectorHeader)) : _session.CreateConsumer(_destination); _consumer = new NMSConsumer(consumer, clientId, subscriptionId); _consumer.MessageHandler += onMessage; _consumers.Add(clientId, _consumer); log.Debug(string.Format("Created Consumer for Client ID: {0}", clientId)); } break; case CommandMessage.UnsubscribeOperation: lock (SyncRoot) { if (_consumers.Contains(clientId)) { removeConsumer(clientId); } } break; } return(result); }
public override object Manage(CommandMessage commandMessage) { NMSConsumer _consumer; String subscriptionId = (String)commandMessage.clientId; String clientId = FluorineContext.Current.ClientId; object result = base.Manage(commandMessage); switch (commandMessage.operation) { case CommandMessage.SubscribeOperation: lock (SyncRoot) { if (_consumers.Contains(clientId)) { removeConsumer(clientId); } IMessageConsumer consumer = (commandMessage.HeaderExists(CommandMessage.SelectorHeader)) ? _session.CreateConsumer(_destination, (String)commandMessage.GetHeader(CommandMessage.SelectorHeader)) : _session.CreateConsumer(_destination); _consumer = new NMSConsumer(consumer, clientId, subscriptionId); _consumer.MessageHandler += onMessage; _consumers.Add(clientId, _consumer); log.Debug(string.Format("Created Consumer for Client ID: {0}", clientId)); } break; case CommandMessage.UnsubscribeOperation: lock (SyncRoot) { if (_consumers.Contains(clientId)) { removeConsumer(clientId); } } break; } return result; }