Search in sources :

Example 6 with Identifier

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

the class RedeliveryQueueImpl method cacheUndelivered.

/**
 * Accepts a new resend candidate.
 *
 * @param ctx the message context.
 * @return ResendCandidate
 */
protected RedeliverCandidate cacheUndelivered(Message message) {
    RMProperties rmps = RMContextUtils.retrieveRMProperties(message, false);
    SequenceType st = rmps.getSequence();
    Identifier sid = st.getIdentifier();
    String key = sid.getValue();
    RedeliverCandidate candidate = null;
    synchronized (this) {
        List<RedeliverCandidate> sequenceCandidates = getSequenceCandidates(key);
        if (null == sequenceCandidates) {
            sequenceCandidates = new ArrayList<>();
            candidates.put(key, sequenceCandidates);
        }
        candidate = getRedeliverCandidate(st, sequenceCandidates);
        if (candidate == null) {
            candidate = new RedeliverCandidate(message);
            if (isSequenceSuspended(key)) {
                candidate.suspend();
            }
            sequenceCandidates.add(candidate);
            undeliveredCount++;
        }
    }
    LOG.fine("Cached undelivered message.");
    return candidate;
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType) RMProperties(org.apache.cxf.ws.rm.RMProperties)

Example 7 with Identifier

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

the class RetransmissionQueueImpl method cacheUnacknowledged.

/**
 * Accepts a new resend candidate.
 *
 * @param ctx the message context.
 * @return ResendCandidate
 */
protected ResendCandidate cacheUnacknowledged(Message message) {
    RMProperties rmps = RMContextUtils.retrieveRMProperties(message, true);
    SequenceType st = rmps.getSequence();
    Identifier sid = st.getIdentifier();
    String key = sid.getValue();
    ResendCandidate candidate = null;
    synchronized (this) {
        List<ResendCandidate> sequenceCandidates = getSequenceCandidates(key);
        if (null == sequenceCandidates) {
            sequenceCandidates = new ArrayList<>();
            candidates.put(key, sequenceCandidates);
        }
        candidate = createResendCandidate(message);
        if (isSequenceSuspended(key)) {
            candidate.suspend();
        }
        sequenceCandidates.add(candidate);
        unacknowledgedCount++;
    }
    LOG.fine("Cached unacknowledged message.");
    try {
        RMEndpoint rme = manager.getReliableEndpoint(message);
        rme.handleAccept(key, st.getMessageNumber(), message);
    } catch (RMException e) {
        LOG.log(Level.WARNING, "Could not find reliable endpoint for message");
    }
    return candidate;
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType) RMEndpoint(org.apache.cxf.ws.rm.RMEndpoint) RMProperties(org.apache.cxf.ws.rm.RMProperties) RMException(org.apache.cxf.ws.rm.RMException)

Example 8 with Identifier

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

the class DestinationSequenceTest method testEqualsAndHashCode.

@Test
public void testEqualsAndHashCode() {
    DestinationSequence seq = new DestinationSequence(id, ref, destination, ProtocolVariation.RM10WSA200408);
    DestinationSequence otherSeq = null;
    assertTrue(!seq.equals(otherSeq));
    otherSeq = new DestinationSequence(id, ref, destination, ProtocolVariation.RM10WSA200408);
    assertEquals(seq, otherSeq);
    assertEquals(seq.hashCode(), otherSeq.hashCode());
    Identifier otherId = factory.createIdentifier();
    otherId.setValue("otherSeq");
    otherSeq = new DestinationSequence(otherId, ref, destination, ProtocolVariation.RM10WSA200408);
    assertTrue(!seq.equals(otherSeq));
    assertTrue(seq.hashCode() != otherSeq.hashCode());
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Test(org.junit.Test)

Example 9 with Identifier

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

the class DestinationTest method testAcknowledgeAlreadyAcknowledgedMessage.

@Test
public void testAcknowledgeAlreadyAcknowledgedMessage() throws SequenceFault, RMException, NoSuchMethodException, IOException {
    Method m1 = Destination.class.getDeclaredMethod("getSequence", new Class[] { Identifier.class });
    destination = EasyMock.createMockBuilder(Destination.class).addMockedMethod(m1).createMock(control);
    Message message = setupMessage();
    RMProperties rmps = control.createMock(RMProperties.class);
    EasyMock.expect(message.get(RMMessageConstants.RM_PROPERTIES_INBOUND)).andReturn(rmps);
    SequenceType st = control.createMock(SequenceType.class);
    EasyMock.expect(rmps.getSequence()).andReturn(st);
    Identifier id = control.createMock(Identifier.class);
    EasyMock.expect(st.getIdentifier()).andReturn(id);
    DestinationSequence ds = control.createMock(DestinationSequence.class);
    EasyMock.expect(destination.getSequence(id)).andReturn(ds);
    long nr = 10;
    EasyMock.expect(st.getMessageNumber()).andReturn(nr);
    ds.applyDeliveryAssurance(nr, message);
    EasyMock.expectLastCall().andReturn(false);
    InterceptorChain ic = control.createMock(InterceptorChain.class);
    EasyMock.expect(message.getInterceptorChain()).andReturn(ic);
    control.replay();
    destination.acknowledge(message);
}
Also used : InterceptorChain(org.apache.cxf.interceptor.InterceptorChain) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Message(org.apache.cxf.message.Message) Method(java.lang.reflect.Method) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType) Test(org.junit.Test)

Example 10 with Identifier

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

the class DestinationTest method testAcknowledgeUnknownSequence.

@Test
public void testAcknowledgeUnknownSequence() throws RMException, IOException {
    Message message = setupMessage();
    RMProperties rmps = control.createMock(RMProperties.class);
    EasyMock.expect(message.get(RMMessageConstants.RM_PROPERTIES_INBOUND)).andReturn(rmps);
    EasyMock.expect(RMContextUtils.getProtocolVariation(message)).andReturn(ProtocolVariation.RM10WSA200408);
    SequenceType st = control.createMock(SequenceType.class);
    EasyMock.expect(rmps.getSequence()).andReturn(st);
    Identifier id = control.createMock(Identifier.class);
    EasyMock.expect(st.getIdentifier()).andReturn(id).times(2);
    String sid = "sid";
    EasyMock.expect(id.getValue()).andReturn(sid);
    control.replay();
    try {
        destination.acknowledge(message);
        fail("Expected SequenceFault not thrown.");
    } catch (SequenceFault ex) {
        assertEquals(RM10Constants.UNKNOWN_SEQUENCE_FAULT_QNAME, ex.getFaultCode());
    }
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Message(org.apache.cxf.message.Message) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType) Test(org.junit.Test)

Aggregations

Identifier (org.apache.cxf.ws.rm.v200702.Identifier)72 Test (org.junit.Test)40 Message (org.apache.cxf.message.Message)14 ArrayList (java.util.ArrayList)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 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)10 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 SequenceType (org.apache.cxf.ws.rm.v200702.SequenceType)7 Method (java.lang.reflect.Method)6 Endpoint (org.apache.cxf.endpoint.Endpoint)6 Exchange (org.apache.cxf.message.Exchange)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