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());
}
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);
}
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);
}
}
}
}
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;
}
Aggregations