Exemple #1
0
        public Task SetValueAsync(object value, CancellationToken cancellationToken)
        {
            BrokeredMessage message = _converter.Convert((TInput)value);

            Debug.Assert(message != null);
            return(_entity.SendAndCreateEntityIfNotExistsAsync(message, _functionInstanceId, cancellationToken));
        }
Exemple #2
0
            /// <summary>
            /// Sends a BrokeredMessage to the bound queue.
            /// </summary>
            /// <param name="value">BrokeredMessage instance as retrieved from user's WebJobs method argument.</param>
            /// <param name="cancellationToken">a cancellation token</param>
            /// <remarks>
            /// The out message parameter is processed as follows:
            /// <list type="bullet">
            /// <item>
            /// <description>
            /// If the value is <see langword="null"/>, no message will be sent.
            /// </description>
            /// </item>
            /// <item>
            /// <description>
            /// If the value has empty content, a message with empty content will be sent.
            /// </description>
            /// </item>
            /// <item>
            /// <description>
            /// If the value has non-empty content, a message with that content will be sent.
            /// </description>
            /// </item>
            /// </list>
            /// </remarks>
            public async Task SetValueAsync(object value, CancellationToken cancellationToken)
            {
                if (value == null)
                {
                    return;
                }

                BrokeredMessage message = (BrokeredMessage)value;

                await _entity.SendAndCreateEntityIfNotExistsAsync(message, _functionInstanceId, cancellationToken);
            }
Exemple #3
0
            /// <summary>
            /// Sends a Message to the bound queue.
            /// </summary>
            /// <param name="value">BrokeredMessage instance as retrieved from user's WebJobs method argument.</param>
            /// <param name="cancellationToken">a cancellation token</param>
            /// <remarks>
            /// The out message parameter is processed as follows:
            /// <list type="bullet">
            /// <item>
            /// <description>
            /// If the value is <see langword="null"/>, no message will be sent.
            /// </description>
            /// </item>
            /// <item>
            /// <description>
            /// If the value has empty content, a message with empty content will be sent.
            /// </description>
            /// </item>
            /// <item>
            /// <description>
            /// If the value has non-empty content, a message with that content will be sent.
            /// </description>
            /// </item>
            /// </list>
            /// </remarks>
            public async Task SetValueAsync(object value, CancellationToken cancellationToken)
            {
                if (value == null)
                {
                    return;
                }

                var message = (Message)value;

                await _entity.SendAndCreateEntityIfNotExistsAsync(message, _functionInstanceId, cancellationToken).ConfigureAwait(false);
            }
        public Task AddAsync(T item, CancellationToken cancellationToken)
        {
            ServiceBusMessage message = _converter.Convert(item);

            if (message == null)
            {
                throw new InvalidOperationException("Cannot enqueue a null brokered message instance.");
            }

            return(_entity.SendAndCreateEntityIfNotExistsAsync(message, _functionInstanceId, cancellationToken));
        }
Exemple #5
0
        public void Add(T item)
        {
            Message message = _converter.Convert(item);

            if (message == null)
            {
                throw new InvalidOperationException("Cannot enqueue a null brokered message instance.");
            }

            _entity.SendAndCreateEntityIfNotExistsAsync(message, _functionInstanceId,
                                                        CancellationToken.None).GetAwaiter().GetResult();
        }
        public void Add(T item)
        {
            ServiceBusMessage message = _converter.Convert(item);

            if (message == null)
            {
                throw new InvalidOperationException("Cannot enqueue a null brokered message instance.");
            }
#pragma warning disable AZC0106
            _entity.SendAndCreateEntityIfNotExistsAsync(message, _functionInstanceId,
                                                        CancellationToken.None).EnsureCompleted();
#pragma warning restore AZC0106
        }
        public void Add(T item)
        {
            ServiceBusMessage message = _converter.Convert(item);

            if (message == null)
            {
                throw new InvalidOperationException("Cannot enqueue a null message instance.");
            }
            _entity.SendAndCreateEntityIfNotExistsAsync(message, _functionInstanceId, CancellationToken.None)
#pragma warning disable AZC0102 // Do not use GetAwaiter().GetResult(). There are no synchronous methods in SB SDK, so we have to do sync over async to support this.
            .GetAwaiter().GetResult();
#pragma warning restore AZC0102 // Do not use GetAwaiter().GetResult().
        }
        public Task SetValueAsync(object value, CancellationToken cancellationToken)
        {
            if (value == null)
            {
                return(Task.FromResult(0));
            }

            Debug.Assert(value is TInput);
            ServiceBusMessage message = _converter.Convert((TInput)value);

            Debug.Assert(message != null);

            return(_entity.SendAndCreateEntityIfNotExistsAsync(message, _functionInstanceId, cancellationToken));
        }