Search in sources :

Example 1 with DeliveryAssurance

use of org.apache.cxf.ws.rm.RMConfiguration.DeliveryAssurance in project cxf by apache.

the class RMManagerConfigurationTest method testExactlyOnce.

@Test
public void testExactlyOnce() {
    SpringBusFactory factory = new SpringBusFactory();
    bus = factory.createBus("org/apache/cxf/ws/rm/exactly-once.xml", false);
    RMManager manager = bus.getExtension(RMManager.class);
    RMConfiguration cfg = manager.getConfiguration();
    DeliveryAssurance da = cfg.getDeliveryAssurance();
    assertEquals(da, DeliveryAssurance.EXACTLY_ONCE);
    assertFalse(cfg.isInOrder());
}
Also used : SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) DeliveryAssurance(org.apache.cxf.ws.rm.RMConfiguration.DeliveryAssurance) Test(org.junit.Test)

Example 2 with DeliveryAssurance

use of org.apache.cxf.ws.rm.RMConfiguration.DeliveryAssurance in project cxf by apache.

the class RMManager method setDeliveryAssurance.

/**
 * @param dat The deliveryAssurance to set.
 */
public void setDeliveryAssurance(DeliveryAssuranceType dat) {
    RMConfiguration cfg = getConfiguration();
    cfg.setInOrder(dat.isSetInOrder());
    DeliveryAssurance da = null;
    if (dat.isSetExactlyOnce() || (dat.isSetAtLeastOnce() && dat.isSetAtMostOnce())) {
        da = DeliveryAssurance.EXACTLY_ONCE;
    } else if (dat.isSetAtLeastOnce()) {
        da = DeliveryAssurance.AT_LEAST_ONCE;
    } else if (dat.isSetAtMostOnce()) {
        da = DeliveryAssurance.AT_MOST_ONCE;
    }
    cfg.setDeliveryAssurance(da);
}
Also used : DeliveryAssurance(org.apache.cxf.ws.rm.RMConfiguration.DeliveryAssurance)

Example 3 with DeliveryAssurance

use of org.apache.cxf.ws.rm.RMConfiguration.DeliveryAssurance in project cxf by apache.

the class RMManager method initialise.

@PostConstruct
void initialise() {
    if (configuration == null) {
        getConfiguration().setExponentialBackoff(true);
    }
    DeliveryAssurance da = configuration.getDeliveryAssurance();
    if (da == null) {
        configuration.setDeliveryAssurance(DeliveryAssurance.AT_LEAST_ONCE);
    }
    if (null == sourcePolicy) {
        setSourcePolicy(null);
    }
    if (null == destinationPolicy) {
        DestinationPolicyType dp = new DestinationPolicyType();
        dp.setAcksPolicy(new AcksPolicyType());
        setDestinationPolicy(dp);
    }
    if (null == retransmissionQueue) {
        retransmissionQueue = new RetransmissionQueueImpl(this);
    }
    if (null == redeliveryQueue) {
        redeliveryQueue = new RedeliveryQueueImpl(this);
    }
    if (null == idGenerator) {
        idGenerator = new DefaultSequenceIdentifierGenerator();
    }
    if (null != bus) {
        managedManager = new ManagedRMManager(this);
        instrumentationManager = bus.getExtension(InstrumentationManager.class);
        if (instrumentationManager != null) {
            try {
                instrumentationManager.register(managedManager);
            } catch (JMException jmex) {
                LOG.log(Level.WARNING, "Registering ManagedRMManager failed.", jmex);
            }
        }
    }
}
Also used : AcksPolicyType(org.apache.cxf.ws.rm.manager.AcksPolicyType) RedeliveryQueueImpl(org.apache.cxf.ws.rm.soap.RedeliveryQueueImpl) RetransmissionQueueImpl(org.apache.cxf.ws.rm.soap.RetransmissionQueueImpl) DeliveryAssurance(org.apache.cxf.ws.rm.RMConfiguration.DeliveryAssurance) JMException(javax.management.JMException) DestinationPolicyType(org.apache.cxf.ws.rm.manager.DestinationPolicyType) InstrumentationManager(org.apache.cxf.management.InstrumentationManager) PostConstruct(javax.annotation.PostConstruct)

Example 4 with DeliveryAssurance

use of org.apache.cxf.ws.rm.RMConfiguration.DeliveryAssurance in project cxf by apache.

the class DestinationSequence method applyDeliveryAssurance.

/**
 * Ensures that the delivery assurance is honored.
 * If the delivery assurance includes either AtLeastOnce or ExactlyOnce, combined with InOrder, this
 * queues out-of-order messages for processing after the missing messages have been received.
 *
 * @param mn message number
 * @return <code>true</code> if message processing to continue, <code>false</code> if to be dropped
 */
boolean applyDeliveryAssurance(long mn, Message message) {
    Continuation cont = getContinuation(message);
    RMConfiguration config = destination.getReliableEndpoint().getConfiguration();
    DeliveryAssurance da = config.getDeliveryAssurance();
    boolean canSkip = da != DeliveryAssurance.AT_LEAST_ONCE && da != DeliveryAssurance.EXACTLY_ONCE;
    boolean robust = false;
    boolean robustDelivering = false;
    boolean inOrder = mn - nextInOrder == 1;
    if (message != null) {
        robust = MessageUtils.getContextualBoolean(message, Message.ROBUST_ONEWAY);
        if (robust) {
            robustDelivering = PropertyUtils.isTrue(message.get(RMMessageConstants.DELIVERING_ROBUST_ONEWAY));
        }
    }
    if (robust && !robustDelivering) {
        // no check performed if in robust and not in delivering
        removeDeliveringMessageNumber(mn);
        if (inOrder) {
            nextInOrder++;
        }
        return true;
    }
    if (inOrder) {
        nextInOrder++;
    } else {
        // message out of order, schedule acknowledgement to update sender
        scheduleImmediateAcknowledgement();
        if (nextInOrder < mn) {
            nextInOrder = mn + 1;
        }
    }
    if (cont != null && config.isInOrder() && !cont.isNew()) {
        return waitInQueue(mn, canSkip, message, cont);
    }
    if ((da == DeliveryAssurance.EXACTLY_ONCE || da == DeliveryAssurance.AT_MOST_ONCE) && (isAcknowledged(mn) || (robustDelivering && deliveringMessageNumbers.contains(mn)))) {
        org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message("MESSAGE_ALREADY_DELIVERED_EXC", LOG, mn, getIdentifier().getValue());
        LOG.log(Level.INFO, msg.toString());
        return false;
    }
    if (robustDelivering) {
        addDeliveringMessageNumber(mn);
    }
    if (config.isInOrder()) {
        return waitInQueue(mn, canSkip, message, cont);
    }
    return true;
}
Also used : Continuation(org.apache.cxf.continuations.Continuation) Message(org.apache.cxf.message.Message) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) DeliveryAssurance(org.apache.cxf.ws.rm.RMConfiguration.DeliveryAssurance)

Aggregations

DeliveryAssurance (org.apache.cxf.ws.rm.RMConfiguration.DeliveryAssurance)4 PostConstruct (javax.annotation.PostConstruct)1 JMException (javax.management.JMException)1 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)1 Continuation (org.apache.cxf.continuations.Continuation)1 InstrumentationManager (org.apache.cxf.management.InstrumentationManager)1 Message (org.apache.cxf.message.Message)1 AcksPolicyType (org.apache.cxf.ws.rm.manager.AcksPolicyType)1 DestinationPolicyType (org.apache.cxf.ws.rm.manager.DestinationPolicyType)1 RMMessage (org.apache.cxf.ws.rm.persistence.RMMessage)1 RedeliveryQueueImpl (org.apache.cxf.ws.rm.soap.RedeliveryQueueImpl)1 RetransmissionQueueImpl (org.apache.cxf.ws.rm.soap.RetransmissionQueueImpl)1 Test (org.junit.Test)1