Search in sources :

Example 1 with SequenceTerminationPolicyType

use of org.apache.cxf.ws.rm.manager.SequenceTerminationPolicyType in project cxf by apache.

the class RMManagerTest method testInitialisation.

@Test
public void testInitialisation() {
    manager = new RMManager();
    assertNull("sourcePolicy is set.", manager.getSourcePolicy());
    assertNull("destinationPolicy is set.", manager.getDestinationPolicy());
    manager.initialise();
    RMConfiguration cfg = manager.getConfiguration();
    assertNotNull("RMConfiguration is not set.", cfg);
    assertNotNull("sourcePolicy is not set.", manager.getSourcePolicy());
    assertNotNull("destinationPolicy is not set.", manager.getDestinationPolicy());
    assertNotNull("deliveryAssirance is not set.", cfg.getDeliveryAssurance());
    assertTrue(cfg.isExponentialBackoff());
    assertEquals(3000L, cfg.getBaseRetransmissionInterval().longValue());
    assertNull(cfg.getAcknowledgementInterval());
    assertNull(cfg.getInactivityTimeout());
    SourcePolicyType sp = manager.getSourcePolicy();
    assertEquals(0L, sp.getSequenceExpiration().getTimeInMillis(new Date()));
    assertEquals(0L, sp.getOfferedSequenceExpiration().getTimeInMillis(new Date()));
    assertNull(sp.getAcksTo());
    assertTrue(sp.isIncludeOffer());
    SequenceTerminationPolicyType stp = sp.getSequenceTerminationPolicy();
    assertEquals(0, stp.getMaxRanges());
    assertEquals(0, stp.getMaxUnacknowledged());
    assertTrue(stp.isTerminateOnShutdown());
    assertEquals(0, stp.getMaxLength());
    DestinationPolicyType dp = manager.getDestinationPolicy();
    assertNotNull(dp.getAcksPolicy());
    assertEquals(dp.getAcksPolicy().getIntraMessageThreshold(), 10);
}
Also used : SequenceTerminationPolicyType(org.apache.cxf.ws.rm.manager.SequenceTerminationPolicyType) SourcePolicyType(org.apache.cxf.ws.rm.manager.SourcePolicyType) DestinationPolicyType(org.apache.cxf.ws.rm.manager.DestinationPolicyType) Date(java.util.Date) Test(org.junit.Test)

Example 2 with SequenceTerminationPolicyType

use of org.apache.cxf.ws.rm.manager.SequenceTerminationPolicyType in project cxf by apache.

the class RMEndpoint method shutdown.

void shutdown() {
    for (DestinationSequence ds : getDestination().getAllSequences()) {
        ds.cancelDeferredAcknowledgments();
        ds.cancelTermination();
    }
    // try terminating sequences
    SourcePolicyType sp = manager.getSourcePolicy();
    SequenceTerminationPolicyType stp = null;
    if (null != sp) {
        stp = sp.getSequenceTerminationPolicy();
    }
    if (null != stp && stp.isTerminateOnShutdown()) {
        Collection<SourceSequence> seqs = source.getAllUnacknowledgedSequences();
        LOG.log(Level.FINE, "Trying to terminate {0} sequences", seqs.size());
        for (SourceSequence seq : seqs) {
            try {
                // sequence acknowledgement
                if (seq.isLastMessage()) {
                // REVISIT: this may be non-standard
                // getProxy().ackRequested(seq);
                } else {
                    getProxy().lastMessage(seq);
                }
            } catch (RMException ex) {
            // already logged
            }
        }
    }
    for (SourceSequence ss : getSource().getAllSequences()) {
        manager.getRetransmissionQueue().stop(ss);
    }
    for (DestinationSequence ds : getDestination().getAllSequences()) {
        manager.getRedeliveryQueue().stop(ds);
    }
// unregistering of this managed bean from the server is done by the bus itself
}
Also used : SequenceTerminationPolicyType(org.apache.cxf.ws.rm.manager.SequenceTerminationPolicyType) SourcePolicyType(org.apache.cxf.ws.rm.manager.SourcePolicyType)

Example 3 with SequenceTerminationPolicyType

use of org.apache.cxf.ws.rm.manager.SequenceTerminationPolicyType in project cxf by apache.

the class SourceSequence method checkLastMessage.

/**
 * Checks if the current message should be the last message in this sequence
 * and if so sets the lastMessageNumber property.
 */
private void checkLastMessage(Identifier inSeqId, long inMsgNumber) {
    if (null != inSeqId && 0 != inMsgNumber) {
        Destination destination = source.getReliableEndpoint().getDestination();
        DestinationSequence inSeq = null;
        if (null != destination) {
            inSeq = destination.getSequence(inSeqId);
        }
        if (null != inSeq && offeredBy(inSeqId) && inMsgNumber == inSeq.getLastMessageNumber()) {
            lastMessage = true;
        }
    }
    if (!lastMessage) {
        SequenceTerminationPolicyType stp = source.getManager().getSourcePolicy().getSequenceTerminationPolicy();
        assert null != stp;
        if ((stp.getMaxLength() != 0 && stp.getMaxLength() <= currentMessageNumber) || (stp.getMaxRanges() > 0 && acknowledgement.getAcknowledgementRange().size() >= stp.getMaxRanges()) || (stp.getMaxUnacknowledged() > 0 && source.getManager().getRetransmissionQueue().countUnacknowledged(this) >= stp.getMaxUnacknowledged())) {
            lastMessage = true;
        }
    }
    if (LOG.isLoggable(Level.FINE) && lastMessage) {
        LOG.fine(currentMessageNumber + " should be the last message in this sequence.");
    }
}
Also used : SequenceTerminationPolicyType(org.apache.cxf.ws.rm.manager.SequenceTerminationPolicyType)

Example 4 with SequenceTerminationPolicyType

use of org.apache.cxf.ws.rm.manager.SequenceTerminationPolicyType in project cxf by apache.

the class RMManager method setSourcePolicy.

/**
 * @param sp The sourcePolicy to set.
 */
public void setSourcePolicy(SourcePolicyType sp) {
    if (null == sp) {
        sp = new SourcePolicyType();
    }
    if (sp.getSequenceTerminationPolicy() == null) {
        SequenceTerminationPolicyType term = new SequenceTerminationPolicyType();
        term.setTerminateOnShutdown(true);
        sp.setSequenceTerminationPolicy(term);
    }
    sourcePolicy = sp;
}
Also used : SequenceTerminationPolicyType(org.apache.cxf.ws.rm.manager.SequenceTerminationPolicyType) SourcePolicyType(org.apache.cxf.ws.rm.manager.SourcePolicyType)

Example 5 with SequenceTerminationPolicyType

use of org.apache.cxf.ws.rm.manager.SequenceTerminationPolicyType in project cxf by apache.

the class RMManagerTest method testCustom.

@Test
public void testCustom() {
    Bus bus = new SpringBusFactory().createBus("org/apache/cxf/ws/rm/custom-rmmanager.xml", false);
    manager = bus.getExtension(RMManager.class);
    assertNotNull("sourcePolicy is not set.", manager.getSourcePolicy());
    assertNotNull("destinationPolicy is not set.", manager.getDestinationPolicy());
    manager.initialise();
    RMConfiguration cfg = manager.getConfiguration();
    assertNotNull("RMConfiguration is not set.", cfg);
    assertNotNull("deliveryAssurance is not set.", cfg.getDeliveryAssurance());
    assertFalse(cfg.isExponentialBackoff());
    assertEquals(10000L, cfg.getBaseRetransmissionInterval().longValue());
    assertEquals(10000L, cfg.getAcknowledgementIntervalTime());
    assertNull(cfg.getInactivityTimeout());
    SourcePolicyType sp = manager.getSourcePolicy();
    assertEquals(0L, sp.getSequenceExpiration().getTimeInMillis(new Date()));
    assertEquals(0L, sp.getOfferedSequenceExpiration().getTimeInMillis(new Date()));
    assertNull(sp.getAcksTo());
    assertTrue(sp.isIncludeOffer());
    SequenceTerminationPolicyType stp = sp.getSequenceTerminationPolicy();
    assertEquals(0, stp.getMaxRanges());
    assertEquals(0, stp.getMaxUnacknowledged());
    assertFalse(stp.isTerminateOnShutdown());
    assertEquals(0, stp.getMaxLength());
    DestinationPolicyType dp = manager.getDestinationPolicy();
    assertNotNull(dp.getAcksPolicy());
    assertEquals(dp.getAcksPolicy().getIntraMessageThreshold(), 0);
}
Also used : Bus(org.apache.cxf.Bus) SequenceTerminationPolicyType(org.apache.cxf.ws.rm.manager.SequenceTerminationPolicyType) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) SourcePolicyType(org.apache.cxf.ws.rm.manager.SourcePolicyType) DestinationPolicyType(org.apache.cxf.ws.rm.manager.DestinationPolicyType) Date(java.util.Date) Test(org.junit.Test)

Aggregations

SequenceTerminationPolicyType (org.apache.cxf.ws.rm.manager.SequenceTerminationPolicyType)5 SourcePolicyType (org.apache.cxf.ws.rm.manager.SourcePolicyType)4 Date (java.util.Date)2 DestinationPolicyType (org.apache.cxf.ws.rm.manager.DestinationPolicyType)2 Test (org.junit.Test)2 Bus (org.apache.cxf.Bus)1 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)1