Recording and replaying data by using a custom integration application
You can create custom integration applications to examine and replay the data that you have recorded and stored by using record and replay.
Before you begin
Read the concept topic Record and replay.
About this task
For further information about these objects and how to use them, see the IBM Integration API information.
The following example shows how
to retrieve data from an integration server by using
the DataCaptureProxy 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();
}
}
The following example shows how to replay data.
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("IBNODE");
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();
}
}