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 = "sequence1";
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"));
Thread.sleep(5000);
StorageManager mgr = SandeshaUtil.getInMemoryStorageManager(configContext);
Transaction t = mgr.getTransaction();
String inboundSequenceID = SandeshaUtil.getSequenceIDFromInternalSequenceID(SandeshaUtil.getInternalSequenceID(to, sequenceKey),
mgr);
t.commit();
SandeshaClient.forceDispatchOfInboundMessages(serverConfigCtx,
inboundSequenceID,
true); //allow later msgs to be delivered
//check that the server is now expecting msg 4
StorageManager serverStore = SandeshaUtil.getInMemoryStorageManager(serverConfigCtx);
t = serverStore.getTransaction();
RMDBean rMDBean =
serverStore.getRMDBeanMgr().retrieve(inboundSequenceID);
assertNotNull(rMDBean);
assertEquals(rMDBean.getNextMsgNoToProcess(), 4);
//also check that the sequence has an out of order gap that contains msg 2
assertNotNull(rMDBean.getOutOfOrderRanges());
RangeString rangeString = rMDBean.getOutOfOrderRanges();
assertTrue(rangeString.isMessageNumberInRanges(2));
t.commit();
//we deliver msg 2
//set highest out msg number to 1
String internalSequenceId = SandeshaUtil.getInternalSequenceID(to, sequenceKey);
t = mgr.getTransaction();
RMSBean rmsBean = SandeshaUtil.getRMSBeanFromInternalSequenceId(mgr, internalSequenceId);
rmsBean.setNextMessageNumber(1);
// Update the bean
mgr.getRMSBeanMgr().update(rmsBean);
t.commit();
clientOptions.setProperty(SandeshaClientConstants.MESSAGE_NUMBER,new Long(2));
serviceClient.fireAndForget(getPingOMBlock("ping2"));
}
finally{
configContext.getListenerManager().stop();
serviceClient.cleanup();