コード例 #1
0
        static async Task SendMessagesAsync(int numberOfMessagesToSend)
        {
            try
            {
                for (var i = 0; i < numberOfMessagesToSend; i++)
                {
                    // Create a new message to send to the queue
                    string messageBody = $"Message {i}";

                    /* ORIGINAL EXAMPLE
                     * var message = new Message(Encoding.UTF8.GetBytes(messageBody));
                     *
                     * // Write the body of the message to the console
                     * Console.WriteLine($"Sending message: {messageBody}");
                     *
                     * // Send the message to the queue
                     * await queueClient.SendAsync(message);
                     */
                    // USING SBCOMPRESSOR
                    var settings = new SBCompressor.Configuration.StorageSettingData(
                        "DefaultEndpointsProtocol=https;AccountName=stsbcompressordevweu001;AccountKey=***REMOVED***;EndpointSuffix=core.windows.net",
                        "sbcompressorcontainer", SBCompressor.VeryLargeMessageStrategy.Storage);
                    await queueClient.SendCompressorAsync(messageBody, settings);
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine($"{DateTime.Now} :: Exception: {exception.Message}");
            }
        }
コード例 #2
0
        static async Task SendMessageWithOjbet()
        {
            var settings = new SBCompressor.Configuration.StorageSettingData(
                "DefaultEndpointsProtocol=https;AccountName=stsbcompressordevweu001;AccountKey=***REMOVED***;EndpointSuffix=core.windows.net",
                "sbcompressorcontainer", SBCompressor.VeryLargeMessageStrategy.Storage);

            //sent object instead of string
            DTOLibrary.MessageDTO messageDTO = new DTOLibrary.MessageDTO();
            messageDTO.Subject = "Hello";
            messageDTO.Content = "I'm a object";
            await queueClient.SendCompressorAsync(messageDTO, settings);
        }