Search in sources :

Example 61 with Identifier

use of org.apache.cxf.ws.rm.v200702.Identifier in project cxf by apache.

the class RMCaptureOutInterceptor method setTerminateSequence.

private void setTerminateSequence(Message msg, Identifier identifier, ProtocolVariation protocol) throws RMException {
    TerminateSequenceType ts = new TerminateSequenceType();
    ts.setIdentifier(identifier);
    MessageContentsList contents = new MessageContentsList(new Object[] { protocol.getCodec().convertToSend(ts) });
    msg.setContent(List.class, contents);
    // create a new exchange for this output-only exchange
    Exchange newex = new ExchangeImpl();
    Exchange oldex = msg.getExchange();
    newex.put(Bus.class, oldex.getBus());
    newex.put(Endpoint.class, oldex.getEndpoint());
    newex.put(Service.class, oldex.getEndpoint().getService());
    newex.put(Binding.class, oldex.getEndpoint().getBinding());
    newex.setConduit(oldex.getConduit(msg));
    newex.setDestination(oldex.getDestination());
    // Setup the BindingOperationInfo
    RMEndpoint rmep = getManager().getReliableEndpoint(msg);
    OperationInfo oi = rmep.getEndpoint(protocol).getEndpointInfo().getService().getInterface().getOperation(protocol.getConstants().getTerminateSequenceAnonymousOperationName());
    BindingInfo bi = rmep.getBindingInfo(protocol);
    BindingOperationInfo boi = bi.getOperation(oi);
    newex.put(BindingInfo.class, bi);
    newex.put(BindingOperationInfo.class, boi);
    msg.setExchange(newex);
    newex.setOutMessage(msg);
}
Also used : Exchange(org.apache.cxf.message.Exchange) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) MessageContentsList(org.apache.cxf.message.MessageContentsList) BindingInfo(org.apache.cxf.service.model.BindingInfo) TerminateSequenceType(org.apache.cxf.ws.rm.v200702.TerminateSequenceType) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 62 with Identifier

use of org.apache.cxf.ws.rm.v200702.Identifier in project cxf by apache.

the class RetransmissionQueueImpl method purgeCandidates.

private void purgeCandidates(SourceSequence seq, boolean any) {
    Collection<Long> purged = new ArrayList<>();
    Collection<ResendCandidate> resends = new ArrayList<>();
    Identifier sid = seq.getIdentifier();
    synchronized (this) {
        LOG.fine("Start purging resend candidates.");
        List<ResendCandidate> sequenceCandidates = getSequenceCandidates(seq);
        if (null != sequenceCandidates) {
            for (int i = sequenceCandidates.size() - 1; i >= 0; i--) {
                ResendCandidate candidate = sequenceCandidates.get(i);
                long m = candidate.getNumber();
                if (any || seq.isAcknowledged(m)) {
                    sequenceCandidates.remove(i);
                    candidate.resolved();
                    unacknowledgedCount--;
                    purged.add(m);
                    resends.add(candidate);
                }
            }
            if (sequenceCandidates.isEmpty()) {
                candidates.remove(sid.getValue());
            }
        }
        LOG.fine("Completed purging resend candidates.");
    }
    if (!purged.isEmpty()) {
        RMStore store = manager.getStore();
        if (null != store) {
            store.removeMessages(sid, purged, true);
        }
        RMEndpoint rmEndpoint = seq.getSource().getReliableEndpoint();
        for (ResendCandidate resend : resends) {
            rmEndpoint.handleAcknowledgment(sid.getValue(), resend.getNumber(), resend.getMessage());
        }
    }
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) ArrayList(java.util.ArrayList) RMStore(org.apache.cxf.ws.rm.persistence.RMStore) RMEndpoint(org.apache.cxf.ws.rm.RMEndpoint) RMEndpoint(org.apache.cxf.ws.rm.RMEndpoint) Endpoint(org.apache.cxf.endpoint.Endpoint)

Example 63 with Identifier

use of org.apache.cxf.ws.rm.v200702.Identifier in project cxf by apache.

the class DestinationSequenceTest method testConstructors.

@Test
public void testConstructors() {
    Identifier otherId = factory.createIdentifier();
    otherId.setValue("otherSeq");
    DestinationSequence seq = new DestinationSequence(id, ref, destination, ProtocolVariation.RM10WSA200408);
    assertEquals(id, seq.getIdentifier());
    assertEquals(0L, seq.getLastMessageNumber());
    assertSame(ref, seq.getAcksTo());
    assertNotNull(seq.getAcknowledgment());
    assertNotNull(seq.getMonitor());
    SequenceAcknowledgement ack = new SequenceAcknowledgement();
    seq = new DestinationSequence(id, ref, 10L, ack, ProtocolVariation.RM10WSA200408);
    assertEquals(id, seq.getIdentifier());
    assertEquals(10L, seq.getLastMessageNumber());
    assertSame(ref, seq.getAcksTo());
    assertSame(ack, seq.getAcknowledgment());
    assertNotNull(seq.getMonitor());
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement) Test(org.junit.Test)

Example 64 with Identifier

use of org.apache.cxf.ws.rm.v200702.Identifier in project cxf by apache.

the class ManagedRMManagerTest method createTestDestinationSequence.

private DestinationSequence createTestDestinationSequence(Destination destination, String sid, EndpointReferenceType to, ProtocolVariation protocol, long[] acked) {
    Identifier identifier = RMUtils.getWSRMFactory().createIdentifier();
    identifier.setValue(sid);
    DestinationSequence ds = new DestinationSequence(identifier, to, null, protocol);
    ds.setDestination(destination);
    List<SequenceAcknowledgement.AcknowledgementRange> ranges = ds.getAcknowledgment().getAcknowledgementRange();
    for (int i = 0; i < acked.length; i += 2) {
        ranges.add(createAcknowledgementRange(acked[i], acked[i + 1]));
    }
    return ds;
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Endpoint(org.apache.cxf.endpoint.Endpoint)

Example 65 with Identifier

use of org.apache.cxf.ws.rm.v200702.Identifier in project cxf by apache.

the class RMTxStoreTestBase method testGetSourceSequence.

@Test
public void testGetSourceSequence() throws SQLException, IOException {
    Identifier sid1 = null;
    Identifier sid2 = null;
    SourceSequence seq = store.getSourceSequence(new Identifier());
    assertNull(seq);
    try {
        sid1 = setupSourceSequence("sequence1");
        seq = store.getSourceSequence(sid1);
        assertNotNull(seq);
        verifySourceSequence("sequence1", seq);
        sid2 = setupSourceSequence("sequence2");
        seq = store.getSourceSequence(sid2);
        assertNotNull(seq);
        verifySourceSequence("sequence2", seq);
    } finally {
        if (null != sid1) {
            store.removeSourceSequence(sid1);
        }
        if (null != sid2) {
            store.removeSourceSequence(sid2);
        }
    }
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) SourceSequence(org.apache.cxf.ws.rm.SourceSequence) Test(org.junit.Test)

Aggregations

Identifier (org.apache.cxf.ws.rm.v200702.Identifier)72 Test (org.junit.Test)43 Message (org.apache.cxf.message.Message)13 RMMessage (org.apache.cxf.ws.rm.persistence.RMMessage)13 SequenceAcknowledgement (org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)13 SourceSequence (org.apache.cxf.ws.rm.SourceSequence)11 Connection (java.sql.Connection)10 ArrayList (java.util.ArrayList)9 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)9 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)9 SQLException (java.sql.SQLException)8 DestinationSequence (org.apache.cxf.ws.rm.DestinationSequence)8 Date (java.util.Date)7 Method (java.lang.reflect.Method)6 Endpoint (org.apache.cxf.endpoint.Endpoint)6 AttributedURIType (org.apache.cxf.ws.addressing.AttributedURIType)6 ProtocolVariation (org.apache.cxf.ws.rm.ProtocolVariation)6 RMStore (org.apache.cxf.ws.rm.persistence.RMStore)6 SequenceType (org.apache.cxf.ws.rm.v200702.SequenceType)6 PreparedStatement (java.sql.PreparedStatement)5