我无法让几个经纪人相互沟通。其他一切都按预期工作(包括生产者和消费者之间的沟通)。但是如何使用多播来管理那个Broker与对方的谈话呢?
任何建议都将受到高度赞赏
这是我的环境:
这些是经纪人设置
private String brokerUri;
private String brokerName;
private String brokerProtokol = "tcp://";;
private int brokerPort = 9999;
private String networkConName = "Network";
private String transportConName = "Transport";
private BrokerService broker;
brokerUri = Inet4Address.getLocalHost().getHostAddress();
brokerName = Inet4Address.getLocalHost().getHostName();
这是剪切的代码,可能不正确:
public void createBroker() throws UnknownHostException, InterruptedException{
try {
broker = new BrokerService();
TransportConnector transportCon = new TransportConnector();
NetworkConnector networkCon = new NetworkConnector(new URI("multicast://default")) {
};
broker.setBrokerName(brokerName);
transportCon.setUri(new URI(brokerProtokol+brokerUri+":"+brokerPort));
transportCon.setName(transportConName);
transportCon.setDiscoveryUri(new URI("multicast://default"));
final SystemUsage systemUsage = broker.getSystemUsage();
systemUsage.getMemoryUsage().setLimit(1024 * 1024 * 2); // 2 MB
systemUsage.getTempUsage().setLimit(1024L * 1024 * 1024 * 2); // 2 GB
systemUsage.getStoreUsage().setLimit(1024L * 1024 * 1024 * 2); // 2 GB
broker.setPersistent(true);
networkCon.setDuplex(true);
// broker.setUseJmx(true);
broker.addConnector(transportCon);
broker.addNetworkConnector(networkCon);
broker.start();