You can use the CMP API to manage brokers and their
associated resources from JavaCompute nodes in deployed
message flows.
Before you start
Before
starting this step, you must create a JavaCompute node in
a message flow.
Use CMP methods and classes in your JavaCompute node to explore
and manage brokers and other resources.
- Create the Java class
for the node in which you want to include CMP methods.
- Add the CMP JAR
file install_dir/classes/ConfigManagerProxy.jar to
the Java build path for the
associated Java project.
- Add the following static method to the class:
BrokerProxy thisBroker = BrokerProxy.getLocalInstance();
This
method returns an instance of the BrokerProxy object for the broker
to which the message flow (that contains this node) is deployed.
- To work with an execution group on this broker, add the
following static method to your code:
ExecutionGroupProxy thisEG = ExecutionGroupProxy.getLocalInstance();
This method returns an instance of the ExecutionGroupProxy
object for the execution group to which the message flow is deployed.
- If you want to connect to a different broker that you have
created on the computer to which your node and message flow are deployed,
you can use a variant of this class:
BrokerProxy secondBroker = BrokerProxy.getLocalInstance(string)
Specify
the name of the alternative local broker as the value of the variable string.
Your code can manage this second broker, and its associated resources,
by using the BrokerProxy object that is returned by this call.
- Include additional CMP methods
in your Java code to run the
operations that you want against the broker or execution group by
using the objects obtained in previous steps. You can follow
the guidance that is provided in other topics in this section for
further information and examples that show how to use CMP methods in CMP applications.
If you include methods that affect the message
flow in which your CMP application
is running, it might not be able to receive all notifications that
these operations have successfully completed. Stopping, deleting,
and redeploying the message flow are examples in this category; consider
carefully the consequences of using these methods.
- Deploy the JAR file, and all associated message flows,
in a BAR file. You do not have to deploy the ConfigManagerProxy.jar file
to the target execution group, because the broker can access these
classes independently.