public static IQueueBroadcaster Define(INodeContext C, Type MessageType, QueueConnector Connector) { var typedef = typeof(QueueBroadcaster <>).GetGenericTypeDefinition(); var type = typedef.MakeGenericType(MessageType); var broadcaster = Activator.CreateInstance(type, new object[] { C, Connector }); return(broadcaster as IQueueBroadcaster); }
public QueueReceiver(INodeContext C, QueueConnector Connector) : base(C) { Connection = new QueueConnection(Connector); Consumer = new EventingBasicConsumer(Channel); Consumer.Received += (channel, e) => OnMessage(e); Channel.BasicConsume (queue: Connector.QueueName, autoAck: Connector.Settings.AutoAck, consumer: Consumer ); }
public QueueConnection(QueueConnector Connector) { CF = new ConnectionFactory { HostName = Connector.HostName }; Connection = CF.CreateConnection(); Channel = Connection.CreateModel(); QueueDeclaration = Channel.QueueDeclare ( queue: Connector.QueueName, durable: false, exclusive: false, autoDelete: false ); this.Connector = Connector; }
IQueueReceiver Receiver(Type MessageType) => Receivers.GetOrAdd( QueueConnector.Define(C.Host, MessageType), connector => QueueReceiver.Define(C, MessageType, connector));
IQueueReceiver Receiver <M>() where M : new() => Receivers.GetOrAdd( QueueConnector.Define <M>(C.Host), connector => QueueReceiver.Define <M>(C, connector));
IQueueBroadcaster Broadcaster <M>() where M : new() => Broadcasters.GetOrAdd( QueueConnector.Define <M>(C.Host), connector => QueueBroadcaster.Define <M>(C, connector));
IQueueBroadcaster Broadcaster(Type MessageType) => Broadcasters.GetOrAdd( QueueConnector.Define(C.Host, MessageType), connector => QueueBroadcaster.Define(C, MessageType, connector));
public static IQueueBroadcaster Define <M>(INodeContext C, QueueConnector Connector) where M : new() => new QueueBroadcaster <M>(C, Connector);
public QueueBroadcaster(INodeContext C, QueueConnector Connector) : base(C) { Connection = new QueueConnection(Connector); }