activemq的高级特性之嵌入式activemq
1:编写activeMQ服务
import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.jmx.ManagementContext; /** * 编写activemq的服务 */ public class EmbedMQ { public static void main(String[] args) throws Exception { BrokerService brokerService = new BrokerService(); brokerService.setBrokerName("EmbedMQ"); brokerService.addConnector("tcp://localhost:62000"); brokerService.setManagementContext(new ManagementContext()); brokerService.start(); } }
2:编写发送端和消费端
参考代码:https://www.cnblogs.com/orange-time/p/10608766.html
只修改连接:
private static final String BROKEURL = "tcp://localhost:62000"; //地址端口号可以自己定义
注:这种方式有很多功能不支持,可以应急一下。