io.zbus.mq.MqAdmin Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zbus Show documentation
Show all versions of zbus Show documentation
a lightweight yet powerful MQ and RPC to build service bus
package io.zbus.mq;
import java.io.IOException;
import io.zbus.mq.Broker.ServerSelector;
import io.zbus.mq.Protocol.ConsumeGroupInfo;
import io.zbus.mq.Protocol.TopicInfo;
import io.zbus.transport.ServerAddress;
public class MqAdmin {
protected final Broker broker;
protected ServerSelector adminServerSelector;
protected String token;
protected long invokeTimeout = 10000; // 10 s
protected boolean verbose = false;
public MqAdmin(MqConfig config){
this.broker = config.getBroker();
this.token = config.getToken();
this.invokeTimeout = config.getInvokeTimeout();
this.adminServerSelector = config.getAdminServerSelector();
this.verbose = config.isVerbose();
if(this.adminServerSelector == null){
this.adminServerSelector = new DefaultAdminSelector();
}
}
protected MqClient configClient(MqClient client){
client.setToken(token);
client.setInvokeTimeout(invokeTimeout);
return client;
}
public TopicInfo[] queryTopic(String topic) throws IOException, InterruptedException {
Message msg = new Message();
msg.setTopic(topic);
MqClientPool[] pools = broker.selectClient(this.adminServerSelector, msg);
TopicInfo[] res = new TopicInfo[pools.length];
for(int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy