Package org.apache.sandesha

Examples of org.apache.sandesha.RMMessageContext


    }

    public RMMessageContext getLowPriorityMessageIfAcked() {
        synchronized (lowPriorityQueue) {
            int size = lowPriorityQueue.size();
            RMMessageContext terminateMsg = null;
            for (int i = 0; i < size; i++) {

                RMMessageContext temp;
                temp = (RMMessageContext) lowPriorityQueue.get(i);
                String seqId = temp.getSequenceID();
                OutgoingSequence hash = null;
                hash = (OutgoingSequence) outgoingMap.get(seqId);
                if (hash == null) {
                    log.error("ERROR: HASH NOT FOUND SEQ ID " + seqId);
                }
View Full Code Here


            int size = highPriorityQueue.size();

            ArrayList remLst = new ArrayList();

            for (int i = 0; i < size; i++) {
                RMMessageContext msg = (RMMessageContext) highPriorityQueue.get(i);
                if (msg.getSequenceID() != null)
                    if (msg.getSequenceID().equals(sequenceID) && msg.getMessageType() == Constants.MSG_TYPE_ACKNOWLEDGEMENT)
                        remLst.add(new Integer(i));
            }

            for (int i = 0; i < remLst.size(); i++) {
                Integer in = (Integer) remLst.get(i);
View Full Code Here

    /**
     * This will be used by the sender.
     */
    public synchronized RMMessageContext getNextMessageToSend() {
        RMMessageContext msg;
        msg = accessor.getNextPriorityMessageContextToSend();
        if (msg == null)
            msg = accessor.getNextOutgoingMsgContextToSend();

        if (null == msg) {
            msg = accessor.getNextLowPriorityMessageContextToSend();

            // checks whether all the request messages have been acked
        }
        if (null != callBack && null != msg)
            informOutgoingMessage(msg);

        if (msg != null && !msg.isLocked()) {
            msg.setLocked(true);
            return msg;
        } else {
            return null;
        }
    }
View Full Code Here

        accessor.addMessageToIncomingSequence(sequenceId, msgNo, rmMessageContext);
        accessor.updateFinalMessageArrivedTime(sequenceId);
    }

    public RMMessageContext checkForResponseMessage(String sequenceId, String requestMsgId) {
        RMMessageContext response = accessor.checkForResponseMessage(requestMsgId, sequenceId);
        return response;

    }
View Full Code Here

    public void invoke(MessageContext msgContext) throws AxisFault {

        storageManager = new ClientStorageManager();

        try {
            RMMessageContext reqMsgCtx = null;
            String tempSeqID = null;

            reqMsgCtx = getRMMessageContext(msgContext);

            tempSeqID = reqMsgCtx.getSequenceID();

            reqMsgCtx = processRequestMessage(reqMsgCtx, reqMsgCtx.getSync());

            if (reqMsgCtx.isHasResponse()) {
                RMMessageContext responseMessageContext = null;
                long startingTime = System.currentTimeMillis();
                long inactivityTimeOut = PolicyLoader.getInstance().getInactivityTimeout();

                while (responseMessageContext == null) {
                    synchronized (lock) {
                        responseMessageContext =
                                checkTheQueueForResponse(tempSeqID, reqMsgCtx.getMessageID());
                        if ((System.currentTimeMillis() - startingTime) >= inactivityTimeOut) {
                            reqMsgCtx.getCtx().stopClientByForce();
                        }
                        Thread.sleep(Constants.CLIENT_RESPONSE_CHECKING_INTERVAL);
                    }
                }

                //setting RMReport;
                if (responseMessageContext != null) {
                    String oldSeqId = reqMsgCtx.getOldSequenceID();
                    if (oldSeqId != null) {
                        Call call = (Call) reqMsgCtx.getCtx().getCallMap().get(reqMsgCtx.getOldSequenceID());

                        if (call != null) {
                            RMReport report = (RMReport) call.getProperty(Constants.ClientProperties.REPORT);
                            report.incrementReturnedMsgCount();
                        }
                    }
                }

                //We need these steps to filter all addressing and rm related headers.
                Message resMsg = responseMessageContext.getMsgContext().getRequestMessage();
                RMHeaders.removeHeaders(resMsg.getSOAPEnvelope());
                AddressingHeaders addHeaders = new AddressingHeaders(resMsg.getSOAPEnvelope(), null, true, true, false, null);
                msgContext.setResponseMessage(new Message(resMsg.getSOAPPartAsString()));

            } else {
View Full Code Here

                    offerID = Constants.UUID + uuidGen.nextUUID();
                    storageManager.addRequestedSequence(offerID);
                    storageManager.addOffer(msgID, offerID);
                }

                RMMessageContext createSeqRMMsgContext = RMMessageCreator.createCreateSeqMsg(reqRMMsgContext, Constants.CLIENT, msgID, offerID);
                storageManager.addOutgoingSequence(reqRMMsgContext.getSequenceID());
                storageManager.setTemporaryOutSequence(reqRMMsgContext.getSequenceID(),
                        createSeqRMMsgContext.getMessageID());

                createSeqRMMsgContext.setSync(sync);
                storageManager.addCreateSequenceRequest(createSeqRMMsgContext);
                processMessage(reqRMMsgContext);

            } else {
                processMessage(reqRMMsgContext);
View Full Code Here

    private RMMessageContext processMessage(RMMessageContext reqRMMsgContext)
            throws Exception {
        if (reqRMMsgContext.isLastMessage()) {
            storageManager.insertTerminateSeqMessage(RMMessageCreator.createTerminateSeqMsg(reqRMMsgContext, Constants.CLIENT));
        }
        RMMessageContext serviceRequestMsg = RMMessageCreator.createServiceRequestMessage(reqRMMsgContext);
        storageManager.insertOutgoingMessage(serviceRequestMsg);
        return reqRMMsgContext;
    }
View Full Code Here

    private RMMessageContext getRMMessageContext(MessageContext msgCtx) throws Exception {
        //Get a copy of the MessageContext. This is required when sending multiple messages from
        //one call object
        MessageContext newMsgContext = RMMessageCreator.cloneMsgContext(msgCtx);
        RMMessageContext requestMesssageContext = new RMMessageContext();
        Call call = (Call) newMsgContext.getProperty(MessageContext.CALL);

        requestMesssageContext = ClientPropertyValidator.validate(call);
        requestMesssageContext.setOutGoingAddress((String) msgCtx.getProperty(MessageContext.TRANS_URL));
        requestMesssageContext.setMsgContext(newMsgContext);
        return requestMesssageContext;
    }
View Full Code Here

*/
public class ClientPropertyValidator {

    public static synchronized RMMessageContext validate(Call call) throws AxisFault {

        RMMessageContext rmMessageContext = null;

        boolean inOut = getInOut(call);
        long msgNumber = getMessageNumber(call);
        boolean lastMessage = getLastMessage(call);
        boolean sync = getSync(call);
        String action = getAction(call);
        String sourceURL = null;
        String from = getFrom(call);
        String replyTo = getReplyTo(call);
        String acksTo = getAcksTo(call);
        String to = getTo(call);
        String faultTo = getFaultTo(call);
        boolean sendOffer = getOffer(call);
        String key = getKey(call);
        SandeshaContext ctx = getCtx(call);

        try {
            sourceURL = getSourceURL(call);
        } catch (Exception e) {
            throw new AxisFault(e.getMessage());
        }

        String errorMsg = getValidated(msgNumber, action, replyTo, sync, inOut);
        if (errorMsg == null) {
            rmMessageContext = new RMMessageContext();

            rmMessageContext.setSync(sync);
            rmMessageContext.setHasResponse(inOut);
            rmMessageContext.setMsgNumber(msgNumber);
            rmMessageContext.setLastMessage(lastMessage);
            rmMessageContext.setSourceURL(sourceURL);
            rmMessageContext.setSequenceID(key);
            rmMessageContext.setReplyTo(replyTo);
            rmMessageContext.setFrom(from);
            rmMessageContext.setAction(action);
            rmMessageContext.setAcksTo(acksTo);
            rmMessageContext.setTo(to);
            rmMessageContext.setFaultTo(faultTo);
            rmMessageContext.setSendOffer(sendOffer);
            rmMessageContext.setCtx(ctx);
            return rmMessageContext;

        } else
            throw new AxisFault(errorMsg);

View Full Code Here

                if (!hasSequence) {
                    storageManager.addIncomingSequence(seqId);
                }
                if (!storageManager.isMessageExist(seqId, messageNumber)) {
                    //Create a copy of the RMMessageContext.
                    RMMessageContext rmMsgContext = new RMMessageContext();
                    //Copy the RMMEssageContext
                    rmMessageContext.copyContents(rmMsgContext);
                    rmMsgContext.setSequenceID(sequenceUUID);
                    rmMsgContext.setMsgNumber(messageNumber);
                    try {
                        MessageContext msgContext = new MessageContext(rmMessageContext.getMsgContext().getAxisEngine());
                        RMMessageContext.copyMessageContext(rmMessageContext.getMsgContext(),
                                msgContext);
                        String soapMsg = rmMessageContext.getMsgContext().getRequestMessage()
                                .getSOAPEnvelope()
                                .toString();
                        Message reqMsg = new Message(soapMsg);

                        msgContext.setRequestMessage(reqMsg);
                        rmMsgContext.setMsgContext(msgContext);
                        rmMsgContext.setMessageType(Constants.MSG_TYPE_SERVICE_REQUEST);
                    } catch (Exception e) {
                        log.error(e);
                        throw new AxisFault(new QName(Constants.FaultCodes.WSRM_SERVER_INTERNAL_ERROR),
                                Constants.FaultMessages.SERVER_INTERNAL_ERROR, null, null);
                    }
View Full Code Here

TOP

Related Classes of org.apache.sandesha.RMMessageContext

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.