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); }
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); }