Example #1
0
        public bool Subscribe()
        {
            this._eventingBasicConsumer.Received += (o, msg) =>
            {
                try
                {
                    EventMessage eventMessage = MessageEncodingHelper.GetMessage(msg);
                    this._cacheLogger.LogAsync($"Incoming message in RMQ BackPlane Subscription Channel with CorrelationId = {eventMessage.CorrelationId} ", EventLevel.Verbose);

                    OnMessage(eventMessage, new Dictionary <string, string>()
                    {
                        { nameof(BackPlaneChannelType), BackPlaneChannelType.RabbitMq.ToString() }
                    });
                }
                catch (Exception ex)
                {
                    this._cacheLogger.LogException(ex);
                }
                this._subscriptionClient.BasicAck(msg.DeliveryTag, false);
            };


            this._subscriptionClient.QueueBind(queue: this._cacheConfig.ListenerInstanceId, exchange: this._cacheConfig.CacheBackPlaneChannel, routingKey: "fanout");
            this._subscriptionClient.BasicConsume(this._cacheConfig.ListenerInstanceId, false, this._eventingBasicConsumer);

            return(true);
        }