|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
CMP api |
« View previous topic :: View next topic » |
Author |
Message
|
paustin_ours |
Posted: Tue Oct 13, 2009 10:23 am Post subject: CMP api |
|
|
Yatiri
Joined: 19 May 2004 Posts: 667 Location: columbus,oh
|
trying to create new EG using CMP api. have the code like this.
Code: |
BrokerProxy broker = topology.getBrokerByName(brokerName);
if (broker == null) {
System.out.println("Broker not found");
} else {
broker.createExecutionGroup(executionGroupName); |
how do i check the result of creating an EG? In the API doc it says check
executiongrouproxy.deploy but i dont want to deploy i just want to create an eg and quit. |
|
Back to top |
|
 |
paustin_ours |
Posted: Tue Oct 13, 2009 10:26 am Post subject: |
|
|
Yatiri
Joined: 19 May 2004 Posts: 667 Location: columbus,oh
|
the code sits and waits at the createexecutiongroup step for a long time and then even after that the code takes over 5 minuted to complete.
Not sure why it is taking so long.
here is the entire code.
Code: |
package cmp;
import com.ibm.broker.config.proxy.*;
public class CreateNewEg {
/**
* Attempts to deploy a BAR file to the resource whose name is hard-coded
* within the source.
*
* @param args
* Not used
*/
public static void main(String[] args) {
// Modify the values of these variables in order
// to change the Configuration Manager, broker, execution
// group and BAR file settings used by this sample.
// -----------------------------------------------
String configHostName = "*******";
int configPort = 1414;
String configQmgrName = "****";
String brokerName = "*****";
String executionGroupName = "****";
// String barFileName = "mybar.bar";
// -----------------------------------------------
// Instantiate an object that describes the connection
// characteristics to the Configuration Manager.
ConfigManagerConnectionParameters cmcp = new MQConfigManagerConnectionParameters(
configHostName, configPort, configQmgrName);
ConfigManagerProxy cmp = null;
try {
// Start communication with the Configuration Manager
System.out
.println("Connecting to Configuration Manager running on "
+ configQmgrName + " at " + configHostName + ":"
+ configPort + "...");
cmp = ConfigManagerProxy.getInstance(cmcp);
// Has the Configuration Manager responded to the connection
// attempt?
if (!cmp.hasBeenUpdatedByConfigManager(true)) {
// The application timed out while waiting for a response from
// the
// Configuration Manager. When it finally becomes available,
// hasBeenUpdatedByConfigurationManager()
// will return true. This application won't wait for that
// though-
// it will just exit now.
System.out.println("Configuration Manager is not responding.");
} else {
// Get the list of brokers defined in that CM's domain
System.out.println("Getting domain information...");
TopologyProxy topology = cmp.getTopology();
// Find the broker with the given name
System.out
.println("Discovering broker '" + brokerName + "'...");
BrokerProxy broker = topology.getBrokerByName(brokerName);
// If the broker exists, find the execution group with the given
// name
if (broker == null) {
System.out.println("Broker not found");
} else {
// System.out.println("Discovering execution group
// '"+executionGroupName+"'...");
// ExecutionGroupProxy eg =
// broker.getExecutionGroupByName(executionGroupName);
System.out.println("Creating new EG");
// ExecutionGroupProxy eg =
broker.createExecutionGroup(executionGroupName);
System.out.println("EG done");
// If the execution group exists, deploy to it.
/*
* if (eg == null) { System.out.println("Execution group not
* found"); } else {
* // Deploy the BAR file and display the result
* System.out.println("Deploying "+barFileName+"..."); try {
* DeployResult deployResult = eg.deploy(barFileName, //
* location of BAR true, // incremental, i.e. don't empty
* the execution group first 10000); // wait 10s for broker
* response
*
* System.out.println("Result =
* "+deployResult.getCompletionCode());
* // You may like to improve this application by querying //
* the deployResult for more information, particularly if //
* deployResult.getCompletionCode() ==
* CompletionCodeType.failure.
* } catch (IOException ioEx) { // e.g. if BAR file doesn't
* exist ioEx.printStackTrace(); }
* }
*/
}
}
} catch (ConfigManagerProxyException cmpEx) {
cmpEx.printStackTrace();
} finally {
if (cmp != null) {
cmp.disconnect();
}
}
}
} |
|
|
Back to top |
|
 |
mqmatt |
Posted: Wed Oct 14, 2009 8:10 am Post subject: |
|
|
 Grand Master
Joined: 04 Aug 2004 Posts: 1213 Location: Hursley, UK
|
In v6.1, everything happens asynchronously, so you should use the BrokerProxy.registerListener() method, and use a callback to catch the response to the EG create using the MyAdministeredObjectListener.processActionResponse() method.
(You can do this in v7 as well, but you can also elect to run methods synchronously using BrokerProxy.setSynchronous() ... if you do this, a successful return code from createExecutionGroup() means that the EG was created successfully).
Hope this helps.
-Matt |
|
Back to top |
|
 |
paustin_ours |
Posted: Wed Oct 14, 2009 1:21 pm Post subject: |
|
|
Yatiri
Joined: 19 May 2004 Posts: 667 Location: columbus,oh
|
Are there any samples somewhere using these? It would be really helpful. Also i am looking for samples to set javadebug port, configurable properties etc., |
|
Back to top |
|
 |
mqmatt |
Posted: Thu Oct 15, 2009 4:38 am Post subject: |
|
|
 Grand Master
Joined: 04 Aug 2004 Posts: 1213 Location: Hursley, UK
|
In the runtime install directory, check out the DomainInfo sample (aka BrokerInfo in v7) for how to implement AdministeredObjectListeners.
V7 has an explicit method for setting the debug port:
Code: |
ExecutionGroupProxy.setDebugPort(newValue); |
but it's quite easy in v6.1 too:
Code: |
ExecutionGroupProxy.setRuntimeProperty(RuntimePropertyConstants.NAME_JVMDEBUGPORT, newValue);
BrokerProxy.deploy(); |
Setting other configurable properties works in much the same way (explicit classes/methods in v7, and runtime properties in v6.1)
Check out the CMP API Exerciser for the set of acceptable values for v6.1. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|