Package javax.jbi.messaging

Examples of javax.jbi.messaging.MessageExchange$Role


            mep = ExchangePattern.fromWsdlUri(defaultMep);
        }
        if (mep == null) {
            mep = ExchangePattern.fromWsdlUri(getMessageExchangePattern());
        }
        MessageExchange answer = null;
        if (mep != null) {
            if (mep == ExchangePattern.InOnly) {
                answer = exchangeFactory.createInOnlyExchange();
            } else if (mep == ExchangePattern.InOptionalOut) {
                answer = exchangeFactory.createInOptionalOutExchange();
View Full Code Here


    }
   
    protected MessageExchange createPart(URI pattern,
                                         NormalizedMessage srcMessage,
                                         Source content) throws Exception {
        MessageExchange me = getExchangeFactory().createExchange(pattern);
        NormalizedMessage in = me.createMessage();
        in.setContent(content);
        me.setMessage(in, "in");
        if (forwardAttachments) {
            Set names = srcMessage.getAttachmentNames();
            for (Iterator iter = names.iterator(); iter.hasNext();) {
                String name = (String) iter.next();
                in.addAttachment(name, srcMessage.getAttachment(name));
View Full Code Here

                }

                return;
            }

            MessageExchange exchange = message
                    .getContent(MessageExchange.class);
            ComponentContext context = message.getExchange().get(
                    ComponentContext.class);
            CxfBcConsumer.this.configureExchangeTarget(exchange);
            CxfBcConsumer.this.messages.put(exchange.getExchangeId(), message);
            CxfBcConsumer.this.isOneway = message.getExchange().get(
                    BindingOperationInfo.class).getOperationInfo().isOneWay();
            message.getExchange().setOneWay(CxfBcConsumer.this.isOneway);
           
View Full Code Here

            super(Phase.POST_INVOKE);
            addBefore(OutgoingChainInterceptor.class.getName());
        }

        public void handleMessage(final Message message) throws Fault {
            MessageExchange exchange = message
                    .getContent(MessageExchange.class);
            Exchange ex = message.getExchange();
            if (exchange.getStatus() == ExchangeStatus.ERROR) {
                throw new Fault(exchange.getError());
            }
            if (!ex.isOneWay()) {
                if (exchange.getFault() != null) {
                    Fault f = new JBIFault(new org.apache.cxf.common.i18n.Message(
                            "Fault occured", (ResourceBundle) null));

                    Element details = toElement(exchange.getFault().getContent());
                    f.setDetail(details);
                    processFaultDetail(f, message);
                    message.put(BindingFaultInfo.class, faultWanted);
                    throw f;
                } else if (exchange.getMessage("out") != null) {
                    Endpoint endpoint = ex.get(Endpoint.class);
                    Message outMessage = ex.getOutMessage();
                    if (outMessage == null) {
                        outMessage = endpoint.getBinding().createMessage();
                        ex.setOutMessage(outMessage);
                    }
                    NormalizedMessageImpl norMessage =
                        (NormalizedMessageImpl) exchange.getMessage("out");
                    List<Attachment> attachmentList = new ArrayList<Attachment>();
                    outMessage.setContent(Source.class, exchange.getMessage(
                            "out").getContent());
                    Iterator<String> iter = norMessage.listAttachments();
                    while (iter.hasNext()) {
                        String id = iter.next();
                        DataHandler dh = norMessage.getAttachment(id);
View Full Code Here

    /* (non-Javadoc)
     * @see org.apache.servicemix.eip.EIPEndpoint#processSync(javax.jbi.messaging.MessageExchange)
     */
    protected void processSync(MessageExchange exchange) throws Exception {
        // Create exchange for target
        MessageExchange tme = getExchangeFactory().createExchange(exchange.getPattern());
        // Now copy input to new exchange
        // We need to read the message once for finding routing target
        // so ensure we have a re-readable source
        NormalizedMessage in = MessageUtil.copyIn(exchange);
        MessageUtil.transferToIn(in, tme);
        // Retrieve target
        ExchangeTarget target = getDestination(tme);
        target.configureTarget(tme, getContext());
        // Send in to target
        sendSync(tme);
        // Send back the result
        if (tme.getStatus() == ExchangeStatus.DONE) {
            done(exchange);
        } else if (tme.getStatus() == ExchangeStatus.ERROR) {
            fail(exchange, tme.getError());
        } else if (tme.getFault() != null) {
            Fault fault = MessageUtil.copyFault(tme);
            done(tme);
            MessageUtil.transferToFault(fault, exchange);
            sendSync(exchange);
        } else if (tme.getMessage("out") != null) {
            NormalizedMessage out = MessageUtil.copyOut(tme);
            done(tme);
            MessageUtil.transferToOut(out, exchange);
            sendSync(exchange);
        } else {
View Full Code Here

     */
    protected void processAsync(MessageExchange exchange) throws Exception {
        if (exchange.getRole() == MessageExchange.Role.PROVIDER
            && exchange.getProperty(correlation) == null) {
            // Create exchange for target
            MessageExchange tme = getExchangeFactory().createExchange(exchange.getPattern());
            if (store.hasFeature(Store.CLUSTERED)) {
                exchange.setProperty(JbiConstants.STATELESS_PROVIDER, Boolean.TRUE);
                tme.setProperty(JbiConstants.STATELESS_CONSUMER, Boolean.TRUE);
            }
            // Set correlations
            tme.setProperty(correlation, exchange.getExchangeId());
            exchange.setProperty(correlation, tme.getExchangeId());
            // Put exchange to store
            store.store(exchange.getExchangeId(), exchange);
            // Now copy input to new exchange
            // We need to read the message once for finding routing target
            // so ensure we have a re-readable source
            NormalizedMessage in = MessageUtil.copyIn(exchange);
            MessageUtil.transferToIn(in, tme);
            // Retrieve target
            ExchangeTarget target = getDestination(tme);
            target.configureTarget(tme, getContext());
            // Send in to target
            send(tme);
        // Mimic the exchange on the other side and send to needed listener
        } else {
            String id = (String) exchange.getProperty(correlation);
            if (id == null) {
                throw new IllegalStateException(correlation + " property not found");
            }
            MessageExchange org = (MessageExchange) store.load(id);
            if (org == null) {
                throw new IllegalStateException("Could not load original exchange with id " + id);
            }
            // Reproduce DONE status to the other side
            if (exchange.getStatus() == ExchangeStatus.DONE) {
View Full Code Here

        assertEquals("wrong number of messages", numMessages, ml.getMessageCount());
        for (int i = 0; i < numMessages; i++) {
            assertSequenceProperties((NormalizedMessage)ml.getMessages().get(i), i + 1);
        }
        for (int i = 0; i < numMessages; i++) {
            MessageExchange me = (InOnly)client.receive();
            assertEquals(ExchangeStatus.DONE, me.getStatus());
        }
    }
View Full Code Here

        } else if (tme.getOutMessage() == null) {
            throw new IllegalStateException("Exchange status is " + ExchangeStatus.ACTIVE
                    + " but has no correlation set");
        // This is the answer from the transformer
        } else {
            MessageExchange me = getExchangeFactory().createExchange(exchange.getPattern());
            target.configureTarget(me, getContext());
            MessageUtil.transferOutToIn(tme, me);
            sendSync(me);
            done(tme);
            if (me.getStatus() == ExchangeStatus.DONE) {
                done(exchange);
            } else if (me.getStatus() == ExchangeStatus.ERROR) {
                fail(exchange, me.getError());
            } else if (me.getFault() != null) {
                if (exchange instanceof InOnly) {
                    // Do not use the fault has it may contain streams
                    // So just transform it to a string and send an error
                    String fault = new SourceTransformer().contentToString(me.getFault());
                    done(me);
                    fail(exchange, new FaultException(fault, null, null));
                } else {
                    Fault fault = MessageUtil.copyFault(me);
                    MessageUtil.transferToFault(fault, exchange);
View Full Code Here

    }

    private void processFault(MessageExchange exchange, InOut tme) throws Exception {
        // Faults must be sent to the target / faultsTarget
        if (faultsTarget != null || sendFaultsToTarget) {
            MessageExchange me = getExchangeFactory().createExchange(exchange.getPattern());
            (faultsTarget != null ? faultsTarget : target).configureTarget(me, getContext());
            MessageUtil.transferToIn(tme.getFault(), me);
            sendSync(me);
            done(tme);
            if (me.getStatus() == ExchangeStatus.DONE) {
                done(exchange);
            } else if (me.getStatus() == ExchangeStatus.ERROR) {
                fail(exchange, me.getError());
            } else if (me.getFault() != null) {
                if (exchange instanceof InOnly) {
                    // Do not use the fault has it may contain streams
                    // So just transform it to a string and send an error
                    String fault = new SourceTransformer().contentToString(me.getFault());
                    done(me);
                    fail(exchange, new FaultException(fault, null, null));
                } else {
                    Fault fault = MessageUtil.copyFault(me);
                    MessageUtil.transferToFault(fault, exchange);
View Full Code Here

            if (transformerId == null && targetId == null) {
                throw new IllegalStateException("Exchange status is " + ExchangeStatus.DONE
                        + " but has no correlation set");
            }
            // Load the exchange
            MessageExchange me = (MessageExchange) store.load(targetId != null ? targetId : transformerId);
            done(me);
        // Errors must be sent back to the target or transformer
        } else if (exchange.getStatus() == ExchangeStatus.ERROR) {
            String transformerId = (String) exchange.getProperty(correlationTransformer);
            String targetId = (String) exchange.getProperty(correlationTarget);
            if (transformerId == null && targetId == null) {
                throw new IllegalStateException("Exchange status is " + ExchangeStatus.DONE
                        + " but has no correlation set");
            }
            // Load the exchange
            MessageExchange me = (MessageExchange) store.load(targetId != null ? targetId : transformerId);
            fail(me, exchange.getError());
        // This is a new exchange
        } else if (exchange.getProperty(correlationTransformer) == null) {
            if (!(exchange instanceof InOnly) && !(exchange instanceof RobustInOnly)) {
                fail(exchange, new UnsupportedOperationException("Use an InOnly or RobustInOnly MEP"));
                return;
            }
            // Create exchange for target
            MessageExchange tme = getExchangeFactory().createInOutExchange();
            transformer.configureTarget(tme, getContext());
            // Set correlations
            exchange.setProperty(correlationTransformer, tme.getExchangeId());
            tme.setProperty(correlationConsumer, exchange.getExchangeId());
            tme.setProperty(TRANSFORMER, Boolean.TRUE);
            tme.setProperty(CONSUMER_MEP, exchange.getPattern());
            // Put exchange to store
            store.store(exchange.getExchangeId(), exchange);
            // Send in to listener and target
            MessageUtil.transferInToIn(exchange, tme);
            send(tme);
View Full Code Here

TOP

Related Classes of javax.jbi.messaging.MessageExchange$Role

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.