Package javax.jbi.messaging

Examples of javax.jbi.messaging.MessageExchange


            ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
            LOG.finest("building document from bytes");
            DocumentBuilder builder = docBuilderFactory.newDocumentBuilder();
            Document doc = builder.parse(bais);
           
            MessageExchange xchng = (MessageExchange)ctx.get(MESSAGE_EXCHANGE_PROPERTY);
            LOG.fine("creating NormalizedMessage");
            NormalizedMessage msg = xchng.createMessage();
            msg.setContent(new DOMSource(doc));
            xchng.setMessage(msg, "out");
            LOG.fine("postDispatch sending out message to NWR");
            channel.send(xchng);
        } catch (Exception ex) {
            LOG.log(Level.SEVERE, "error sending Out message", ex);
        }
View Full Code Here


           
            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

        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

                }
                dv = cc.getDeliveryChannel();
            }
            mef = dv.createExchangeFactory();
        }
        MessageExchange me = mef.createExchange(mep);
        me.setOperation(operation.getName());
        return me;
    }
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

     */
    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

            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

        // 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

    /* (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

                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

TOP

Related Classes of javax.jbi.messaging.MessageExchange

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.