Setting properties of a configurable service of type UserDefined at run time by using a JavaCompute node

Use the IBM® Integration API in a JavaCompute node to query, set, create, and delete properties dynamically at run time, in configurable services that have the UserDefined type.

Before you begin

Complete the following tasks.

About this task

If you created a UserDefined configurable service, and created properties for that service, you can work with those properties in a JavaCompute node. For example, you can create a UserDefined configurable service to set timeouts for processing HTTP messages.

You can create and delete configurable services in JavaCompute nodes, in the web user interface, and by using the mqsicreateconfigurableservice and mqsideleteconfigurableservice commands.

Procedure

  1. Right-click the JavaCompute node and click Open Java to create and open a Java™ file in the Editor view, or open an existing file.
  2. Create the Java class for the node in which you want to include IBM Integration API methods.
  3. Add the IBM Integration API JAR file install_dir/common/classes/IntegrationAPI.jar to the Java build path for the associated Java project.
  4. Import com.ibm.broker.config.proxy.* in your code.
  5. Add the following static method to the class that you created:
    BrokerProxy b = BrokerProxy.getLocalInstance();

    This method returns an instance of the BrokerProxy object for the integration node to which the message flow (that contains this node) is deployed.

  6. To ensure that the BrokerProxy object is populated with data from the integration node before you access the configurable service, add the following code:
    while(!b.hasBeenPopulatedByBroker()) { Thread.sleep(100); } 
  7. Access the appropriate UserDefined configurable service:
    1. If you know the name of the configurable service, use the following code to access it:
      ConfigurableService myUDCS = b.getConfigurableService("UserDefined", "UD1");
    2. If you want to select from a set of UserDefined configurable services, use the following code to get a list of all services of a particular type:
      ConfigurableService[] UD_set = b.getConfigurableServices("UserDefined");
  8. Add further code to access and use the specific properties that you are interested in.
    For example:
    • Retrieve the properties that are defined to that service:
      String[] props = myUDCS.getProperties();
    • Create a new property:
      String newprop = 'VerifyRequestTimeout';
      String newval = '15';
      myUDCS.setProperty(newprop, newval);
    • Delete a property:
      myUDCS.deleteProperty(newprop);
      You can also use the deleteProperties() method to delete more than one property.

      You can delete properties in UserDefined configurable services only. If you use this method on a configurable service of a different type, a ConfigManagerProxyLoggedException is generated.

  9. Deploy the JAR file, and all associated message flows, in a BAR file.
    You do not have to deploy the IntegrationAPI.jar file to the target integration server, because the integration node can access these classes independently.
  10. It is best practice to call disconnect() on the BrokerProxy object after you have finished using it.
    By calling disconnect(), you deregister all listeners that are registered to the BrokerProxy instance and close the link to the integration node.