Beispiel #1
0
        /// <summary>
        /// This event will be called each time a message arrives.
        /// </summary>
        /// <param name="message">Brokered Message</param>
        /// <param name="cancel">Cancellation Token</param>
        /// <returns>Task</returns>
        public virtual async Task OnMessageArrived(Message message, CancellationToken cancel)
        {
            var queued = new Queued <T>(message);
            var data   = await queued.Data();

            await this.Process(data);
        }
        public async Task OnMessageArrived()
        {
            var data = Guid.NewGuid().ToString();
            var msg  = new BrokeredMessage(data)
            {
                ContentType = data.GetType().ToString(),
            };

            var queue  = new Queued <string>(msg);
            var result = await queue.Data();

            Assert.AreEqual(result, data);
        }
        public async Task OnMessageArrived()
        {
            var data = Guid.NewGuid().ToString();
            var msg = new BrokeredMessage(data)
            {
                ContentType = data.GetType().ToString(),
            };

            var queue = new Queued<string>(msg);
            var result = await queue.Data();

            Assert.AreEqual(result, data);
        }
        public async Task OnMessageArrived()
        {
            var data  = Guid.NewGuid().ToString();
            var bytes = System.Text.Encoding.ASCII.GetBytes(data);
            var msg   = new Message(bytes)
            {
                ContentType = data.GetType().ToString(),
            };

            var queue  = new Queued <string>(msg);
            var result = await queue.Data();

            Assert.AreEqual(result, data);
        }
        public async Task OnMessageArrivedBinary()
        {
            var data = Guid.NewGuid();
            var msg  = new Message(data.ToByteArray())
            {
                ContentType = data.GetType().ToString(),
            };

            msg.UserProperties.Add(BusQueueClient.EncodingKey, Encoding.Binary);

            var queue  = new Queued <Guid>(msg);
            var result = await queue.Data();

            Assert.AreEqual(result, data);
        }
Beispiel #6
0
        public async Task OnMessageArrived()
        {
            var formatter = new BinaryFormatter();

            using (var stream = new MemoryStream())
            {
                var data = Guid.NewGuid();
                formatter.Serialize(stream, data);
                var msg = new Message(stream.ToArray());

                var queue  = new Queued <Guid>(msg);
                var result = await queue.Data();

                Assert.AreEqual(result, data);
            }
        }
        public async Task OnMessageArrivedJson()
        {
            var data = Guid.NewGuid();
            var json = JsonConvert.SerializeObject(data);
            var msg  = new BrokeredMessage(json)
            {
                ContentType = data.GetType().ToString(),
            };

            msg.Properties.Add(BusQueueClient.EncodingKey, Encoding.Json);

            var queue  = new Queued <Guid>(msg);
            var result = await queue.Data();

            Assert.AreEqual(result, data);
        }
Beispiel #8
0
        public async Task OnMessageArrivedBinary()
        {
            var formatter = new BinaryFormatter();

            using (var stream = new MemoryStream())
            {
                var data = Guid.NewGuid();
                formatter.Serialize(stream, data);
                var msg = new Message(stream.ToArray())
                {
                    ContentType = data.GetType().ToString(),
                };
                msg.UserProperties.Add(BusQueueClient.EncodingKey, Encoding.Binary);

                var queue  = new Queued <Guid>(msg);
                var result = await queue.Data();

                Assert.AreEqual(result, data);
            }
        }