public IMessageConsumer CreateDurableConsumer( ITopic destination, string name, string selector, bool noLocal) { ConsumerInfo command = CreateConsumerInfo(destination, selector); ConsumerId consumerId = command.ConsumerId; command.SubscriptionName = name; command.NoLocal = noLocal; try { MessageConsumer consumer = new MessageConsumer(this, command, acknowledgementMode); // lets register the consumer first in case we start dispatching messages immediately connection.AddConsumer(consumerId, consumer); connection.SyncRequest(command); consumers[consumerId] = consumer; return(consumer); } catch (Exception e) { connection.RemoveConsumer(consumerId); throw e; } }
/// <summary> /// Handle incoming commands /// </summary> /// <param name="transport">An ITransport</param> /// <param name="command">A Command</param> protected void OnCommand(ITransport transport, Command command) { if (command is MessageDispatch) { MessageDispatch dispatch = (MessageDispatch)command; ConsumerId consumerId = dispatch.ConsumerId; MessageConsumer consumer = (MessageConsumer)consumers[consumerId]; if (consumer == null) { Tracer.Error("No such consumer active: " + consumerId); } else { ActiveMQMessage message = (ActiveMQMessage)dispatch.Message; consumer.Dispatch(message); } } else if (command is WireFormatInfo) { this.brokerWireFormatInfo = (WireFormatInfo)command; } else if (command is BrokerInfo) { this.brokerInfo = (BrokerInfo)command; } else if (command is ShutdownInfo) { //ShutdownInfo info = (ShutdownInfo)command; if (!closing && !closed) { OnException(transport, new NMSException("Broker closed this connection.")); } } else { Tracer.Error("Unknown command: " + command); } }
public MessageConsumerSynchronization(MessageConsumer consumer, Message message) { this.message = message; this.consumer = consumer; }
public IMessageConsumer CreateDurableConsumer( ITopic destination, string name, string selector, bool noLocal) { ConsumerInfo command = CreateConsumerInfo(destination, selector); ConsumerId consumerId = command.ConsumerId; command.SubscriptionName = name; command.NoLocal = noLocal; try { MessageConsumer consumer = new MessageConsumer(this, command, acknowledgementMode); // lets register the consumer first in case we start dispatching messages immediately connection.AddConsumer(consumerId, consumer); connection.SyncRequest(command); consumers[consumerId] = consumer; return consumer; } catch (Exception e) { connection.RemoveConsumer(consumerId); throw e; } }
/// <summary> /// Register a new consumer /// </summary> /// <param name="consumerId">A ConsumerId</param> /// <param name="consumer">A MessageConsumer</param> public void AddConsumer(ConsumerId consumerId, MessageConsumer consumer) { consumers[consumerId] = consumer; }