public static void RetornaDados(NotificacaoEnvio notificacao) { Console.WriteLine("CdPessoa: {0}", notificacao.CdPessoa); Console.WriteLine("Mensagem: {0}", notificacao.Mensagem); Console.WriteLine("PlayerId: {0}", notificacao.PushNotificationDados.PlayerIds); Console.WriteLine("CdPessoa: {0}", notificacao.TipoComunicacao); }
public static void Main() { var factory = new ConnectionFactory() { HostName = "localhost" }; using (var connection = factory.CreateConnection()) using (var channel = connection.CreateModel()) { channel.QueueDeclare(queue: "ituranDigital_Json", durable: false, exclusive: false, autoDelete: false, arguments: null); var consumer = new EventingBasicConsumer(channel); consumer.Received += (model, ea) => { var body = ea.Body; var message = Encoding.UTF8.GetString(body); NotificacaoEnvio deserializedProduct = JsonConvert.DeserializeObject <NotificacaoEnvio>(message); RetornaDados(deserializedProduct); Console.WriteLine(" [x] Received {0}", message); }; channel.BasicConsume(queue: "ituranDigital_Json", autoAck: true, consumer: consumer); Console.WriteLine(" Press [enter] to exit."); Console.ReadLine(); } }