Options clientOptions = new Options ();
clientOptions.setTo(new EndpointReference (to));
clientOptions.setProperty(Configuration.TRANSPORT_URL,transportTo);
ServiceClient serviceClient = new ServiceClient (configContext,null);
clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION, Sandesha2Constants.SPEC_VERSIONS.v1_1);
clientOptions.setUseSeparateListener(true);
serviceClient.setOptions(clientOptions);
// Create a sequence
SandeshaClient.createSequence(serviceClient, false, null);
long limit = System.currentTimeMillis() + waitTime;
Error lastError = null;
while(System.currentTimeMillis() < limit) {
Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
try {
//now check the sequence is running
SequenceReport report = SandeshaClient.getOutgoingSequenceReport(serviceClient);
assertEquals(report.getSequenceStatus(), SequenceReport.SEQUENCE_STATUS_ESTABLISHED);
lastError = null;
break;
} catch(Error e) {
lastError = e;
}
}
if(lastError != null) throw lastError;
// Send the ACK request
SandeshaClient.sendAckRequest(serviceClient);
limit = System.currentTimeMillis() + waitTime;
while(System.currentTimeMillis() < limit) {
Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
try {
// Get the storage manager from the ConfigurationContext
StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configContext, configContext.getAxisConfiguration());
// Get the sequence id for this sequence.
String sequenceId = SandeshaClient.getSequenceID(serviceClient);
// Get the SenderBeanManager
SenderBeanMgr senderManager = storageManager.getSenderBeanMgr();
Transaction transaction = storageManager.getTransaction();
// Check that there are no sender beans inside the SenderBeanMgr.
SenderBean senderBean = new SenderBean();
senderBean.setSequenceID(sequenceId);
senderBean.setSend(true);
senderBean.setReSend(false);
// Find any sender beans for the to address.
List beans = senderManager.find(senderBean);
//only the ackRequested bean will be present.
assertTrue("SenderBeans found when the list should be empty", (beans.size()==1));
SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
transaction.commit();
assertNotNull(sequenceReport.getSequenceID());
assertFalse(sequenceReport.isSecureSequence());
lastError = null;
break;
} catch(Error e) {
lastError = e;
}
}
if(lastError != null) throw lastError;
configContext.getListenerManager().stop();
serviceClient.cleanup();
}