Examples of MyRoleMessageExchange


Examples of org.apache.ode.bpel.iapi.MyRoleMessageExchange

        InvokerThread(Invocation invocation) {
            _invocation = invocation;
        }

        public void run() {
            final MyRoleMessageExchange mex;
            final Future<MessageExchange.Status> running;

            // Wait for it....
            try {
                Thread.sleep(_invocation.invokeDelayMs);
            } catch (Exception ex) {
            }

            scheduler.begin();
            try {
                mex = _server.getEngine().createMessageExchange(new GUID().toString(), _invocation.target, _invocation.operation);
                mexContext.clearCurrentResponse();

                Message request = mex.createMessage(_invocation.requestType);
                request.setMessage(_invocation.request);
                _invocation.invokeTime = System.currentTimeMillis();
                running = mex.invoke(request);

                Status status = mex.getStatus();
                CorrelationStatus cstatus = mex.getCorrelationStatus();
                if (_invocation.expectedStatus != null && !status.equals(_invocation.expectedStatus))
                    failure(_invocation, "Unexpected message exchange status", _invocation.expectedStatus, status);

                if (_invocation.expectedCorrelationStatus != null && !cstatus.equals(_invocation.expectedCorrelationStatus))
                    failure(_invocation, "Unexpected correlation status", _invocation.expectedCorrelationStatus, cstatus);

            } catch (Exception ex) {
                if (_invocation.expectedInvokeException == null)
                    failure(_invocation, "Unexpected invocation exception.", ex);
                else if (_invocation.expectedInvokeException.isAssignableFrom(ex.getClass()))
                    failure(_invocation, "Unexpected invocation exception.", _invocation.expectedInvokeException, ex.getClass());

                return;
            } finally {
                scheduler.commit();
            }

            if (isFailed())
                return;

            Status finalstat;
            try {
                finalstat = running.get(_invocation.maximumWaitMs, TimeUnit.MILLISECONDS);
            } catch (Exception ex) {
                failure(_invocation, "Exception on future object.", ex);
                return;
            }

            long ctime = System.currentTimeMillis();
            long itime = ctime - _invocation.invokeTime;
            if (_invocation.minimumWaitMs != null && _invocation.minimumWaitMs >= itime)
                failure(_invocation, "Response received too soon.", _invocation.minimumWaitMs, itime);

            if (_invocation.maximumWaitMs <= itime)
                failure(_invocation, "Response took too long.", _invocation.maximumWaitMs, itime);

            if (_invocation.expectedFinalStatus != null && !_invocation.expectedFinalStatus.equals(finalstat))
                failure(_invocation, "Unexpected final message exchange status", _invocation.expectedFinalStatus, finalstat);

            if (isFailed())
                return;

            scheduler.begin();
            try {
                if (_invocation.expectedFinalCorrelationStatus != null
                        && !_invocation.expectedFinalCorrelationStatus.equals(mex.getCorrelationStatus())) {
                    failure(_invocation, "Unexpected final correlation status", _invocation.expectedFinalCorrelationStatus, mex
                            .getCorrelationStatus());
                }
                if (_invocation.expectedResponsePattern != null) {

                }
View Full Code Here

Examples of org.apache.ode.bpel.iapi.MyRoleMessageExchange

        String guid = "12345678";
        QName serviceName = new QName("http://ode/bpel/unit-test.wsdl", "HelloService");
        String operation = "hello";

        final Future<MessageExchange.Status> running;
        MyRoleMessageExchange role;
        scheduler.beginTransaction();
        try {
            role = server.getEngine().createMessageExchange(guid, serviceName, operation);
            //role.setProperty("isTwoWay", "true");
            Message msg = role.createMessage(null);

            Document doc = camelContext.getTypeConverter().convertTo(Document.class, "<message><TestPart>" + name + "</TestPart></message>");
            msg.setMessage(doc.getDocumentElement());

            LOG.info("Sending msg " + msg);
            running = role.invoke(msg);
        } finally {
            scheduler.commitTransaction();
        }

        running.get(10000, TimeUnit.MILLISECONDS);

        scheduler.beginTransaction();
        try {
            MessageExchange.Status status = role.getStatus();
            LOG.info("Status: " + status);

            Message response = role.getResponse();
            LOG.info("Response: " + response);
            String xml = camelContext.getTypeConverter().convertTo(String.class, response.getMessage());
            LOG.info("Response XML: " + xml);

            answer = xml;
View Full Code Here

Examples of org.apache.ode.bpel.iapi.MyRoleMessageExchange

     * @throws BpelEngineException
     */
    private MyRoleMessageExchange createNewMyRoleMex(ODEProcess target, List<MyRoleMessageExchange> meps, InvocationStyle istyle)
            throws BpelEngineException {
        String mexId = new GUID().toString();
        MyRoleMessageExchange template = meps.get(0);
        switch (istyle) {
        case RELIABLE:
            return new BrokeredReliableMyRoleMessageExchangeImpl(target, meps, mexId, template);
        case TRANSACTED:
            return new BrokeredTransactedMyRoleMessageExchangeImpl(target, meps, mexId, template);
View Full Code Here

Examples of org.apache.ode.bpel.iapi.MyRoleMessageExchange

     *
     * @param jbiMex
     */
    private void invokeOde(javax.jbi.messaging.MessageExchange jbiMex, NormalizedMessage request) throws Exception {

        MyRoleMessageExchange odeMex;
        if (__log.isDebugEnabled()) {
            __log.debug("invokeOde() JBI exchangeId=" + jbiMex.getExchangeId() + " endpoint=" + _endpoint + " operation="
                    + jbiMex.getOperation());
        }

        odeMex = _ode._server.createMessageExchange(InvocationStyle.UNRELIABLE, _endpoint.serviceName, jbiMex.getOperation()
                .getLocalPart(), jbiMex.getExchangeId());

        if (odeMex.getOperation() == null) {
            __log.error("ODE MEX " + odeMex + " was unroutable.");
            sendError(jbiMex, new IllegalArgumentException("Unroutable invocation."));
            return;
        }

        copyMexProperties(odeMex, jbiMex);
        javax.wsdl.Message msgdef = odeMex.getOperation().getInput().getMessage();
        Message odeRequest = odeMex.createMessage(odeMex.getOperation().getInput().getMessage().getQName());
        Mapper mapper = _ode.findMapper(request, odeMex.getOperation());
        if (mapper == null) {
            String errmsg = "Could not find a mapper for request message for JBI MEX " + jbiMex.getExchangeId() + "; ODE MEX "
                    + odeMex.getMessageExchangeId() + " is failed. ";
            __log.error(errmsg);
            throw new MessageTranslationException(errmsg);

        }
        odeMex.setProperty(Mapper.class.getName(), mapper.getClass().getName());
        mapper.toODE(odeRequest, request, msgdef);
        odeMex.setRequest(odeRequest);
        try {
            odeMex.invokeBlocking();

        } catch (Exception ex) {
            __log.error("ODE MEX " + odeMex + " resulted in an error.");
            sendError(jbiMex, ex);
            return;
        }

        switch (odeMex.getAckType()) {
        case FAULT:
            outResponseFault(odeMex, jbiMex);
            break;
        case RESPONSE:
            outResponse(odeMex, jbiMex);
            break;
        case FAILURE:
            outFailure(odeMex, jbiMex);
            break;
        default:
            __log.fatal("Unexpected AckType:" + odeMex.getAckType());
            sendError(jbiMex, new RuntimeException("Unexpected AckType:" + odeMex.getAckType()));
           
        }

    }
View Full Code Here

Examples of org.apache.ode.bpel.iapi.MyRoleMessageExchange

        _converter = new SoapMessageConverter(_wsdlDef, serviceName, portName);
    }

    public void onAxisMessageExchange(MessageContext msgContext, MessageContext outMsgContext, SOAPFactory soapFactory)
            throws AxisFault {
        MyRoleMessageExchange odeMex = null;
        try {
            // Creating mesage exchange
            String messageId = new GUID().toString();
            odeMex = _server.createMessageExchange(InvocationStyle.UNRELIABLE, _serviceName,
                    msgContext.getAxisOperation().getName().getLocalPart(), "" + messageId);
           
            __log.debug("ODE routed to operation " + odeMex.getOperation() + " from service " + _serviceName);

            if (odeMex.getOperation() == null) {
                String errmsg = "Call to " + _serviceName + "." + odeMex.getOperationName() + " was not routable.";
                __log.error(errmsg);
                throw new OdeFault(errmsg);
            }

            // Preparing message to send to ODE
            Message odeRequest = odeMex.createMessage(odeMex.getOperation().getInput().getMessage().getQName());
            _converter.parseSoapRequest(odeRequest, msgContext.getEnvelope(), odeMex.getOperation());
            readHeader(msgContext, odeMex);

            if (__log.isDebugEnabled()) {
                __log.debug("Invoking ODE using MEX " + odeMex);
                __log.debug("Message content:  " + DOMUtils.domToString(odeRequest.getMessage()));
            }

            odeMex.setRequest(odeRequest);
            odeMex.setTimeout(resolveTimeout());
            try {
                odeMex.invokeBlocking();
            } catch (java.util.concurrent.TimeoutException te) {
                String errmsg = "Call to " + _serviceName + "." + odeMex.getOperationName() + " timed out.";
                __log.error(errmsg, te);
                throw new OdeFault(errmsg);        
            }
           
            if (odeMex.getOperation().getOutput() != null && outMsgContext != null) {
                SOAPEnvelope envelope = soapFactory.getDefaultEnvelope();
                outMsgContext.setEnvelope(envelope);

                // Hopefully we have a response
                __log.debug("Handling response for MEX " + odeMex);
                onResponse(odeMex, outMsgContext);
            }
        } catch (Exception e) {
            String errmsg = "Call to " + _serviceName + "." + odeMex.getOperationName() + " caused an exception.";
            __log.error(errmsg, e);
            throw new OdeFault(errmsg, e);        
        } finally {
            if (odeMex != null)
                try {
                    odeMex.release();
                } catch (Exception ex) {
                    __log.error("Error releasing message exchange: " + odeMex.getMessageExchangeId());
                }
        }
    }
View Full Code Here

Examples of org.apache.ode.bpel.iapi.MyRoleMessageExchange

        return pids;
    }

    public void invoke(QName serviceName, String opName, Element body) throws Exception {
        String messageId = new GUID().toString();
        MyRoleMessageExchange mex;

        mex = _server.createMessageExchange(InvocationStyle.UNRELIABLE, serviceName, opName, "" + messageId);
        if (mex.getOperation() == null)
            throw new Exception("Did not find operation " + opName + " on service " + serviceName);
        Message request = mex.createMessage(mex.getOperation().getInput().getMessage().getQName());
        Element wrapper = body.getOwnerDocument().createElementNS("", "main");
        wrapper.appendChild(body);
        Element message = body.getOwnerDocument().createElementNS("", "message");
        message.appendChild(wrapper);
        request.setMessage(message);
        mex.setRequest(request);
        mex.invokeBlocking();
        mex.complete();

    }
View Full Code Here

Examples of org.apache.ode.bpel.iapi.MyRoleMessageExchange

            _invocation.maximumWaitMs = getMaximumWaitInMillis();
            _invocation.minimumWaitMs = getMinimumWaitInMillis();
        }

        public void run() {
            final MyRoleMessageExchange mex;
            final Future<MessageExchange.Status> running;

            // Wait for it....
            try {
                Thread.sleep(_invocation.invokeDelayMs * 1000);
            } catch (Exception ex) {
            }

            try {
                mex = _server.createMessageExchange(InvocationStyle.UNRELIABLE, _invocation.target, _invocation.operation,
                        new GUID().toString());

                Message request = mex.createMessage(_invocation.requestType);
                request.setMessage(_invocation.request);
                _invocation.invokeTime = System.currentTimeMillis();
                mex.setRequest(request);
                mex.invokeBlocking();

                CorrelationStatus cstatus = mex.getCorrelationStatus();
                if (_invocation.expectedCorrelationStatus != null && !cstatus.equals(_invocation.expectedCorrelationStatus))
                    failure(_invocation, "Unexpected correlation status", _invocation.expectedCorrelationStatus, cstatus);

            } catch (Exception ex) {
                if (_invocation.expectedInvokeException == null)
                    failure(_invocation, "Unexpected invocation exception.", ex);
                else if (_invocation.expectedInvokeException.isAssignableFrom(ex.getClass()))
                    failure(_invocation, "Unexpected invocation exception.", _invocation.expectedInvokeException, ex.getClass());

                return;
            }

            if (mex.getStatus() != Status.ACK)
                failure(_invocation, "No ACK status", Status.ACK.toString(), mex.getStatus().toString());

            if (isFailed())
                return;

            long ctime = System.currentTimeMillis();
            long itime = ctime - _invocation.invokeTime;
            if (_invocation.minimumWaitMs != -1 && _invocation.minimumWaitMs >= itime)
                failure(_invocation, "Response received too soon.", _invocation.minimumWaitMs, itime);

            if (_invocation.maximumWaitMs <= itime)
                failure(_invocation, "Response took too long.", _invocation.maximumWaitMs, itime);

            if (isFailed())
                return;

            AckType finalstat = mex.getAckType();
            if (_invocation.expectedFinalStatus != null && _invocation.expectedFinalStatus != finalstat) {
                if (finalstat.equals(AckType.FAULT)) {
                    failure(_invocation, "Unexpected final message exchange status", _invocation.expectedFinalStatus, "FAULT: "
                            + mex.getFault() + " | " + mex.getFaultExplanation());
                } else {
                    failure(_invocation, "Unexpected final message exchange status", _invocation.expectedFinalStatus, finalstat);
                }
            }

            if (_invocation.expectedFinalCorrelationStatus != null
                && !_invocation.expectedFinalCorrelationStatus.equals(mex.getCorrelationStatus())) {
              failure(_invocation, "Unexpected final correlation status", _invocation.expectedFinalCorrelationStatus, mex
                  .getCorrelationStatus());
            }
            if (_invocation.expectedResponsePattern != null) {
              if (mex.getResponse() == null)
                failure(_invocation, "Expected response, but got none.", null);
              String responseStr = DOMUtils.domToString(mex.getResponse().getMessage());
              Matcher matcher = _invocation.expectedResponsePattern.matcher(responseStr);
              if (!matcher.matches())
                failure(_invocation, "Response does not match expected pattern", _invocation.expectedResponsePattern,
                    responseStr);
            }
View Full Code Here

Examples of org.apache.ode.bpel.iapi.MyRoleMessageExchange

                e.printStackTrace();
                txMgr.rollback();
            }
           
            // transaction one
            MyRoleMessageExchange mex = null;
            Future onhold = null;
            try {
                // invoke the process
                txMgr.begin();
                mex = odeServer.getBpelServer().getEngine().createMessageExchange(new GUID().toString(),
                        new QName("http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl", "HelloService"), "hello");

                Message request = mex.createMessage(new QName("", ""));
                request.setMessage(DOMUtils.stringToDOM("<message><TestPart><hello xmlns=\"http://tuscany.apache.org/implementation/bpel/example/helloworld.wsdl\">Hello</hello></TestPart></message>"));
                onhold = mex.invoke(request);
                txMgr.commit();
            } catch (Exception e) {
                e.printStackTrace();
                txMgr.rollback();
            }
            // - end of transaction one

            // Waiting until the reply is ready in case the engine needs to continue in a different thread
            if (onhold != null)
                onhold.get();

            // transaction two
            try {
                txMgr.begin();
                // Reloading the mex in the current transaction, otherwise we can't be sure we have
                // the "freshest" one.
                mex = (MyRoleMessageExchange) odeServer.getBpelServer().getEngine().getMessageExchange(mex.getMessageExchangeId());

                Status status = mex.getStatus();
                System.out.println("Status: " + status.name());
                Element response = mex.getResponse().getMessage();
                System.out.println("Response: " + DOMUtils.domToString(response));
                txMgr.commit();
                // end of transaction two
            } catch (Exception e) {
                e.printStackTrace();
View Full Code Here

Examples of org.apache.ode.bpel.iapi.MyRoleMessageExchange

        if (getConfigForPartnerLink(partnerLink.partnerLink).usePeer2Peer && partnerEndpoint != null)
            p2pProcesses = _bpelProcess.getEngine().route(partnerEndpoint.serviceName, mex.getRequest());

        if (p2pProcesses != null && !p2pProcesses.isEmpty()) {
            // Creating a my mex using the same message id as partner mex to "pipe" them
            MyRoleMessageExchange myRoleMex = _bpelProcess.getEngine().createMessageExchange(
                    mex.getMessageExchangeId(), partnerEndpoint.serviceName,
                    operation.getName(), mex.getMessageExchangeId());

            if (myRoleMex instanceof BrokeredMyRoleMessageExchangeImpl) {
                mex.setSubscriberCount(((BrokeredMyRoleMessageExchangeImpl) myRoleMex).getSubscriberCount());
            }

            if (BpelProcess.__log.isDebugEnabled()) {
                __log.debug("Invoking in a p2p interaction, partnerrole " + mex + " - myrole " + myRoleMex);
            }

            Message odeRequest = myRoleMex.createMessage(operation.getInput().getMessage().getQName());
            odeRequest.setMessage(outgoingMessage);
            ((MessageImpl)odeRequest)._dao.setHeader(message.getHeader());

            if (BpelProcess.__log.isDebugEnabled()) {
                __log.debug("Setting myRoleMex session ids for p2p interaction, mySession "
                        + partnerSessionId + " - partnerSess " + mySessionId);
            }
            if ( partnerSessionId != null )
                myRoleMex.setProperty(MessageExchange.PROPERTY_SEP_MYROLE_SESSIONID, partnerSessionId);
            if ( mySessionId != null )
                myRoleMex.setProperty(MessageExchange.PROPERTY_SEP_PARTNERROLE_SESSIONID, mySessionId);

            mex.setStatus(MessageExchange.Status.REQUEST);
            myRoleMex.invoke(odeRequest);

            // Can't expect any sync response
            scheduleInvokeCheck(mex, partnerLink.partnerLink, true);
            mex.replyAsync();
        } else {
View Full Code Here

Examples of org.apache.ode.bpel.iapi.MyRoleMessageExchange

        }

        _ode.getTransactionManager().begin();

        boolean success = false;
        MyRoleMessageExchange odeMex = null;
        try {
            if (__log.isDebugEnabled()) {
                __log.debug("invokeOde() JBI exchangeId=" + jbiMex.getExchangeId() + " endpoint=" + _endpoint
                        + " operation=" + jbiMex.getOperation());
            }
            odeMex = _ode._server.getEngine().createMessageExchange(jbiMex.getExchangeId(), _endpoint.serviceName,
                    jbiMex.getOperation().getLocalPart());

            if (odeMex.getOperation() != null) {
                copyMexProperties(odeMex, jbiMex);
                javax.wsdl.Message msgdef = odeMex.getOperation().getInput().getMessage();
                Message odeRequest = odeMex.createMessage(odeMex.getOperation().getInput().getMessage().getQName());
                Mapper mapper = _ode.findMapper(request, odeMex.getOperation());
                if (mapper == null) {
                    String errmsg = "Could not find a mapper for request message for JBI MEX " + jbiMex.getExchangeId()
                            + "; ODE MEX " + odeMex.getMessageExchangeId() + " is failed. ";
                    __log.error(errmsg);
                    throw new MessageTranslationException(errmsg);

                }
                odeMex.setProperty(Mapper.class.getName(), mapper.getClass().getName());
                mapper.toODE(odeRequest, request, msgdef);
                odeMex.invoke(odeRequest);

                // Handle the response if it is immediately available.
                if (odeMex.getStatus() != Status.ASYNC) {
                    if (__log.isDebugEnabled()) {
                        __log.debug("ODE MEX " + odeMex + " completed SYNCHRONOUSLY.");
                    }
                    onResponse(odeMex);
                    _jbiMexTracker.consume(jbiMex.getExchangeId());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.