All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.zbus.mq.MqAdmin Maven / Gradle / Ivy

There is a newer version: 1.0.0-b1
Show newest version
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