Search in sources :

Example 16 with SequenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType 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 17 with SequenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType 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 18 with SequenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType 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)

Example 19 with SequenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType in project cxf by apache.

the class RMManager method recoverDestinationSequence.

private void recoverDestinationSequence(Endpoint endpoint, Conduit conduit, Destination d, DestinationSequence ds) {
    // always recover the sequence
    d.addSequence(ds, false);
    Collection<RMMessage> ms = store.getMessages(ds.getIdentifier(), false);
    if (null == ms || 0 == ms.size()) {
        return;
    }
    LOG.log(Level.FINE, "Number of messages in sequence: {0}", ms.size());
    for (RMMessage m : ms) {
        Message message = new MessageImpl();
        Exchange exchange = new ExchangeImpl();
        message.setExchange(exchange);
        if (null != conduit) {
            exchange.setConduit(conduit);
        }
        exchange.put(Endpoint.class, endpoint);
        exchange.put(Service.class, endpoint.getService());
        if (endpoint.getEndpointInfo().getService() != null) {
            exchange.put(ServiceInfo.class, endpoint.getEndpointInfo().getService());
            exchange.put(InterfaceInfo.class, endpoint.getEndpointInfo().getService().getInterface());
        }
        exchange.put(Binding.class, endpoint.getBinding());
        exchange.put(BindingInfo.class, endpoint.getEndpointInfo().getBinding());
        exchange.put(Bus.class, bus);
        SequenceType st = new SequenceType();
        st.setIdentifier(ds.getIdentifier());
        st.setMessageNumber(m.getMessageNumber());
        RMProperties rmps = new RMProperties();
        rmps.setSequence(st);
        rmps.setCreatedTime(m.getCreatedTime());
        RMContextUtils.storeRMProperties(message, rmps, false);
        try {
            // RMMessage is stored in a serialized way, therefore
            // RMMessage content must be splitted into soap root message
            // and attachments
            PersistenceUtils.decodeRMContent(m, message);
            redeliveryQueue.addUndelivered(message);
            // add acknowledged undelivered message
            ds.addDeliveringMessageNumber(m.getMessageNumber());
        } catch (IOException e) {
            LOG.log(Level.SEVERE, "Error reading persisted message data", e);
        }
    }
    // if no messages are recovered and the sequence has been already terminated, remove the sequence
    if (ds.isTerminated() && ds.allAcknowledgedMessagesDelivered()) {
        d.removeSequence(ds);
        store.removeDestinationSequence(ds.getIdentifier());
    }
}
Also used : Exchange(org.apache.cxf.message.Exchange) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) Message(org.apache.cxf.message.Message) RMMessage(org.apache.cxf.ws.rm.persistence.RMMessage) CloseSequenceType(org.apache.cxf.ws.rm.v200702.CloseSequenceType) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType) IOException(java.io.IOException) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 20 with SequenceType

use of com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType in project cxf by apache.

the class VersionTransformer method convert.

/**
 * Convert 200502 wsrm:SequenceType with 200508 WS-Addressing namespace to internal form.
 *
 * @param exposed (non-<code>null</code>)
 * @return converted
 */
public static SequenceType convert(org.apache.cxf.ws.rm.v200502wsa15.SequenceType exposed) {
    SequenceType internal = new SequenceType();
    internal.setIdentifier(convert(exposed.getIdentifier()));
    internal.setMessageNumber(exposed.getMessageNumber());
    addAll(exposed.getAny(), internal.getAny());
    putAll(exposed.getOtherAttributes(), internal.getOtherAttributes());
    return internal;
}
Also used : CreateSequenceType(org.apache.cxf.ws.rm.v200702.CreateSequenceType) TerminateSequenceType(org.apache.cxf.ws.rm.v200702.TerminateSequenceType) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType)

Aggregations

SequenceType (org.apache.cxf.ws.rm.v200702.SequenceType)33 CloseSequenceType (org.apache.cxf.ws.rm.v200702.CloseSequenceType)12 RMProperties (org.apache.cxf.ws.rm.RMProperties)11 CreateSequenceType (org.apache.cxf.ws.rm.v200702.CreateSequenceType)11 TerminateSequenceType (org.apache.cxf.ws.rm.v200702.TerminateSequenceType)11 Message (org.apache.cxf.message.Message)8 Identifier (org.apache.cxf.ws.rm.v200702.Identifier)7 SequenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.SequenceType)6 IOException (java.io.IOException)6 Unmarshaller (javax.xml.bind.Unmarshaller)5 AckRequestedType (org.apache.cxf.ws.rm.v200702.AckRequestedType)5 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)4 Endpoint (org.apache.cxf.endpoint.Endpoint)4 Exchange (org.apache.cxf.message.Exchange)4 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)4 SequenceAcknowledgement (org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)4 Test (org.junit.Test)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 SystemException (com.evolveum.midpoint.util.exception.SystemException)3 File (java.io.File)3