Configuring workload management policies by using the IBM Integration API

Create, retrieve, update, and delete workload management policies by using the IBM® Integration API.

About this task

Example code is provided for the following tasks:

Creating a workload management policy

About this task

The following code provides an example of creating a workload management policy.

public static void PolicyCreate(String hostname, int port) {
  BrokerProxy b = null;
  try {      
    System.out.println("Connecting to the integration node.");
    System.out.println("Hostname="+hostname+", Port="+port+");
    BrokerConnectionParameters bcp = new IntegrationNodeConnectionParameters(hostname, port);
    b = BrokerProxy.getInstance(bcp);     
    String policyName = "ExamplePolicy";
    String policyType = "WorkloadManagement";
    String policyContent = "<wsp:Policy xmlns:wsp=\"http://www.w3.org/ns/ws-policy\">
                           <iwlm:workloadManagement xmlns:iwlm=\"http://www.ibm.com/xmlns/prod/websphere/iib/9.0.0/policy/wlm\">
                           <iwlm:notificationThresholdMsgsPerSec>75</iwlm:notificationThresholdMsgsPerSec>
                           <iwlm:maximumRateMsgsPerSec>100</iwlm:maximumRateMsgsPerSec>
                           <iwlm:processingTimeoutSec></iwlm:processingTimeoutSec>
                           <iwlm:processingTimeoutAction></iwlm:processingTimeoutAction>
                           <iwlm:additionalInstances>0</iwlm:additionalInstances>
                           <iwlm:startInstancesWhenFlowStarts>false</iwlm:startInstancesWhenFlowStarts>
                           <iwlm:commitCount>0</iwlm:commitCount>
                           <iwlm:commitInterval></iwlm:commitInterval>
                           <iwlm:startMode>maintained</iwlm:startMode>
                           </iwlm:workloadManagement>
                           </wsp:Policy>";	   			 
                           System.out.println("About to create a policy.");
    b.createPolicy(policyType, policyName, policyContent);    
    System.out.println("Disconnecting from the integration node.");
    b.disconnect();
  } catch (ConfigManagerProxyException ex) {
    ex.printStackTrace();
  }
}

Retrieving a workload management policy

About this task

The following code provides an example of retrieving a workload management policy.

public static void PolicyRetrieve(String hostname, int port) {
	BrokerProxy b = null;
	try {			 
		 System.out.println("Connecting to the integration node.");
		 System.out.println("Hostname="+hostname+", Port="+port+");
		 BrokerConnectionParameters bcp = new IntegrationNodeConnectionParameters(hostname, port);
		 b = BrokerProxy.getInstance(bcp);			 
		 String policyName = "ExamplePolicy";
		 String policyType = "WorkloadManagement";			 	   		
		 System.out.println("About to retrieve a policy.");
		 PolicyProxy p = b.getPolicy(policyType, policyName);
		 System.out.println("Policy contents of retrieved policy:");
		 System.out.println(p.getPolicyContent());
		 System.out.println("Disconnecting from the integration node.");
		 b.disconnect();
	} catch (ConfigManagerProxyException ex) {
		 ex.printStackTrace();
	}
}	

Updating a workload management policy

About this task

The following code provides an example of updating a workload management policy.

public static void PolicyUpdate(String hostname, int port) {
  BrokerProxy b = null;
  try {      
    System.out.println("Connecting to the integration node.");
    System.out.println("Hostname="+hostname+", Port="+port+");
    BrokerConnectionParameters bcp = new IntegrationNodeConnectionParameters(hostname, port);
    b = BrokerProxy.getInstance(bcp);     
    String policyName = "ExamplePolicy";
    String policyType = "WorkloadManagement";
    String policyContent = "<wsp:Policy xmlns:wsp=\"http://www.w3.org/ns/ws-policy\">
                           <iwlm:workloadManagement xmlns:iwlm=\"http://www.ibm.com/xmlns/prod/websphere/iib/9.0.0/policy/wlm\">
                           <iwlm:notificationThresholdMsgsPerSec>75</iwlm:notificationThresholdMsgsPerSec>
                           <iwlm:maximumRateMsgsPerSec>100</iwlm:maximumRateMsgsPerSec>
                           <iwlm:processingTimeoutSec></iwlm:processingTimeoutSec>
                           <iwlm:processingTimeoutAction></iwlm:processingTimeoutAction>
                           <iwlm:additionalInstances>0</iwlm:additionalInstances>
                           <iwlm:startInstancesWhenFlowStarts>false</iwlm:startInstancesWhenFlowStarts>
                           <iwlm:commitCount>0</iwlm:commitCount>
                           <iwlm:commitInterval></iwlm:commitInterval>
                           <iwlm:startMode>maintained</iwlm:startMode></iwlm:workloadManagement>
                           </wsp:Policy>";          
                           System.out.println("About to update a policy.");
    b.updatePolicy(policyType, policyName, policyContent);
    System.out.println("Disconnecting from the integration node.");
    b.disconnect();
  } catch (ConfigManagerProxyException ex) {
    ex.printStackTrace();
  }
} 

Deleting a workload management policy

About this task

The following code provides an example of deleting a workload management policy.

public static void PolicyDelete(String hostname, int port) {
	BrokerProxy b = null;
	try {			 
		 System.out.println("Connecting to the integration node.");
		 System.out.println("Hostname="+hostname+", Port="+port+");
		 BrokerConnectionParameters bcp = new IntegrationNodeConnectionParameters(hostname, port);
		 b = BrokerProxy.getInstance(bcp);	   
		 String policyName = "ExamplePolicy";
		 String policyType = "WorkloadManagement";			 	   		 
		 System.out.println("About to delete a policy.");
		 b.deletePolicy(policyType, policyName);
		 System.out.println("Disconnecting from the integration node.");
		 b.disconnect();
	} catch (ConfigManagerProxyException ex) {
		 ex.printStackTrace();
	}
}