use of org.apache.cxf.ws.rm.RMManager in project cxf by apache.
the class ManagedEndpointsTest method testSuspendAndResumeSourceSequence.
@Test
public void testSuspendAndResumeSourceSequence() throws Exception {
prepareClient();
RMManager clientManager = clientBus.getExtension(RMManager.class);
InstrumentationManager serverIM = serverBus.getExtension(InstrumentationManager.class);
MBeanServer mbs = serverIM.getMBeanServer();
assertNotNull("MBeanServer must be available.", mbs);
Object o;
GreeterService gs = new GreeterService();
final Greeter greeter = gs.getGreeterPort();
updateAddressPort(greeter, ManagedEndpointsTest.PORT);
LOG.fine("Created greeter client.");
org.apache.cxf.endpoint.Endpoint ep = ClientProxy.getClient(greeter).getEndpoint();
ObjectName clientEndpointName = RMUtils.getManagedObjectName(clientManager, ep);
// sent
greeter.greetMeOneWay("one");
o = mbs.invoke(clientEndpointName, "getCurrentSourceSequenceId", null, null);
assertTrue(o instanceof String);
String sseqId = (String) o;
o = mbs.invoke(clientEndpointName, "getUnAcknowledgedMessageIdentifiers", new Object[] { sseqId }, ONESTRING_SIGNATURE);
assertTrue("No unacknowledged message", o instanceof Long[] && 0 == ((Long[]) o).length);
// sent but suspended
greeter.greetMeOneWay("two");
// sent but suspended
greeter.greetMeOneWay("three");
o = mbs.invoke(clientEndpointName, "getQueuedMessageTotalCount", new Object[] { true }, ONEBOOLEAN_SIGNATURE);
assertTrue("One queued message", o instanceof Integer && 1 == ((Integer) o).intValue());
mbs.invoke(clientEndpointName, "suspendSourceQueue", new Object[] { sseqId }, ONESTRING_SIGNATURE);
LOG.info("suspended the source queue: " + sseqId);
// 3 sec retry interval + 1 sec
LOG.info("waiting for 4 secs for the retry (suspended)...");
Thread.sleep(4000);
o = mbs.invoke(clientEndpointName, "getQueuedMessageTotalCount", new Object[] { true }, ONEBOOLEAN_SIGNATURE);
assertTrue("One queued message", o instanceof Integer && 1 == ((Integer) o).intValue());
mbs.invoke(clientEndpointName, "resumeSourceQueue", new Object[] { sseqId }, ONESTRING_SIGNATURE);
LOG.info("resumed the source queue: " + sseqId);
o = mbs.invoke(clientEndpointName, "getQueuedMessageTotalCount", new Object[] { true }, ONEBOOLEAN_SIGNATURE);
int count = 0;
assertTrue(o instanceof Integer);
while (((Integer) o).intValue() > 0) {
Thread.sleep(200);
count++;
if (count > 100) {
// up to 20 seconds to do the resend, should be within 3 or 4
fail("Failed to empty the resend queue");
}
o = mbs.invoke(clientEndpointName, "getQueuedMessageTotalCount", new Object[] { true }, ONEBOOLEAN_SIGNATURE);
assertTrue(o instanceof Integer);
}
assertTrue("No queued messages", o instanceof Integer && 0 == ((Integer) o).intValue());
}
use of org.apache.cxf.ws.rm.RMManager in project cxf by apache.
the class MessageCallbackOnewayTest method testOnewayAtMostOnce.
private void testOnewayAtMostOnce(Executor executor) throws Exception {
init("org/apache/cxf/systest/ws/rm/atmostonce.xml", executor);
greeterBus.getOutInterceptors().add(new MessageLossSimulator());
RMManager manager = greeterBus.getExtension(RMManager.class);
manager.getConfiguration().setBaseRetransmissionInterval(RETRANSMISSION_INTERVAL);
String[] callArgs = new String[] { "one", "two", "three", "four" };
for (int i = 0; i < callArgs.length; i++) {
greeter.greetMeOneWay(callArgs[i]);
}
callback.waitDone(8, 3000, 60000);
verifyCallbacks();
}
use of org.apache.cxf.ws.rm.RMManager in project cxf by apache.
the class ProtocolVariationsTest method testTerminateSequenceDefault.
@Test
public void testTerminateSequenceDefault() throws Exception {
init("org/apache/cxf/systest/ws/rm/rminterceptors.xml", false);
RMManager manager = greeterBus.getExtension(RMManager.class);
manager.getSourcePolicy().getSequenceTerminationPolicy().setMaxLength(1);
greeter.greetMeOneWay("one");
verifyTerminateSequence(Names200408.WSA_NAMESPACE_NAME, RM10Constants.INSTANCE);
}
use of org.apache.cxf.ws.rm.RMManager in project cxf by apache.
the class RetransmissionGZIPTest method testDecoupleFaultHandling.
@Test
public void testDecoupleFaultHandling() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
bus = bf.createBus("/org/apache/cxf/systest/ws/rm/gzip-enabled.xml");
BusFactory.setDefaultBus(bus);
LoggingInInterceptor in = new LoggingInInterceptor();
bus.getInInterceptors().add(in);
bus.getInFaultInterceptors().add(in);
LoggingOutInterceptor out = new LoggingOutInterceptor();
bus.getOutInterceptors().add(out);
bus.getExtension(RMManager.class).getConfiguration().setBaseRetransmissionInterval(new Long(4000));
// an interceptor to simulate a transmission error
MessageLossSimulator loser = new MessageLossSimulator();
bus.getOutInterceptors().add(loser);
bus.getOutFaultInterceptors().add(out);
GreeterService gs = new GreeterService();
final Greeter greeter = gs.getGreeterPort();
updateAddressPort(greeter, PORT);
LOG.fine("Created greeter client.");
ConnectionHelper.setKeepAliveConnection(greeter, true);
loser.setMode(-1);
loser.setThrowsException(true);
try {
greeter.greetMeOneWay("oneway");
} catch (Exception e) {
fail("fault thrown after queued for retransmission");
}
Thread.sleep(2000);
RMManager manager = bus.getExtension(RMManager.class);
boolean empty = manager.getRetransmissionQueue().isEmpty();
assertFalse("RetransmissionQueue is empty", empty);
loser.setMode(1);
Thread.sleep(6000);
empty = manager.getRetransmissionQueue().isEmpty();
assertTrue("RetransmissionQueue not cleared", empty);
}
use of org.apache.cxf.ws.rm.RMManager in project cxf by apache.
the class RetransmissionQueueTest method testOnewayFaultHandlingWithoutRetry.
@Test
public void testOnewayFaultHandlingWithoutRetry() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
bus = bf.createBus("/org/apache/cxf/systest/ws/rm/message-loss.xml");
BusFactory.setDefaultBus(bus);
LoggingInInterceptor in = new LoggingInInterceptor();
bus.getInInterceptors().add(in);
bus.getInFaultInterceptors().add(in);
LoggingOutInterceptor out = new LoggingOutInterceptor();
bus.getOutInterceptors().add(out);
bus.getExtension(RMManager.class).getConfiguration().setBaseRetransmissionInterval(new Long(4000));
SourcePolicyType sourcePolicy = new SourcePolicyType();
RetryPolicyType retryP = new RetryPolicyType();
retryP.setMaxRetries(0);
sourcePolicy.setRetryPolicy(retryP);
bus.getExtension(RMManager.class).setSourcePolicy(sourcePolicy);
// an interceptor to simulate a transmission error
MessageLossSimulator loser = new MessageLossSimulator();
bus.getOutInterceptors().add(loser);
bus.getOutFaultInterceptors().add(out);
GreeterService gs = new GreeterService();
final Greeter greeter = gs.getGreeterPort();
updateAddressPort(greeter, PORT);
LOG.fine("Created greeter client.");
ConnectionHelper.setKeepAliveConnection(greeter, true);
loser.setMode(-1);
loser.setThrowsException(true);
try {
greeter.greetMeOneWay("oneway");
fail("no retransmission so catch an Exception");
} catch (Exception e) {
assertEquals("simulated transmission exception", e.getMessage());
}
Thread.sleep(6000);
RMManager manager = bus.getExtension(RMManager.class);
boolean empty = manager.getRetransmissionQueue().isEmpty();
assertFalse("RetransmissionQueue is empty", empty);
}
Aggregations