Ejemplo n.º 1
0
        /// <summary>
        /// new
        /// </summary>
        /// <param name="queueName"></param>
        /// <param name="config"></param>
        /// <param name="callback"></param>
        public Consumer(string queueName, Config.RabbitMQ config,
                        Action <Messaging.Message> callback)
        {
            if (string.IsNullOrEmpty(queueName))
            {
                throw new ArgumentNullException("queueName");
            }
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }

            this.QueueName = queueName;
            this._callback = callback;
            this.Exchange  = config.Exchange;

            this._factory = new ConnectionFactory
            {
                HostName           = config.Host,
                Port               = config.Port,
                UserName           = config.UserName,
                Password           = config.Password,
                VirtualHost        = config.VHost,
                RequestedHeartbeat = 10,
            };

            this._server = GenServer.Start(this);
            this._server.Call(new ListenMessage());
        }
Ejemplo n.º 2
0
            /// <summary>
            /// new
            /// </summary>
            /// <param name="publisher"></param>
            /// <param name="exchange"></param>
            public Worker(Publisher publisher, string exchange)
            {
                if (publisher == null)
                {
                    throw new ArgumentNullException("publisher");
                }
                if (string.IsNullOrEmpty(exchange))
                {
                    throw new ArgumentNullException("exchange");
                }

                this._publisher = publisher;
                this._exchange  = exchange;
                this._server    = GenServer.Start(this);
            }
Ejemplo n.º 3
0
        /// <summary>
        /// new
        /// </summary>
        /// <param name="config"></param>
        public Publisher(Config.RabbitMQ config)
        {
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            this._factory = new ConnectionFactory
            {
                HostName    = config.Host,
                Port        = config.Port,
                UserName    = config.UserName,
                Password    = config.Password,
                VirtualHost = config.VHost
            };
            this._arrWorkers = Enumerable.Range(0, 4).Select(_ => new Worker(this, config.Exchange)).ToArray();
            this._server     = GenServer.Start(this);
        }
Ejemplo n.º 4
0
 public Worker()
 {
     this._server = GenServer.Start(this);
 }