Search in sources :

Example 1 with SourcePolicyType

use of org.apache.cxf.ws.rm.manager.SourcePolicyType 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 SourcePolicyType

use of org.apache.cxf.ws.rm.manager.SourcePolicyType 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 SourcePolicyType

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

the class RMOutInterceptor method addAckRequest.

/**
 * Add AcknowledgementRequested to message if needed. The AckRequest mode set either in the message
 * properties or in the source policy is used to determine whether AcknowledgementRequested is always
 * added, never added, or added only when we're waiting for the acknowledgement to a previously-sent
 * message.
 *
 * @param msg
 * @param rmpsIn
 * @param seq
 * @param sequence
 */
protected void addAckRequest(Message msg, RMProperties rmpsIn, SourceSequence seq, SequenceType sequence) {
    AckRequestModeType mode = (AckRequestModeType) msg.get(RMMessageConstants.ACK_REQUEST_MODE);
    if (mode == null) {
        mode = AckRequestModeType.PENDING;
        SourcePolicyType policy = getManager().getSourcePolicy();
        if (policy.isSetAckRequestMode()) {
            mode = policy.getAckRequestMode();
        }
    }
    if (AckRequestModeType.ALWAYS == mode || (mode == AckRequestModeType.PENDING && seq.needAcknowledge(rmpsIn.getMessageNumber()))) {
        Collection<AckRequestedType> reqs = rmpsIn.getAcksRequested();
        if (reqs == null) {
            reqs = new ArrayList<>();
        }
        Identifier identifier = new Identifier();
        identifier.setValue(sequence.getIdentifier().getValue());
        AckRequestedType ackRequest = new AckRequestedType();
        ackRequest.setIdentifier(identifier);
        reqs.add(ackRequest);
        rmpsIn.setAcksRequested(reqs);
    }
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) AckRequestModeType(org.apache.cxf.ws.rm.manager.AckRequestModeType) SourcePolicyType(org.apache.cxf.ws.rm.manager.SourcePolicyType) AckRequestedType(org.apache.cxf.ws.rm.v200702.AckRequestedType)

Example 4 with SourcePolicyType

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

the class RetransmissionQueueImplTest method setupRetryPolicy.

private void setupRetryPolicy(Message message) {
    SourcePolicyType spt = control.createMock(SourcePolicyType.class);
    EasyMock.expect(manager.getSourcePolicy()).andReturn(spt).anyTimes();
    RetryPolicyType rpt = control.createMock(RetryPolicyType.class);
    EasyMock.expect(spt.getRetryPolicy()).andReturn(rpt);
    EasyMock.expect(rpt.getMaxRetries()).andReturn(3);
}
Also used : SourcePolicyType(org.apache.cxf.ws.rm.manager.SourcePolicyType) RetryPolicyType(org.apache.cxf.ws.rm.manager.RetryPolicyType)

Example 5 with SourcePolicyType

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

the class Proxy method createSequence.

public CreateSequenceResponseType createSequence(EndpointReferenceType defaultAcksTo, RelatesToType relatesTo, boolean isServer, final ProtocolVariation protocol, final Exchange exchange, Map<String, Object> context) throws RMException {
    this.sequenceContext = context;
    SourcePolicyType sp = reliableEndpoint.getManager().getSourcePolicy();
    CreateSequenceType create = new CreateSequenceType();
    String address = sp.getAcksTo();
    EndpointReferenceType acksTo = null;
    if (null != address) {
        acksTo = RMUtils.createReference(address);
    } else {
        acksTo = defaultAcksTo;
    }
    create.setAcksTo(acksTo);
    Duration d = sp.getSequenceExpiration();
    if (null != d) {
        Expires expires = new Expires();
        expires.setValue(d);
        create.setExpires(expires);
    }
    if (sp.isIncludeOffer()) {
        OfferType offer = new OfferType();
        d = sp.getOfferedSequenceExpiration();
        if (null != d) {
            Expires expires = new Expires();
            expires.setValue(d);
            offer.setExpires(expires);
        }
        offer.setIdentifier(reliableEndpoint.getSource().generateSequenceIdentifier());
        offer.setEndpoint(acksTo);
        create.setOffer(offer);
        setOfferedIdentifier(offer);
    }
    InterfaceInfo ii = reliableEndpoint.getEndpoint(protocol).getEndpointInfo().getService().getInterface();
    EncoderDecoder codec = protocol.getCodec();
    RMConstants constants = codec.getConstants();
    final OperationInfo oi = isServer ? ii.getOperation(constants.getCreateSequenceOnewayOperationName()) : ii.getOperation(constants.getCreateSequenceOperationName());
    final Object send = codec.convertToSend(create);
    if (isServer) {
        LOG.fine("sending CreateSequenceRequest from server side");
        Runnable r = new Runnable() {

            public void run() {
                try {
                    invoke(oi, protocol, new Object[] { send }, null, exchange);
                } catch (RMException ex) {
                // already logged
                }
            }
        };
        Executor ex = reliableEndpoint.getApplicationEndpoint().getExecutor();
        if (ex == null) {
            ex = SynchronousExecutor.getInstance();
        }
        ex.execute(r);
        return null;
    }
    Object resp = invoke(oi, protocol, new Object[] { send }, context, exchange);
    return codec.convertReceivedCreateSequenceResponse(resp);
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) Duration(javax.xml.datatype.Duration) OfferType(org.apache.cxf.ws.rm.v200702.OfferType) Executor(java.util.concurrent.Executor) SynchronousExecutor(org.apache.cxf.workqueue.SynchronousExecutor) CreateSequenceType(org.apache.cxf.ws.rm.v200702.CreateSequenceType) SourcePolicyType(org.apache.cxf.ws.rm.manager.SourcePolicyType) Expires(org.apache.cxf.ws.rm.v200702.Expires) InterfaceInfo(org.apache.cxf.service.model.InterfaceInfo)

Aggregations

SourcePolicyType (org.apache.cxf.ws.rm.manager.SourcePolicyType)9 SequenceTerminationPolicyType (org.apache.cxf.ws.rm.manager.SequenceTerminationPolicyType)4 Test (org.junit.Test)3 Date (java.util.Date)2 Duration (javax.xml.datatype.Duration)2 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)2 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)2 InterfaceInfo (org.apache.cxf.service.model.InterfaceInfo)2 OperationInfo (org.apache.cxf.service.model.OperationInfo)2 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)2 DestinationPolicyType (org.apache.cxf.ws.rm.manager.DestinationPolicyType)2 RetryPolicyType (org.apache.cxf.ws.rm.manager.RetryPolicyType)2 Identifier (org.apache.cxf.ws.rm.v200702.Identifier)2 Method (java.lang.reflect.Method)1 HashMap (java.util.HashMap)1 Executor (java.util.concurrent.Executor)1 Bus (org.apache.cxf.Bus)1 Endpoint (org.apache.cxf.endpoint.Endpoint)1 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)1 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)1