Package org.apache.servicemix.nmr.api

Examples of org.apache.servicemix.nmr.api.Message


                    exchange.setProperty(MessageExchangeImpl.SERVICE_ENDPOINT_PROP, se);
                }
                // Re-process JBI addressing
                DeliveryChannelImpl.createTarget(getChannel().getNMR(), exchange);
                // TODO: read exchange properties
                Message msg = (Message) ((ObjectMessage) message).getObject();
                exchange.setIn(msg);
                exchanges.put(exchange.getId(), exchange);
                if (pendingExchanges.incrementAndGet() >= maxPendingExchanges) {
                    if (pauseConsumption.compareAndSet(false, true)) {
                        invalidateSelector();
                    }
                }
                exchange.setProperty(PROPERTY_CORR_ID + "." + name, exchange.getId());
                requestor.suspend(exchange.getId());
                if (requestor.getTransaction() != null) {
                    exchange.setProperty(MessageExchange.JTA_TRANSACTION_PROPERTY_NAME, requestor.getTransaction());
                }
                send(exchange);
                break;
            }
            case JBI_MESSAGE_OUT: {
                String corrId = message.getStringProperty(PROPERTY_CORR_ID);
                if (corrId == null) {
                    throw new IllegalStateException("Incoming JMS message has no correlationId");
                }
                Exchange exchange = exchanges.get(corrId);
                if (exchange == null) {
                    throw new IllegalStateException("Exchange not found for id " + corrId);
                }
                Message msg = (Message) ((ObjectMessage) message).getObject();
                exchange.setOut(msg);
                exchanges.put(exchange.getId(), exchange);
                exchange.setProperty(PROPERTY_CORR_ID + "." + name, exchange.getId());
                requestor.suspend(exchange.getId());
                if (requestor.getTransaction() != null) {
                    exchange.setProperty(MessageExchange.JTA_TRANSACTION_PROPERTY_NAME, requestor.getTransaction());
                }
                send(exchange);
                break;
            }
            case JBI_MESSAGE_FAULT: {
                String corrId = message.getStringProperty(PROPERTY_CORR_ID);
                if (corrId == null) {
                    throw new IllegalStateException("Incoming JMS message has no correlationId");
                }
                Exchange exchange = exchanges.get(corrId);
                if (exchange == null) {
                    throw new IllegalStateException("Exchange not found for id " + corrId);
                }
                Message msg = (Message) ((ObjectMessage) message).getObject();
                exchange.setFault(msg);
                exchanges.put(exchange.getId(), exchange);
                exchange.setProperty(PROPERTY_CORR_ID + "." + name, exchange.getId());
                requestor.suspend(exchange.getId());
                if (requestor.getTransaction() != null) {
View Full Code Here


                rollbackOnErrors = Boolean.TRUE.equals(exchange.getProperty(PROPERTY_ROLLBACK_ON_ERRORS + "." + name));
            } else {
                rollbackOnErrors = this.rollbackOnErrors;
            }
            if (exchange.getStatus() == Status.Active) {
                Message msg = exchange.getFault(false);
                int type;
                if (msg != null) {
                    type = JBI_MESSAGE_FAULT;
                } else {
                    msg = exchange.getOut(false);
View Full Code Here

    protected Exchange checkSerializable(Exchange exchange) {
        boolean isSerializable = isMapSerializable(exchange.getProperties());
        if (isSerializable) {
            for (Type t : Type.values()) {
                Message m = exchange.getMessage(t, false);
                if (m != null) {
                    if (!isMapSerializable(m.getHeaders())) {
                        isSerializable = false;
                        break;
                    }
                }
            }
        }
        if (!isSerializable) {
            exchange = exchange.copy();
            makeMapSerializable(exchange.getProperties());
            for (Type t : Type.values()) {
                Message m = exchange.getMessage(t, false);
                if (m != null) {
                    makeMapSerializable(m.getHeaders());
                }
            }
        }
        return exchange;
    }
View Full Code Here

            d.add(new Field(FIELD_STATUS, String.valueOf(exchange.getStatus()).toLowerCase(), Field.Store.YES, Field.Index.NOT_ANALYZED));
            d.add(new Field(FIELD_ROLE, String.valueOf(exchange.getRole()).toLowerCase(), Field.Store.YES, Field.Index.NOT_ANALYZED));
            addExchangePropertiesToDocument(exchange, d);
            Type[] types = { Type.In, Type.Out, Type.Fault };
            for (int i = 0; i < types.length; i++) {
                Message message = exchange.getMessage(types[i], false);
                if (message != null) {
                    String text = getBodyAsText(message);
                    if (text != null) {
                        d.add(new Field(types[i].toString().toLowerCase() + "." + FIELD_CONTENT, text, Field.Store.COMPRESS, Field.Index.ANALYZED));
                    }
View Full Code Here

    public void testWrite() throws Exception {
        Exchange e = new ExchangeImpl(Pattern.InOnly);
        e.setOperation(new QName("op"));
        e.setProperty("key", "value");
        e.setStatus(Status.Done);
        Message msg = e.getIn();
        msg.setHeader("header", "value");
        msg.addAttachment("id", "att");
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream os = new ObjectOutputStream(baos);
        os.writeObject(e);
        os.close();
        ObjectInputStream is = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
View Full Code Here

    private static final Log LOG = LogFactory.getLog(ExchangeUtilsTest.class);

    public void testReReadable() throws Exception {
        Exchange e = new ExchangeImpl(Pattern.InOnly);
        Message msg = e.getIn();
        msg.addAttachment("id", new BufferedInputStream(new ByteArrayInputStream(new byte[] { 1, 2, 3, 4 })));
        msg.setBody(new DOMSource(parse("<hello/>")));

        e.ensureReReadable();

        assertNotNull(msg.getBody());
        assertTrue(msg.getBody() instanceof StringSource);
        assertNotNull(msg.getAttachment("id"));
        assertTrue(msg.getAttachment("id") instanceof ByteArrayInputStream);
    }
View Full Code Here

    public void testDisplay() throws Exception {
        Exchange e = new ExchangeImpl(Pattern.InOnly);
        e.setOperation(new QName("op"));
        e.setProperty("key", "value");
        e.setStatus(Status.Done);
        Message msg = e.getIn();
        msg.setHeader("header", "value");
        msg.addAttachment("id", new BufferedInputStream(new ByteArrayInputStream(new byte[] { 1, 2, 3, 4 })));
        msg.setBody(new StringSource("<hello/>"));

        String str = e.display(false);
        LOG.info(str);
        assertNotNull(msg.getBody());
        assertTrue(msg.getBody() instanceof StringSource);
        assertNotNull(msg.getAttachment("id"));
        assertTrue(msg.getAttachment("id") instanceof BufferedInputStream);

        str = e.display(true);
        LOG.info(str);
        assertNotNull(msg.getBody());
        assertTrue(msg.getBody() instanceof StringSource);
        assertNotNull(msg.getAttachment("id"));
        assertTrue(msg.getAttachment("id") instanceof ByteArrayInputStream);
    }
View Full Code Here

            throw new IllegalStateException();
        }
    }

    public NormalizedMessage getInMessage() {
        Message msg = exchange.getIn(false);
        if (msg == null) {
            return null;
        } else {
            return new NormalizedMessageImpl(msg);
        }
View Full Code Here

        NormalizedMessageImpl msg = (NormalizedMessageImpl) message;
        exchange.setIn(msg.getInternalMessage());
    }

    public NormalizedMessage getOutMessage() {
        Message msg = exchange.getOut(false);
        if (msg == null) {
            return null;
        } else {
            return new NormalizedMessageImpl(msg);
        }
View Full Code Here

    public Fault createFault() throws MessagingException {
        return new FaultImpl(new MessageImpl());
    }

    public Fault getFault() {
        Message msg = exchange.getFault(false);
        if (msg == null) {
            return null;
        } else {
            return new FaultImpl(msg);
        }
View Full Code Here

TOP

Related Classes of org.apache.servicemix.nmr.api.Message

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.