예제 #1
0
        public async Task ExecuteAsync(CancellationToken cancellationToken)
        {
            await using var handle = await _distributedLockProvider.AcquireLockAsync(nameof (CreateSubscriptions), _elsaOptions.DistributedLockTimeout, cancellationToken);

            if (handle == null)
            {
                throw new Exception("Could not acquire a lock within the maximum amount of time configured");
            }

            foreach (var messageType in _competingMessageTypes)
            {
                var bus = await _serviceBusFactory.GetServiceBusAsync(messageType.MessageType, messageType.QueueName, cancellationToken);

                await bus.Subscribe(messageType.MessageType);
            }

            var containerName = _containerNameAccessor.GetContainerName();

            foreach (var messageType in _pubSubMessageTypes)
            {
                var queueName = $"{containerName}:{messageType.QueueName ?? messageType.MessageType.Name}";
                var bus       = await _serviceBusFactory.GetServiceBusAsync(messageType.MessageType, queueName, cancellationToken);

                await bus.Subscribe(messageType.MessageType);
            }
        }
예제 #2
0
        public async Task ExecuteAsync(CancellationToken cancellationToken)
        {
            foreach (var messageType in _messageTypes)
            {
                var bus = await _serviceBusFactory.GetServiceBusAsync(messageType, cancellationToken);

                await bus.Subscribe(messageType);
            }
        }
예제 #3
0
        public async Task ExecuteAsync(CancellationToken cancellationToken)
        {
            foreach (var messageType in _competingMessageTypes)
            {
                var bus = await _serviceBusFactory.GetServiceBusAsync(messageType, cancellationToken);

                await bus.Subscribe(messageType);
            }

            var containerName = _containerNameAccessor.GetContainerName();

            foreach (var messageType in _pubSubMessageTypes)
            {
                var queueName = $"{containerName}:{messageType.Name}";
                var bus       = await _serviceBusFactory.GetServiceBusAsync(messageType, queueName, cancellationToken);

                await bus.Subscribe(messageType);
            }
        }
예제 #4
0
        public async Task PublishAsync(object message, IDictionary <string, string>?headers = default)
        {
            var bus = await _serviceBusFactory.GetServiceBusAsync(message.GetType(), default);

            await bus.Publish(message, headers);
        }
예제 #5
0
 private async Task <IBus> GetBusAsync(object message, string?queue, CancellationToken cancellationToken) => await _serviceBusFactory.GetServiceBusAsync(message.GetType(), queue, cancellationToken);