Search in sources :

Example 1 with CloseSequenceType

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

the class ServantTest method createTestCloseSequenceMessage.

private static Message createTestCloseSequenceMessage(String sidstr) {
    Message message = new MessageImpl();
    Exchange exchange = new ExchangeImpl();
    exchange.setInMessage(message);
    message.put(Message.REQUESTOR_ROLE, Boolean.FALSE);
    AddressingProperties maps = new AddressingProperties();
    String msgId = "urn:uuid:12345-" + Math.random();
    AttributedURIType id = ContextUtils.getAttributedURI(msgId);
    maps.setMessageID(id);
    maps.setAction(ContextUtils.getAttributedURI(RM10Constants.INSTANCE.getTerminateSequenceAction()));
    maps.setTo(ContextUtils.getAttributedURI(SERVICE_URL));
    maps.setReplyTo(RMUtils.createReference(DECOUPLED_URL));
    message.put(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND, maps);
    CloseSequenceType cs = new CloseSequenceType();
    org.apache.cxf.ws.rm.v200702.Identifier sid = new org.apache.cxf.ws.rm.v200702.Identifier();
    sid.setValue(sidstr);
    cs.setIdentifier(sid);
    MessageContentsList contents = new MessageContentsList();
    contents.add(cs);
    message.setContent(List.class, contents);
    RMContextUtils.setProtocolVariation(message, ProtocolVariation.RM11WSA200508);
    return message;
}
Also used : Message(org.apache.cxf.message.Message) MessageContentsList(org.apache.cxf.message.MessageContentsList) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) Exchange(org.apache.cxf.message.Exchange) Identifier(org.apache.cxf.ws.rm.v200502.Identifier) CloseSequenceType(org.apache.cxf.ws.rm.v200702.CloseSequenceType) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 2 with CloseSequenceType

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

the class EncoderDecoder10AImpl method decodeSequenceTypeCloseSequence.

public CloseSequenceType decodeSequenceTypeCloseSequence(Element elem) throws JAXBException {
    Unmarshaller unmarshaller = getContext().createUnmarshaller();
    JAXBElement<org.apache.cxf.ws.rm.v200502wsa15.SequenceType> jaxbElement = unmarshaller.unmarshal(elem, org.apache.cxf.ws.rm.v200502wsa15.SequenceType.class);
    org.apache.cxf.ws.rm.v200502wsa15.SequenceType seq = jaxbElement.getValue();
    if (seq.isSetLastMessage()) {
        CloseSequenceType close = new CloseSequenceType();
        close.setIdentifier(VersionTransformer.convert(seq.getIdentifier()));
        close.setLastMsgNumber(seq.getMessageNumber());
        return close;
    }
    return null;
}
Also used : CloseSequenceType(org.apache.cxf.ws.rm.v200702.CloseSequenceType) CreateSequenceType(org.apache.cxf.ws.rm.v200702.CreateSequenceType) TerminateSequenceType(org.apache.cxf.ws.rm.v200702.TerminateSequenceType) CloseSequenceType(org.apache.cxf.ws.rm.v200702.CloseSequenceType) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType) Unmarshaller(javax.xml.bind.Unmarshaller)

Example 3 with CloseSequenceType

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

the class EncoderDecoder10Impl method decodeSequenceTypeCloseSequence.

public CloseSequenceType decodeSequenceTypeCloseSequence(Element elem) throws JAXBException {
    Unmarshaller unmarshaller = getContext().createUnmarshaller();
    JAXBElement<org.apache.cxf.ws.rm.v200502.SequenceType> jaxbElement = unmarshaller.unmarshal(elem, org.apache.cxf.ws.rm.v200502.SequenceType.class);
    org.apache.cxf.ws.rm.v200502.SequenceType seq = jaxbElement.getValue();
    if (seq.isSetLastMessage()) {
        CloseSequenceType close = new CloseSequenceType();
        close.setIdentifier(VersionTransformer.convert(seq.getIdentifier()));
        close.setLastMsgNumber(seq.getMessageNumber());
        return close;
    }
    return null;
}
Also used : CloseSequenceType(org.apache.cxf.ws.rm.v200702.CloseSequenceType) CreateSequenceType(org.apache.cxf.ws.rm.v200702.CreateSequenceType) TerminateSequenceType(org.apache.cxf.ws.rm.v200702.TerminateSequenceType) CloseSequenceType(org.apache.cxf.ws.rm.v200702.CloseSequenceType) SequenceType(org.apache.cxf.ws.rm.v200702.SequenceType) Unmarshaller(javax.xml.bind.Unmarshaller)

Example 4 with CloseSequenceType

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

the class Proxy method lastMessage.

void lastMessage(SourceSequence s) throws RMException {
    final ProtocolVariation protocol = s.getProtocol();
    EndpointReferenceType target = s.getTarget();
    AttributedURIType uri = null;
    if (null != target) {
        uri = target.getAddress();
    }
    String addr = null;
    if (null != uri) {
        addr = uri.getValue();
    }
    if (addr == null) {
        LOG.log(Level.WARNING, "STANDALONE_CLOSE_SEQUENCE_NO_TARGET_MSG");
        return;
    }
    if (RMUtils.getAddressingConstants().getAnonymousURI().equals(addr)) {
        LOG.log(Level.WARNING, "STANDALONE_CLOSE_SEQUENCE_ANON_TARGET_MSG");
        return;
    }
    RMConstants constants = protocol.getConstants();
    OperationInfo oi = reliableEndpoint.getEndpoint(protocol).getEndpointInfo().getService().getInterface().getOperation(constants.getCloseSequenceOperationName());
    // pass reference to source sequence in invocation context
    Map<String, Object> context = new HashMap<>(Collections.singletonMap(SourceSequence.class.getName(), (Object) s));
    context.put(FaultListener.class.getName(), new FaultListener() {

        public boolean faultOccurred(Exception exception, String description, Message message) {
            if (exception.getCause() instanceof IOException) {
                // for close messages, the server may be gone and nothing we can do so don't pollute the logs
                LOG.log(Level.WARNING, "Could not send CloseSequence message: " + exception.getCause().getMessage());
                return false;
            }
            return true;
        }
    });
    try {
        if (constants instanceof RM11Constants) {
            CloseSequenceType csr = new CloseSequenceType();
            csr.setIdentifier(s.getIdentifier());
            csr.setLastMsgNumber(s.getCurrentMessageNr());
            invoke(oi, protocol, new Object[] { csr }, context, Level.FINER);
        } else {
            invoke(oi, protocol, new Object[] {}, context, Level.FINER);
        }
    } catch (Fault f) {
        throw new RMException(f);
    }
}
Also used : BindingOperationInfo(org.apache.cxf.service.model.BindingOperationInfo) OperationInfo(org.apache.cxf.service.model.OperationInfo) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) Message(org.apache.cxf.message.Message) HashMap(java.util.HashMap) AttributedURIType(org.apache.cxf.ws.addressing.AttributedURIType) FaultListener(org.apache.cxf.logging.FaultListener) Fault(org.apache.cxf.interceptor.Fault) IOException(java.io.IOException) IOException(java.io.IOException) CloseSequenceType(org.apache.cxf.ws.rm.v200702.CloseSequenceType)

Example 5 with CloseSequenceType

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

the class RMManager method recoverSourceSequence.

private void recoverSourceSequence(Endpoint endpoint, Conduit conduit, Source s, SourceSequence ss) {
    Collection<RMMessage> ms = store.getMessages(ss.getIdentifier(), true);
    if (null == ms || 0 == ms.size()) {
        store.removeSourceSequence(ss.getIdentifier());
        return;
    }
    LOG.log(Level.FINE, "Number of messages in sequence: {0}", ms.size());
    // only recover the sequence if there are pending messages
    s.addSequence(ss, false);
    // choosing an arbitrary valid source sequence as the current source sequence
    if (s.getAssociatedSequence(null) == null && !ss.isExpired() && !ss.isLastMessage()) {
        s.setCurrent(ss);
    }
    // make sure this is associated with the offering id
    s.setCurrent(ss.getOfferingSequenceIdentifier(), ss);
    for (RMMessage m : ms) {
        Message message = new MessageImpl();
        Exchange exchange = new ExchangeImpl();
        message.setExchange(exchange);
        exchange.setOutMessage(message);
        if (null != conduit) {
            exchange.setConduit(conduit);
            message.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
        }
        exchange.put(Endpoint.class, endpoint);
        exchange.put(Service.class, endpoint.getService());
        exchange.put(Binding.class, endpoint.getBinding());
        exchange.put(Bus.class, bus);
        SequenceType st = new SequenceType();
        st.setIdentifier(ss.getIdentifier());
        st.setMessageNumber(m.getMessageNumber());
        RMProperties rmps = new RMProperties();
        rmps.setSequence(st);
        rmps.setCreatedTime(m.getCreatedTime());
        rmps.exposeAs(ss.getProtocol().getWSRMNamespace());
        if (ss.isLastMessage() && ss.getCurrentMessageNr() == m.getMessageNumber()) {
            CloseSequenceType close = new CloseSequenceType();
            close.setIdentifier(ss.getIdentifier());
            rmps.setCloseSequence(close);
        }
        RMContextUtils.storeRMProperties(message, rmps, true);
        if (null == conduit) {
            String to = m.getTo();
            AddressingProperties maps = new AddressingProperties();
            maps.setTo(RMUtils.createReference(to));
            RMContextUtils.storeMAPs(maps, message, true, 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);
            RMContextUtils.setProtocolVariation(message, ss.getProtocol());
            retransmissionQueue.addUnacknowledged(message);
        } catch (IOException e) {
            LOG.log(Level.SEVERE, "Error reading persisted message data", e);
        }
    }
}
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) AddressingProperties(org.apache.cxf.ws.addressing.AddressingProperties) 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)

Aggregations

CloseSequenceType (org.apache.cxf.ws.rm.v200702.CloseSequenceType)6 Message (org.apache.cxf.message.Message)4 AddressingProperties (org.apache.cxf.ws.addressing.AddressingProperties)3 SequenceType (org.apache.cxf.ws.rm.v200702.SequenceType)3 IOException (java.io.IOException)2 Unmarshaller (javax.xml.bind.Unmarshaller)2 Exchange (org.apache.cxf.message.Exchange)2 ExchangeImpl (org.apache.cxf.message.ExchangeImpl)2 MessageImpl (org.apache.cxf.message.MessageImpl)2 AttributedURIType (org.apache.cxf.ws.addressing.AttributedURIType)2 CreateSequenceType (org.apache.cxf.ws.rm.v200702.CreateSequenceType)2 TerminateSequenceType (org.apache.cxf.ws.rm.v200702.TerminateSequenceType)2 HashMap (java.util.HashMap)1 Fault (org.apache.cxf.interceptor.Fault)1 FaultListener (org.apache.cxf.logging.FaultListener)1 MessageContentsList (org.apache.cxf.message.MessageContentsList)1 BindingOperationInfo (org.apache.cxf.service.model.BindingOperationInfo)1 OperationInfo (org.apache.cxf.service.model.OperationInfo)1 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)1 RMMessage (org.apache.cxf.ws.rm.persistence.RMMessage)1