示例#1
0
        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);
        }
示例#2
0
        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
                );
        }
示例#3
0
        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;
        }
示例#4
0
 IQueueReceiver Receiver(Type MessageType)
 => Receivers.GetOrAdd(
     QueueConnector.Define(C.Host, MessageType),
     connector => QueueReceiver.Define(C, MessageType, connector));
示例#5
0
 IQueueReceiver Receiver <M>()
     where M : new()
 => Receivers.GetOrAdd(
     QueueConnector.Define <M>(C.Host),
     connector => QueueReceiver.Define <M>(C, connector));
示例#6
0
 IQueueBroadcaster Broadcaster <M>()
     where M : new()
 => Broadcasters.GetOrAdd(
     QueueConnector.Define <M>(C.Host),
     connector => QueueBroadcaster.Define <M>(C, connector));
示例#7
0
 IQueueBroadcaster Broadcaster(Type MessageType)
 => Broadcasters.GetOrAdd(
     QueueConnector.Define(C.Host, MessageType),
     connector => QueueBroadcaster.Define(C, MessageType, connector));
示例#8
0
 public static IQueueBroadcaster Define <M>(INodeContext C, QueueConnector Connector)
     where M : new() => new QueueBroadcaster <M>(C, Connector);
示例#9
0
 public QueueBroadcaster(INodeContext C, QueueConnector Connector)
     : base(C)
 {
     Connection = new QueueConnection(Connector);
 }