Search in sources :

Example 31 with RMManager

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());
}
Also used : GreeterService(org.apache.cxf.greeter_control.GreeterService) InstrumentationManager(org.apache.cxf.management.InstrumentationManager) Endpoint(javax.xml.ws.Endpoint) ObjectName(javax.management.ObjectName) RMManager(org.apache.cxf.ws.rm.RMManager) Greeter(org.apache.cxf.greeter_control.Greeter) MBeanServer(javax.management.MBeanServer) Test(org.junit.Test)

Example 32 with RMManager

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();
}
Also used : RMManager(org.apache.cxf.ws.rm.RMManager) Endpoint(javax.xml.ws.Endpoint)

Example 33 with RMManager

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);
}
Also used : RMManager(org.apache.cxf.ws.rm.RMManager) Test(org.junit.Test)

Example 34 with RMManager

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);
}
Also used : SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) RMManager(org.apache.cxf.ws.rm.RMManager) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) Greeter(org.apache.cxf.greeter_control.Greeter) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) GreeterService(org.apache.cxf.greeter_control.GreeterService) Test(org.junit.Test)

Example 35 with RMManager

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);
}
Also used : SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) RMManager(org.apache.cxf.ws.rm.RMManager) LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) Greeter(org.apache.cxf.greeter_control.Greeter) SourcePolicyType(org.apache.cxf.ws.rm.manager.SourcePolicyType) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) GreeterService(org.apache.cxf.greeter_control.GreeterService) RetryPolicyType(org.apache.cxf.ws.rm.manager.RetryPolicyType) Test(org.junit.Test)

Aggregations

RMManager (org.apache.cxf.ws.rm.RMManager)43 Test (org.junit.Test)26 Endpoint (javax.xml.ws.Endpoint)12 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)12 GreeterService (org.apache.cxf.greeter_control.GreeterService)10 Greeter (org.apache.cxf.greeter_control.Greeter)9 MessageFlow (org.apache.cxf.systest.ws.util.MessageFlow)8 Bus (org.apache.cxf.Bus)7 Client (org.apache.cxf.endpoint.Client)4 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)4 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)4 MBeanServer (javax.management.MBeanServer)3 ObjectName (javax.management.ObjectName)3 WebServiceException (javax.xml.ws.WebServiceException)3 InstrumentationManager (org.apache.cxf.management.InstrumentationManager)3 Message (org.apache.cxf.message.Message)3 RMProperties (org.apache.cxf.ws.rm.RMProperties)3 RMMessage (org.apache.cxf.ws.rm.persistence.RMMessage)3 SQLException (java.sql.SQLException)2 SoapFault (org.apache.cxf.binding.soap.SoapFault)2