internal RabbitMQTransport(string baseQueueName, IConfigurationContext configuration)
        {
            this.configuration = MergeConfiguration(configuration);

            // Cache encoding name as looking it from the Encoding class is expensive.
            this.encodingName = new Lazy<string>(() => configuration.Serializer.Encoding.EncodingName);

            this.connectionManager = new RabbitConnectionManager(new Uri(configuration.GetConnectionString()));
            this.primaryQueueName = baseQueueName;
            this.delayQueueName = String.Format("{0}_Delay", this.primaryQueueName);
            this.errorQueueName = String.Format("{0}_Error", this.primaryQueueName);

            this.DeclareExchange();

            this.sendChannel = new ThreadLocal<IModel>(() => this.connectionManager.GetChannel(), true);
        }
Beispiel #2
0
        internal RabbitMQTransport(string baseQueueName, IConfigurationContext configuration)
        {
            this.configuration = MergeConfiguration(configuration);

            // Cache encoding name as looking it from the Encoding class is expensive.
            this.encodingName = new Lazy <string>(() => configuration.Serializer.Encoding.EncodingName);

            this.connectionManager = new RabbitConnectionManager(new Uri(configuration.GetConnectionString()));
            this.primaryQueueName  = baseQueueName;
            this.delayQueueName    = String.Format("{0}_Delay", this.primaryQueueName);
            this.errorQueueName    = String.Format("{0}_Error", this.primaryQueueName);

            using (var channel = this.connectionManager.GetChannel())
            {
                // Create exchange if it doesn't already exist
                channel.ExchangeDeclare(this.configuration.GetExchange(), "direct", true);
            }

            this.sendChannel = new ThreadLocal <IModel>(() => this.connectionManager.GetChannel(), true);
        }
        internal RabbitMQTransport(string baseQueueName, IConfigurationContext configuration)
        {
            this.configuration = MergeConfiguration(configuration);

            // Cache encoding name as looking it from the Encoding class is expensive.
            this.encodingName = new Lazy <string>(() => configuration.Serializer.Encoding.EncodingName);

            this.connectionManager = new RabbitConnectionManager(new Uri(configuration.GetConnectionString()));
            this.primaryQueueName  = baseQueueName;
            this.delayQueueName    = String.Format("{0}_Delay", this.primaryQueueName);
            this.errorQueueName    = String.Format("{0}_Error", this.primaryQueueName);

            this.DeclareExchange();

            this.sendChannel = new ThreadLocal <IModel>(valueFactory: CreateSendChannel);

            this.onSend = this.configuration.GetOnSendingMessageAction() ?? DoNothingOnSend;

            this.sendChannelMonitor = new Timer(
                MonitorSendChannels,
                state: null,
                dueTime: SendChannelMonitorInterval,
                period: SendChannelMonitorInterval);
        }