String to = "http://127.0.0.1:" + serverPort + "/axis2/services/RMSampleService";
String repoPath = "target" + File.separator + "repos" + File.separator + "client";
String axis2_xml = "target" + File.separator + "repos" + File.separator + "client" + File.separator + "client_axis2.xml";
ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(repoPath,axis2_xml);
Options clientOptions = new Options ();
clientOptions.setAction(pingAction);
clientOptions.setSoapVersionURI(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
clientOptions.setTo(new EndpointReference (to));
String sequenceKey = "sequence2";
clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
ServiceClient serviceClient = new ServiceClient (configContext,null);
serviceClient.setOptions(clientOptions);
try
{
serviceClient.fireAndForget(getPingOMBlock("ping1"));
//now deliver the next out of order
clientOptions.setProperty(SandeshaClientConstants.MESSAGE_NUMBER,new Long(3));
serviceClient.fireAndForget(getPingOMBlock("ping3"));
String internalSequenceId = SandeshaUtil.getInternalSequenceID(to, sequenceKey);
waitForMessageToBeAcked(serviceClient, internalSequenceId);
StorageManager mgr = SandeshaUtil.getInMemoryStorageManager(configContext);
Transaction t = mgr.getTransaction();
String inboundSequenceID = SandeshaUtil.getSequenceIDFromInternalSequenceID(internalSequenceId,
mgr);
t.commit();
SandeshaClient.forceDispatchOfInboundMessages(serverConfigCtx, inboundSequenceID, false);
//check that the server is now expecting msg 4
StorageManager serverMgr = SandeshaUtil.getInMemoryStorageManager(serverConfigCtx);
t = serverMgr.getTransaction();
RMDBean rMDBean = serverMgr.getRMDBeanMgr().retrieve(inboundSequenceID);
assertNotNull(rMDBean);
assertEquals(rMDBean.getNextMsgNoToProcess(), 4);
t.commit();
}
finally{
configContext.getListenerManager().stop();
serviceClient.cleanup();
}
}