public void CreateMessageSender_ReturnsExpectedSender()
        {
            string defaultConnection = "Endpoint=sb://default.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=abc123=";
            var    config            = new ServiceBusConfiguration
            {
                ConnectionString = defaultConnection
            };
            var provider = new MessagingProvider(config);
            var sender   = provider.CreateMessageSender("entityPath", defaultConnection);

            Assert.Equal("entityPath", sender.Path);

            var sender2 = provider.CreateMessageSender("entityPath", defaultConnection);

            Assert.Same(sender, sender2);
        }
Example #2
0
        public Task <ServiceBusEntity> ConvertAsync(string input, CancellationToken cancellationToken)
        {
            string queueOrTopicName;

            // For convenience, treat an an empty string as a request for the default value.
            if (string.IsNullOrEmpty(input) && _defaultPath.IsBound)
            {
                queueOrTopicName = _defaultPath.Bind(null);
            }
            else
            {
                queueOrTopicName = input;
            }

            cancellationToken.ThrowIfCancellationRequested();
            var messageSender = _messagingProvider.CreateMessageSender(_clientFactory.CreateClientFromSetting(_attribute.Connection), queueOrTopicName);

            var entity = new ServiceBusEntity
            {
                MessageSender = messageSender,
                EntityType    = _entityType
            };

            return(Task.FromResult(entity));
        }
        public async Task <IValueProvider> BindAsync(BindingContext context)
        {
            context.CancellationToken.ThrowIfCancellationRequested();

            string boundQueueName = _path.Bind(context.BindingData);
            var    messageSender  = _messagingProvider.CreateMessageSender(_clientFactory.CreateClientFromSetting(_attribute.Connection), boundQueueName);

            var entity = new ServiceBusEntity
            {
                MessageSender = messageSender,
                EntityType    = _attribute.EntityType
            };

            return(await BindAsync(entity, context.ValueContext).ConfigureAwait(false));
        }
        public async Task <IValueProvider> BindAsync(BindingContext context)
        {
            context.CancellationToken.ThrowIfCancellationRequested();

            string boundQueueName = _path.Bind(context.BindingData);
            var    messageSender  = _messagingProvider.CreateMessageSender(boundQueueName, _account.ConnectionString);

            var entity = new ServiceBusEntity
            {
                MessageSender = messageSender,
                EntityType    = _entityType
            };

            return(await BindAsync(entity, context.ValueContext).ConfigureAwait(false));
        }