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

            Debug.Assert(message != null);
            return(_entity.SendAndCreateQueueIfNotExistsAsync(message, _functionInstanceId, cancellationToken));
        }
        public Task AddAsync(T item, CancellationToken cancellationToken)
        {
            BrokeredMessage message = _converter.Convert(item);

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

            return(_entity.SendAndCreateQueueIfNotExistsAsync(message, _functionInstanceId, cancellationToken));
        }
            /// <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.SendAndCreateQueueIfNotExistsAsync(message, _functionInstanceId, cancellationToken);
            }
        public void Add(T item)
        {
            BrokeredMessage message = _converter.Convert(item);

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

            _entity.SendAndCreateQueueIfNotExistsAsync(message, _functionInstanceId,
                                                       CancellationToken.None).GetAwaiter().GetResult();
        }