Examples of MessageExchange


Examples of javax.jbi.messaging.MessageExchange

           
            try {
                running = true;
                LOG.fine("JBIServerTransport message receiving thread started");
                do {
                    MessageExchange exchange = channel.accept();
                    if (exchange != null) {
                        // REVISIT: serialized message handling not such a
                        // good idea.
                        // REVISIT: can there be more than one ep?
                        ServiceEndpoint ep = exchange.getEndpoint();
                        CeltixServiceUnit csu = suManager.getServiceUnitForEndpoint(ep);
                        ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
                       
                        try {
                            Thread.currentThread().setContextClassLoader(csu.getClassLoader());
View Full Code Here

Examples of javax.jbi.messaging.MessageExchange

        super(Phase.PRE_INVOKE);
    }

    public void handleMessage(Message message) {
        try {
            MessageExchange exchange;
            NormalizedMessage nm;
            // Create message
            if (!isRequestor(message)) {
                exchange = createExchange(message);
                nm = exchange.createMessage();
                exchange.setMessage(nm, "in");
                message.setContent(MessageExchange.class, exchange);
            } else {
                exchange = message.getContent(MessageExchange.class);
                if (exchange == null) {
                    throw new IllegalStateException("Content of type "
                            + MessageExchange.class + " not found on message");
                }
                if (message.getContent(Exception.class) == null) {
                    nm = exchange.createMessage();
                    exchange.setMessage(nm, "out");
                } else {
                    exchange.setFault(exchange.createFault());
                    nm = exchange.getFault();
                }
            }
            // Put headers
            toNMSHeaders(nm, message);
            // Put attachments
View Full Code Here

Examples of javax.jbi.messaging.MessageExchange

                }
                dv = cc.getDeliveryChannel();
            }
            mef = dv.createExchangeFactory();
        }
        MessageExchange me = mef.createExchange(mep);
        me.setOperation(operation.getName());
        return me;
    }
View Full Code Here

Examples of javax.jbi.messaging.MessageExchange

        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

Examples of javax.jbi.messaging.MessageExchange

     */
    protected void processSync(MessageExchange exchange) throws Exception {
        if (!(exchange instanceof InOut)) {
            throw new IllegalStateException("Use an InOut MEP");
        }
        MessageExchange current = exchange;
        for (int i = 0; i < targets.length; i++) {
            InOut me = getExchangeFactory().createInOutExchange();
            targets[i].configureTarget(me, getContext());
            if (i == 0) {
                MessageUtil.transferInToIn(current, me);
View Full Code Here

Examples of javax.jbi.messaging.MessageExchange

            String correlationId = (String) exchange.getProperty(correlation);
            if (correlationId == null) {
                throw new IllegalStateException(correlation + " property not found");
            }
            // Ack last target hit
            MessageExchange me = (MessageExchange) store.load(correlationId);
            done(me);
        } else if (exchange.getStatus() == ExchangeStatus.ERROR) {
            String correlationId = (String) exchange.getProperty(correlation);
            if (correlationId == null) {
                throw new IllegalStateException(correlation + " property not found");
            }
            // Ack last target hit
            MessageExchange me = (MessageExchange) store.load(correlationId);
            done(me);
        } else if (!(exchange instanceof InOut)) {
            throw new IllegalStateException("Use an InOut MEP");
        } else {
            MessageExchange me = getExchangeFactory().createInOutExchange();
            me.setProperty(correlation, exchange.getExchangeId());
            me.setProperty(index, new Integer(0));
            targets[0].configureTarget(me, getContext());
            store.store(exchange.getExchangeId(), exchange);
            MessageUtil.transferInToIn(exchange, me);
            send(me);
        }
View Full Code Here

Examples of javax.jbi.messaging.MessageExchange

        // This should never happen, as we can only send DONE
        if (exchange.getStatus() == ExchangeStatus.DONE) {
            throw new IllegalStateException("Exchange status is " + ExchangeStatus.DONE);
        // ERROR are sent back to the consumer
        } else if (exchange.getStatus() == ExchangeStatus.ERROR) {
            MessageExchange me = (MessageExchange) store.load(correlationId);
            fail(me, exchange.getError());
            // Ack the previous target
            if (previousId != null) {
                me = (MessageExchange) store.load(previousId);
                done(me);
            }
        // Faults are sent back to the consumer
        } else if (exchange.getFault() != null) {
            MessageExchange me = (MessageExchange) store.load(correlationId);
            me.setProperty(correlation, exchange.getExchangeId());
            store.store(exchange.getExchangeId(), exchange);
            MessageUtil.transferFaultToFault(exchange, me);
            send(me);
            // Ack the previous target
            if (previousId != null) {
                me = (MessageExchange) store.load(previousId);
                done(me);
            }
        // Out message, give it to next target or back to consumer
        } else if (exchange.getMessage("out") != null) {
            // This is the answer from the last target
            if (prevIndex.intValue() == targets.length - 1) {
                MessageExchange me = (MessageExchange) store.load(correlationId);
                me.setProperty(correlation, exchange.getExchangeId());
                store.store(exchange.getExchangeId(), exchange);
                MessageUtil.transferOutToOut(exchange, me);
                send(me);
                if (previousId != null) {
                    me = (MessageExchange) store.load(previousId);
                    done(me);
                }
            // We still have a target to hit
            } else {
                MessageExchange me = getExchangeFactory().createInOutExchange();
                Integer curIndex = new Integer(prevIndex.intValue() + 1);
                me.setProperty(correlation, correlationId);
                me.setProperty(index, curIndex);
                me.setProperty(previous, exchange.getExchangeId());
                targets[curIndex.intValue()].configureTarget(me, getContext());
                store.store(exchange.getExchangeId(), exchange);
                MessageUtil.transferOutToIn(exchange, me);
                send(me);
                if (previousId != null) {
View Full Code Here

Examples of javax.jbi.messaging.MessageExchange

    /* (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());
        target.configureTarget(tme, getContext());
        sendSyncToListenerAndTarget(exchange, tme, inListener, "in", false);
        if (tme.getStatus() == ExchangeStatus.DONE) {
            done(exchange);
        } else if (tme.getStatus() == ExchangeStatus.ERROR) {
            fail(exchange, tme.getError());
        } else if (tme.getFault() != null) {
            sendSyncToListenerAndTarget(tme, exchange, faultListener, "fault", isCopyProperties());
            done(tme);
        } else if (tme.getMessage("out") != null) {
            sendSyncToListenerAndTarget(tme, exchange, outListener, "out", isCopyProperties());
            done(tme);
        } else {
            done(tme);
            throw new IllegalStateException("Exchange status is " + ExchangeStatus.ACTIVE
View Full Code Here

Examples of javax.jbi.messaging.MessageExchange

                component.getServiceUnitManager().init(suName,
                        path.getAbsolutePath());
                component.getServiceUnitManager().start(suName);

                // Send message
                MessageExchange exchange = createExchange(client);
                configureExchange(client, exchange);
                populateExchange(exchange);
                client.sendSync(exchange);
                assertNotNull(exchange.getMessage("out"));
                //assertNotNull(exchange.getMessage("out").getContent());
                // TODO: check out
                client.done(exchange);

                // Stop and undeploy
View Full Code Here

Examples of javax.jbi.messaging.MessageExchange

     */
    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);
            }
            target.configureTarget(tme, getContext());
            // Set correlations
            exchange.setProperty(correlation, tme.getExchangeId());
            tme.setProperty(correlation, exchange.getExchangeId());
            // Put exchange to store
            store.store(exchange.getExchangeId(), exchange);
            // Send in to listener and target
            sendToListenerAndTarget(exchange, tme, inListener, "in", false);
        // Mimic the exchange on the other side and send to needed listener
        } else {
            String id = (String) exchange.getProperty(correlation);
            if (id == null) {
                if (exchange.getRole() == MessageExchange.Role.CONSUMER
                    && exchange.getStatus() != ExchangeStatus.ACTIVE) {
                    // This must be a listener status, so ignore
                    return;
                }
                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
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.