Una de las hermosas características de ActiveMQ es los brokers embebidos. Con ello podemos gozar de las ventajas de tener en la misma máquina virtual el consumidor, productor y el broker, haciendo que el flujo de mensajes sean más rápidos. Es demasiado simple ponerlo a funcionar, (ya hemos visto como agregar el API que se necesita). Y ahora sí, a codear.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.chapter7.amq;
import org.apache.activemq.broker.BrokerService;
/**
*
* @author lyonn
*/
public class AMQBroker {
private static final String bname="myBroker";
private static final String bdata="/opt/brokers/instance1/example/data";
public static void main(String[] args) throws Exception {
BrokerService broker = new BrokerService();
broker.setBrokerName(bname);
broker.setDataDirectory(bdata);
broker.addConnector("tcp://localhost:6080");
broker.start();
System.out.println("For stop the service, press any key: ");
System.in.read();
}
}
Comentarios
Publicar un comentario