Broker 10.5 | webMethods Broker Documentation | webMethods Broker Administration Java API Programmer’s Guide | Managing Broker Clients | Understanding BrokerAdminClients | Creating a BrokerAdminClient
 
Creating a BrokerAdminClient
Creating a BrokerAdminClient will establish a connection between your application and a Broker. This connection is identified by the following tuple (an ordered set of values):
*The name of the host where the Broker server is running.
*The IP port number assigned to the Broker's server.
*The name of the Broker.
Multiple Broker clients within a single application that connect to the same Broker will all share a single network connection.
Your application creates an administrative Broker client by using the BrokerAdminClient constructor and specifying these parameters:
*The name of the host where the Broker to which you want to connect is running.
*The name of the Broker to which you wish to connect. You may specify a null value if you want to connect to the default Broker. The default Broker for a particular host is determined by your webMethods Broker administrator. It can also be set or obtained using the BrokerServerClient class, described in Managing Brokers and Broker Servers. See Listing all Brokers on a Host for details on obtaining the names of Brokers available on a given host.
*A unique client ID that identifies your Broker client. You may specify a null value if you wish the Broker to generate a unique client ID for you. The client ID generated by the Broker can be obtained after this call completes by calling the BrokerClient.getClientId method.
*The client group for your new Broker client. Client groups define the event types your new Broker client will be able to publish or retrieve, as well as the life cycle and queue storage type for your Broker client. Client groups are defined by your webMethods Broker administrator. See Managing Client Groups for information on using the BrokerAdminClient class to administer client groups.
*The name of the application that is creating the Broker client. This name is used primarily by webMethods Broker administration and analysis tools. The application name can be any meaningful string of characters you choose.
*A BrokerConnectionDescriptor to be used for the new Broker client. If you specify a null value, a new connection descriptor will be created for you.
The following example illustrates how to create a new BrokerAdminClient object. In this example, a null Broker name is passed to indicate that the caller wishes to connect to the default Broker on the host "localhost". A null client ID is specified, indicating that the Broker should generate a unique client ID. A client group named "admin" is requested and the application name is set to "My Broker Monitor." A null connection descriptor is passed, indicating that the caller wishes a default connection to be established.
import COM.activesw.api.client.*;
 
class MyMonitor
{
static String broker_host = "localhost";
static String broker_name = null;
static String client_group = "admin";
. . .
public static void main(String args[])
{
BrokerAdminClient c;
. . .
/* Create an administrative client */
try {
c = new BrokerAdminClient(broker_host, broker_name, null,
client_group, "My Broker Monitor", null);
} catch (BrokerException ex) {
System.out.println("Error creating admin client\n"+ex);
return;
}
. . .