Example #1
0
        private static void ServiceBusEnviarMsg()
        {
            var fila = QueueClient.CreateFromConnectionString(cCon, NomeFila);

            Assinantes assistente = new Assinantes()
            {
                DataAssinatura = new DateTime(2016, 01, 12),
                Descricao      = "Assinatura Futebol",
                Nome           = "HENRIQUE SOUZA"
            };

            BrokeredMessage bkm = new BrokeredMessage(assistente);

            bkm.MessageId = Guid.NewGuid().ToString();

            try
            {
                fila.Send(bkm);
            }
            catch (MessagingException ex)
            {
                if (!ex.IsTransient)
                {
                    Console.WriteLine(ex.Message);
                }
            }
            finally
            {
                fila.Close();
            }
        }
Example #2
0
        private static void SBPublicarTopicoSANTOS()
        {
            var topico = TopicClient.CreateFromConnectionString(cCon, NomeTopico);
            var ass    = new Assinantes {
                DataAssinatura = DateTime.Now,
                Descricao      = "TORCEDOR SANTOS",
                Nome           = "HENRIQUE SOUZA",
                Time           = "SANTOS"
            };

            using (var message = new BrokeredMessage(ass))
            {
                message.MessageId = Guid.NewGuid().ToString();
                message.Properties.Add("TIME", ass.Time);
                topico.Send(message);
            }
        }