Package org.apache.servicemix.nmr.api

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


                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 Message unmarshallMessage(javax.jms.Message message) throws JMSException {
        Message msg = null;
        ClassLoader oldCl = Thread.currentThread().getContextClassLoader();
        try {
            Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
            msg = (Message) ((ObjectMessage) message).getObject();
        } finally {
View Full Code Here

        sb.append("]\n");
        return sb.toString();
    }

    public static void display(Exchange exchange, Type type, StringBuffer sb) {
        Message message = exchange.getMessage(type, false);
        if (message != null) {
            sb.append("  ").append(type).append(": [").append('\n');
            sb.append("    content: ");
            try {
                if (message.getBody() != null) {
                    Object contents = message.getBody();
                    sb.append(convertDisplay(contents));
                } else {
                    sb.append("null");
                }
            } catch (Exception e) {
                sb.append("Unable to display: ").append(e);
            }
            sb.append('\n');
            if (message.getAttachments().size() > 0) {
                sb.append("    attachments: [").append('\n');
                for (String key : message.getAttachments().keySet()) {
                    Object contents = message.getAttachment(key);
                    sb.append("      ").append(key).append(" = ").append(convertDisplay(contents)).append('\n');
                }
                sb.append("    ]").append('\n');
            }
            if (message.getHeaders().size() > 0) {
                sb.append("    properties: [").append('\n');
                for (String key : message.getHeaders().keySet()) {
                    sb.append("      ").append(key).append(" = ");
                    Object contents = message.getHeader(key);
                    sb.append(convertDisplay(contents));
                    sb.append('\n');
                }
                sb.append("    ]").append('\n');
            }
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);
        assertTrue(str.indexOf("<hello/>") == -1);

        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);
        assertTrue(str.indexOf("<hello/>") != -1);

        // now switch to suppression mode
        System.setProperty(ExchangeUtils.SYSTEM_PROPERTY_SUPPRESS_CONTENT, "true");

        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);
        assertTrue(str.indexOf("<hello/>") == -1);
    }
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

    }
   

    @Override
    protected ServiceMixMessage createInMessage() {
        Message msg = exchange.getIn(true);
        return msg != null ? new ServiceMixMessage(msg) : null;
    }
View Full Code Here

        return msg != null ? new ServiceMixMessage(msg) : null;
    }

    @Override
    protected ServiceMixMessage createOutMessage() {
        Message msg = exchange.getOut(true);
        return msg != null ? new ServiceMixMessage(msg) : null;
    }
View Full Code Here

        return msg != null ? new ServiceMixMessage(msg) : null;
    }
   
    @Override
    protected org.apache.camel.Message createFaultMessage() {
        Message msg = exchange.getFault(true);
        return msg != null ? new ServiceMixMessage(msg) : null;
    }
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.