CMP アプリケーションを作成して、記録および再生を使用することで、記録および保管したデータを検証したり、再生したりすることができます。
概念トピック 記録および再生をお読みください。
このオブジェクトとその使い方について詳しくは、CMP APIを参照してください。
BrokerProxy bp = null;
try {
BrokerProxy.enableAdministrationAPITracing("C:\\AdminTrace.txt");
bp = BrokerProxy.getLocalInstance("WEB");
ExecutionGroupProxy eg = bp.getExecutionGroupByName("default");
Properties newFilterProps = new Properties();
newFilterProps.setProperty(DataCaptureEntry.PROPERTY_BROKER_NAME, "WEB");
DataCaptureEntry filterMessage = new DataCaptureEntry(newFilterProps);
DataCaptureProxy dcp = eg.getDataCapture("MYDATA", filterMessage);
String output = dcp.getDataCaptureEntryAsXml(1);
System.out.println("XML output: "+output);
int messNo = 0;
Enumeration <DataCaptureEntry> dceE = dcp.elements();
while (dceE.hasMoreElements()) {
DataCaptureEntry dce = dceE.nextElement();
System.out.print("\nMessage: "+messNo++);
Properties props = dce.getAllProperties();
String[] columns = dce.getPropertyNames();
for (int i = 0; i < columns.length; i++) {
System.out.print("\nProperty: "+columns[i]+ " Value: "+props.getProperty(columns[i]));
}
}
} catch (ConfigManagerProxyLoggedException e) {
e.printStackTrace();
} catch (ConfigManagerProxyPropertyNotInitializedException e) {
e.printStackTrace();
} finally {
if(bp != null) {
bp.disconnect();
}
}
以下の例は、データを再生する方法を示しています。
BrokerProxy brokerProxy = null;
try {
// DataCaptureStore containing message to replay
String dataCaptureStore = "MyStore";
// ID of message to replay
String replayMsgId = "0123456789ABCDEF";
// DataDestination to replay message to
String dataDestination = "ReplayDestination";
// EG to replay
String replayEG = "MyExecutionGroupName";
Properties dataCaptureProps = new Properties();
// Set the message to replay
dataCaptureProps.setProperty(DataCaptureEntry.PROPERTY_WMBMSG_KEY, replayMsgId);
// Set the destination to replay to
dataCaptureProps.setProperty(AttributeConstants.DATACAPTURE_REPLAY, dataDestination);
DataCaptureEntry dataCaptureEntry = new DataCaptureEntry(dataCaptureProps );
brokerProxy = WebAdminBrokerProxy.getLocalInstance("MB8BROKER");
ExecutionGroupProxy egProxy = brokerProxy.getExecutionGroupByName(replayEG);
// Submit request to EG to actually do replay
DataCaptureProxy dataCaptureProxy = egProxy.getDataCapture(dataCaptureStore, dataCaptureEntry);
dataCaptureProxy.hasBeenPopulatedByBroker(true);
String responseBody = dataCaptureProxy.getDataCaptureEntryAsXml(1);
} catch (Exception e) {
// TODO: Handle Exception
} finally {
if (brokerProxy != null) {
brokerProxy.disconnect();
}
}