Search in sources :

Example 26 with Identifier

use of org.geotoolkit.sml.xml.v101.Identifier in project cxf by apache.

the class RetransmissionQueueImpl method cacheUnacknowledged.

/**
 * Accepts a new resend candidate.
 *
 * @param message the message object.
 * @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();
    final ResendCandidate candidate;
    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 27 with Identifier

use of org.geotoolkit.sml.xml.v101.Identifier in project cxf by apache.

the class RedeliveryQueueImpl method cacheUndelivered.

/**
 * Accepts a new resend candidate.
 *
 * @param message the message.
 * @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;
    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 28 with Identifier

use of org.geotoolkit.sml.xml.v101.Identifier in project cxf by apache.

the class RedeliveryQueueImpl method purgeDelivered.

protected void purgeDelivered(RedeliverCandidate candidate) {
    RMProperties rmps = RMContextUtils.retrieveRMProperties(candidate.getMessage(), false);
    SequenceType st = rmps.getSequence();
    Identifier sid = st.getIdentifier();
    String key = sid.getValue();
    synchronized (this) {
        List<RedeliverCandidate> sequenceCandidates = getSequenceCandidates(key);
        if (null != sequenceCandidates) {
            // TODO use a constant op instead of this inefficient linear op
            sequenceCandidates.remove(candidate);
            undeliveredCount--;
        }
        if (sequenceCandidates.isEmpty()) {
            candidates.remove(sid.getValue());
        }
    }
    LOG.fine("Purged delivered message.");
}
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 29 with Identifier

use of org.geotoolkit.sml.xml.v101.Identifier in project cxf by apache.

the class RMEndpointTest method testShutdown.

@Test
public void testShutdown() {
    DestinationSequence ds = control.createMock(DestinationSequence.class);
    Identifier did = control.createMock(Identifier.class);
    EasyMock.expect(ds.getIdentifier()).andReturn(did).anyTimes();
    EasyMock.expect(ds.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
    String d = "d";
    EasyMock.expect(did.getValue()).andReturn(d).anyTimes();
    SourceSequence ss = control.createMock(SourceSequence.class);
    Identifier sid = control.createMock(Identifier.class);
    EasyMock.expect(ss.getIdentifier()).andReturn(sid).anyTimes();
    EasyMock.expect(ss.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
    String s = "s";
    EasyMock.expect(sid.getValue()).andReturn(s).anyTimes();
    ds.cancelDeferredAcknowledgments();
    EasyMock.expectLastCall().anyTimes();
    ds.cancelTermination();
    EasyMock.expectLastCall().anyTimes();
    RetransmissionQueue queue = control.createMock(RetransmissionQueue.class);
    EasyMock.expect(manager.getRetransmissionQueue()).andReturn(queue).anyTimes();
    queue.stop(ss);
    EasyMock.expectLastCall().anyTimes();
    RedeliveryQueue dqueue = control.createMock(RedeliveryQueue.class);
    EasyMock.expect(manager.getRedeliveryQueue()).andReturn(dqueue).anyTimes();
    dqueue.stop(ds);
    EasyMock.expectLastCall().anyTimes();
    control.replay();
    rme.getDestination().addSequence(ds, false);
    rme.getSource().addSequence(ss, false);
    rme.shutdown();
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) Test(org.junit.Test)

Example 30 with Identifier

use of org.geotoolkit.sml.xml.v101.Identifier in project cxf by apache.

the class RMOutInterceptorTest method testHandleApplicationMessage.

@Test
public void testHandleApplicationMessage() throws NoSuchMethodException, SequenceFault, RMException {
    AddressingProperties maps = createMAPs("greetMe", "localhost:9000/GreeterPort", org.apache.cxf.ws.addressing.Names.WSA_NONE_ADDRESS);
    Method[] mocked = new Method[] { AbstractRMInterceptor.class.getDeclaredMethod("getManager", new Class[] {}), RMOutInterceptor.class.getDeclaredMethod("isRuntimeFault", new Class[] { Message.class }), RMOutInterceptor.class.getDeclaredMethod("addAcknowledgements", new Class[] { Destination.class, RMProperties.class, Identifier.class, AttributedURIType.class }) };
    RMOutInterceptor interceptor = EasyMock.createMockBuilder(RMOutInterceptor.class).addMockedMethods(mocked).createMock(control);
    RMManager manager = control.createMock(RMManager.class);
    EasyMock.expect(interceptor.getManager()).andReturn(manager).anyTimes();
    Message message = control.createMock(Message.class);
    EasyMock.expect(interceptor.isRuntimeFault(message)).andReturn(false).anyTimes();
    Exchange ex = control.createMock(Exchange.class);
    EasyMock.expect(message.getExchange()).andReturn(ex).anyTimes();
    EasyMock.expect(ex.getOutMessage()).andReturn(message).anyTimes();
    EasyMock.expect(ex.put("defer.uncorrelated.message.abort", Boolean.TRUE)).andReturn(null).anyTimes();
    EasyMock.expect(message.get(Message.REQUESTOR_ROLE)).andReturn(Boolean.TRUE).anyTimes();
    EasyMock.expect(message.get(JAXWSAConstants.ADDRESSING_PROPERTIES_OUTBOUND)).andReturn(maps).anyTimes();
    RMProperties rmpsOut = new RMProperties();
    EasyMock.expect(message.get(RMMessageConstants.RM_PROPERTIES_OUTBOUND)).andReturn(rmpsOut).anyTimes();
    InterceptorChain chain = control.createMock(InterceptorChain.class);
    EasyMock.expect(message.getInterceptorChain()).andReturn(chain).anyTimes();
    EasyMock.expectLastCall();
    RMEndpoint rme = control.createMock(RMEndpoint.class);
    RMConfiguration config = new RMConfiguration();
    config.setRMNamespace(RM10Constants.NAMESPACE_URI);
    config.setRM10AddressingNamespace(Names200408.WSA_NAMESPACE_NAME);
    EasyMock.expect(rme.getConfiguration()).andReturn(config).anyTimes();
    EasyMock.expect(manager.getEffectiveConfiguration(message)).andReturn(config).anyTimes();
    Source source = control.createMock(Source.class);
    EasyMock.expect(source.getReliableEndpoint()).andReturn(rme).anyTimes();
    EasyMock.expect(manager.getSource(message)).andReturn(source).anyTimes();
    Destination destination = control.createMock(Destination.class);
    EasyMock.expect(manager.getDestination(message)).andReturn(destination).anyTimes();
    SourceSequence sseq = control.createMock(SourceSequence.class);
    EasyMock.expect(sseq.getProtocol()).andReturn(ProtocolVariation.RM10WSA200408).anyTimes();
    EasyMock.expect(manager.getSequence((Identifier) EasyMock.isNull(), EasyMock.same(message), EasyMock.same(maps))).andReturn(sseq).anyTimes();
    EasyMock.expect(sseq.nextMessageNumber((Identifier) EasyMock.isNull(), (Long) EasyMock.eq(0L), EasyMock.eq(false))).andReturn(Long.valueOf(10)).anyTimes();
    EasyMock.expect(sseq.isLastMessage()).andReturn(false).anyTimes();
    interceptor.addAcknowledgements(EasyMock.same(destination), EasyMock.same(rmpsOut), (Identifier) EasyMock.isNull(), EasyMock.isA(AttributedURIType.class));
    EasyMock.expectLastCall();
    Identifier sid = control.createMock(Identifier.class);
    EasyMock.expect(sseq.getIdentifier()).andReturn(sid).anyTimes();
    EasyMock.expect(sseq.getCurrentMessageNr()).andReturn(Long.valueOf(10)).anyTimes();
    control.replay();
    interceptor.handle(message);
    control.verify();
}
Also used : Message(org.apache.cxf.message.Message) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) Method(java.lang.reflect.Method) Exchange(org.apache.cxf.message.Exchange) InterceptorChain(org.apache.cxf.interceptor.InterceptorChain) Identifier(org.apache.cxf.ws.rm.v200702.Identifier) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) Test(org.junit.Test)

Aggregations

Identifier (org.apache.cxf.ws.rm.v200702.Identifier)72 Test (org.junit.Test)43 ArrayList (java.util.ArrayList)13 Message (org.apache.cxf.message.Message)11 SourceSequence (org.apache.cxf.ws.rm.SourceSequence)11 RMMessage (org.apache.cxf.ws.rm.persistence.RMMessage)11 SequenceAcknowledgement (org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)11 Connection (java.sql.Connection)9 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)8 SQLException (java.sql.SQLException)7 Date (java.util.Date)7 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)7 DestinationSequence (org.apache.cxf.ws.rm.DestinationSequence)7 InputStream (java.io.InputStream)6 Method (java.lang.reflect.Method)6 AttributedURIType (org.apache.cxf.ws.addressing.AttributedURIType)6 RMStore (org.apache.cxf.ws.rm.persistence.RMStore)6 SequenceType (org.apache.cxf.ws.rm.v200702.SequenceType)6 JAXBElement (javax.xml.bind.JAXBElement)5 SoapBinding (org.apache.cxf.binding.soap.SoapBinding)5