Bootstrap FreeKB - WebMethods - Get Brokers in Java
WebMethods - Get Brokers in Java

Updated:   |  WebMethods articles

This assumes you are able to connect to WebMethods Broker Server in Java.

Here is an example class that can be used to list the Brokers on the Broker server on server1.example.com.

import COM.activesw.api.client.*;

public class Main {
	public static void main(String[] args) {
		try {				
			BrokerServerClient server_client = new BrokerServerClient("server1.example.com", null);
			System.out.println("server_client = " + server_client);

			String name = server_client.getDefaultBrokerName();
			System.out.println("default broker name = " + name);

			BrokerInfo brokers[] = server_client.getBrokers();

			System.out.println("brokers:");
				
			for (int i = 0;  i < brokers.length;  i++) {  
				System.out.println(brokers[i].broker_name+"\n");  
			}

		} catch (BrokerException ex) {
			System.out.println("Caught the following exception: " + ex);
		}
	}	
}

 

If the request is successful, something like this should be returned.

BrokerServerClient:
  broker_host=server1.example.com
  broker_port=6849

default broker name = Broker #1

brokers:
  Broker #1
  Broker #2
  Broker #3

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter 8dfa7d in the box below so that we can be sure you are a human.