Package org.servicemix.ws.xmlbeans.rm

Examples of org.servicemix.ws.xmlbeans.rm.SequenceType


        String identifier = terminateSequence.getIdentifier().getStringValue();
        sequenceStore.delete(identifier);
    }

    public SequenceAcknowledgementDocument assertValid(SequenceDocument doc) {
        SequenceType sequence = doc.getSequence();
        String identifier = sequence.getIdentifier().getStringValue();
        Sequence s = sequenceStore.retrieve(identifier);
       
        if( s == null ) {
            throw new SoapFault(
                    "The value of wsrm:Identifier is not a known Sequence identifier",
                    "Sender",
                    "wsrm:UnknownSequence",
                    sequence.getIdentifier().xmlText());
        }
       
        // Is the message number out of range?
        BigInteger value = sequence.getMessageNumber();
        if( value.compareTo(BigInteger.ZERO) <= 0 || value.compareTo(MAX_INTEGER)>0 ) {
           
            // We must terminate the sequence now.
            sequenceStore.delete(identifier);
           
            throw new SoapFault(
                    "The maximum value for wsrm:MessageNumber has been exceeded",
                    "Sender",
                    "wsrm:MessageNumberRollover",
                    sequence.getIdentifier().xmlText());
        }
       
        int intValue = value.intValue();
       
        // If we received the last message, then check to see if the message being
        // processed exceeds it's sequence.
        if( s.lastMessageNumber>0 && intValue > s.lastMessageNumber) {
            throw new SoapFault(
                    "The value for wsrm:MessageNumber exceeds the value of the MessageNumber  accompanying a LastMessage element in this Sequence.",
                    "Sender",
                    "wsrm:LastMessageNumberExceeded",
                    sequence.getIdentifier().xmlText());
        }
       
        // Is this message comming out of order??       
        if( intValue!=s.lastMessageAcked+1) {
            // This implementation is really simple and just drops out of order
            // messages.
           
            SequenceAcknowledgementDocument resultDoc = SequenceAcknowledgementDocument.Factory.newInstance();
            SequenceAcknowledgement acknowledgement = resultDoc.addNewSequenceAcknowledgement();
            acknowledgement.setIdentifier(sequence.getIdentifier());
            if( s.lastMessageAcked> 0 ) {
                AcknowledgementRange range = acknowledgement.addNewAcknowledgementRange();
                range.setLower(BigInteger.ONE);
                range.setUpper(new BigInteger(""+s.lastMessageAcked));
            }
View Full Code Here


        return null;
    }

    public SequenceAcknowledgementDocument acknowledge(SequenceDocument doc) {
       
        SequenceType sequence = doc.getSequence();
        String identifier = sequence.getIdentifier().getStringValue();
       
        // We might need something like a retrieve for update so that
        // we can lock this record across a cluster
        Sequence s = sequenceStore.retrieve(identifier);
       
        int value = sequence.getMessageNumber().intValue();
        s.lastMessageAcked = value;
        if( sequence.isSetLastMessage() ) {
            s.lastMessageNumber = value;
        }
       
        sequenceStore.update(s);
       
        SequenceAcknowledgementDocument resultDoc = SequenceAcknowledgementDocument.Factory.newInstance();
        SequenceAcknowledgement acknowledgement = resultDoc.addNewSequenceAcknowledgement();
        acknowledgement.setIdentifier(sequence.getIdentifier());
        AcknowledgementRange range = acknowledgement.addNewAcknowledgementRange();
        range.setLower(BigInteger.ONE);
        range.setUpper(new BigInteger(""+s.lastMessageAcked));
       
        return resultDoc;
View Full Code Here

TOP

Related Classes of org.servicemix.ws.xmlbeans.rm.SequenceType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.