コード例 #1
0
 public RabbitConsumer(IMessageBus messageBus, IConsumerBuildStrategy buildStrategy, RabbitConsumerOptions queue, ISubscriptionResult rabbitToken)
 {
     MessageBus    = messageBus;
     BuildStrategy = buildStrategy;
     Queue         = queue;
     RabbitToken   = rabbitToken;
 }
コード例 #2
0
        public ISubscriptionResult SubscribeConsumer(IMessageBus messageBus, RabbitConsumerOptions options)
        {
            string subscriberId = RabbitUtility.CreateSubscriberId();
            var    rabbitToken  = _bus.Subscribe <TRemote>(subscriberId, remote =>
            {
                var remoteTopic = _getTopic?.Invoke(remote) ?? options.RemoteTopic;
                var localTopic  = options.MakeLocalTopic(remoteTopic);
                var envelope    = _transform(remote, remoteTopic).RedirectToTopic(localTopic);

                if (options.RemoteOnly && envelope.OriginBusId == messageBus.Id)
                {
                    return;
                }
                messageBus.PublishEnvelope(envelope);
            }, options.ConfigureSubscription);

            return(rabbitToken);
        }
コード例 #3
0
        public ISubscriptionResult SubscribeConsumer(IMessageBus messageBus, RabbitConsumerOptions options)
        {
            string subscriberId = RabbitUtility.CreateSubscriberId();
            var    rabbitToken  = _bus.Subscribe <RabbitEnvelope <TPayload> >(subscriberId, remote =>
            {
                var remoteTopic = options.RemoteTopic;
                var localTopic  = options.MakeLocalTopic(remoteTopic);
                var envelope    = messageBus.EnvelopeFactory
                                  .CreateFromRemote(remote.OriginBusId, new[] { localTopic }, remote.Payload, remote.Metadata);

                if (options.RemoteOnly && envelope.OriginBusId == messageBus.Id)
                {
                    return;
                }
                messageBus.PublishEnvelope(envelope);
            }, options.ConfigureSubscription);

            return(rabbitToken);
        }
コード例 #4
0
 public ISubscriptionResult ResubscribeConsumer(IMessageBus messageBus, RabbitConsumerOptions options)
 {
     return(SubscribeConsumer(messageBus, options));
 }