/// <summary>
        /// Sends a collection of messages inside a batch transaction
        /// </summary>
        /// <param name="messages"></param>
        public void SendBatch(IEnumerable <Envelope <Stream> > messages)
        {
            List <BrokeredMessage> msg = new List <BrokeredMessage>();

            foreach (var message in messages)
            {
                msg.Add(AzureServiceBusMessageConverter.ConstructMessage(message));
            }

            _client.SendBatch(msg);
        }
Пример #2
0
        /// <summary>
        /// Called by the message receiver to start processing a message
        /// </summary>
        /// <param name="message"></param>
        private Task ProcessReceivedMessage(BrokeredMessage message)
        {
            Envelope <Stream> envelope = AzureServiceBusMessageConverter.ConstructEnvelope(message);
            Task messageProcess        = Task.Run(() =>
            {
                MessageReleaseAction releaseResult = InvokeMessageHandler(envelope);

                CompleteMessage(message, releaseResult);
            });

            return(messageProcess);
        }
        /// <summary>
        /// Called by the message receiver to start processing a message
        /// </summary>
        /// <param name="message"></param>
        private Task ProcessReceivedMessage(BrokeredMessage message)
        {
            Task messageProcess = Task.Run(() =>
            {
                Envelope <Stream> env = AzureServiceBusMessageConverter.ConstructEnvelope(message);

                MessageReleaseAction releaseResult = InvokeMessageHandler(env);

                CompleteMessage(message, releaseResult);
            });

            // http://stackoverflow.com/questions/30467896/brokeredmessage-automatically-disposed-after-calling-onmessage
            // "...The received message needs to be processed in the callback function's life time..."

            _cache.AddTask(messageProcess);

            return(messageProcess);
        }
 /// <summary>
 /// Sends a message using the metadata in the envelope if applicable
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="message"></param>
 public void Send(Envelope <Stream> message)
 {
     _client.Send(AzureServiceBusMessageConverter.ConstructMessage(message));
 }