package br.com.caelum.jms;
import javax.jms.*;
import javax.naming.InitialContext;
import java.util.Scanner;
public class TesteConsumidor {
public static void main(String[] args) throws Exception{
InitialContext context = new InitialContext();
//imports do package javax.jms
// Pega a conexão do contexto: lookup
ConnectionFactory factory = (ConnectionFactory) context.lookup("ConnectionFactory");
Connection connection = factory.createConnection();
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination fila = (Destination) context.lookup("financeiro");
MessageConsumer consumer = session.createConsumer(fila);
Message message = consumer.receive();
System.out.println("Recebendo msg: "+ message);
new Scanner(System.in).nextLine(); //parar o programa para testar a conexao
session.close();
connection.close();
context.close();
}
}