Não sei porque razão mesmo fazendo a configuração no activemq.xml e definindo as prioridades conforme o vídeo. O consumo não são relacionados na ordem da prioridade configurada no JMS e não consigo entender o porque?
public class ProdutorFilaLOG {
public static void main(String[] args) throws Exception {
InitialContext context = new InitialContext();
ConnectionFactory factory = (ConnectionFactory)context.lookup("ConnectionFactory");
Connection connection = factory.createConnection();
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = (Destination) context.lookup("LOG");
MessageProducer producer = session.createProducer(destination);
Message message = session.createTextMessage("ERROR | ActiveMQ");
producer.send(message,DeliveryMode.NON_PERSISTENT,9,100000);
session.close();
connection.close();
context.close();
}
}
@SuppressWarnings("resource")
public static void main(String[] args) throws Exception {
InitialContext context = new InitialContext();
ConnectionFactory factory = (ConnectionFactory)context.lookup("ConnectionFactory");
Connection connection = factory.createConnection();
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = (Destination)context.lookup("LOG");
MessageConsumer consumer = session.createConsumer(destination);
consumer.setMessageListener(new MessageListener() {
@Override
public void onMessage(Message message) {
try {
TextMessage textMessage = (TextMessage)message;
System.out.println(textMessage.getText());
} catch (JMSException e) {
e.printStackTrace();
}
}
});
new Scanner(System.in).nextInt();
connection.close();
context.close();
}