Search in sources :

Example 21 with DefaultMessage

use of org.apache.camel.impl.DefaultMessage in project camel by apache.

the class ZooKeeperUtilsTest method testModeInMessage.

private CreateMode testModeInMessage(String mode, CreateMode defaultMode) {
    Message m = new DefaultMessage();
    m.setHeader(ZooKeeperMessage.ZOOKEEPER_CREATE_MODE, mode);
    return getCreateMode(m, defaultMode);
}
Also used : DefaultMessage(org.apache.camel.impl.DefaultMessage) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage)

Example 22 with DefaultMessage

use of org.apache.camel.impl.DefaultMessage in project camel by apache.

the class ZipIterator method getNextElement.

private Message getNextElement() {
    if (zipInputStream == null) {
        return null;
    }
    try {
        ZipEntry current = getNextEntry();
        if (current != null) {
            LOGGER.debug("read zipEntry {}", current.getName());
            Message answer = new DefaultMessage();
            answer.getHeaders().putAll(inputMessage.getHeaders());
            answer.setHeader("zipFileName", current.getName());
            answer.setHeader(Exchange.FILE_NAME, current.getName());
            answer.setBody(new ZipInputStreamWrapper(zipInputStream));
            return answer;
        } else {
            LOGGER.trace("close zipInputStream");
            return null;
        }
    } catch (IOException exception) {
        //Just wrap the IOException as CamelRuntimeException
        throw new RuntimeCamelException(exception);
    }
}
Also used : DefaultMessage(org.apache.camel.impl.DefaultMessage) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage) ZipEntry(java.util.zip.ZipEntry) RuntimeCamelException(org.apache.camel.RuntimeCamelException) IOException(java.io.IOException)

Example 23 with DefaultMessage

use of org.apache.camel.impl.DefaultMessage in project camel by apache.

the class TarIterator method getNextElement.

private Message getNextElement() {
    if (tarInputStream == null) {
        return null;
    }
    try {
        TarArchiveEntry current = getNextEntry();
        if (current != null) {
            LOGGER.debug("Reading tarEntry {}", current.getName());
            Message answer = new DefaultMessage();
            answer.getHeaders().putAll(inputMessage.getHeaders());
            answer.setHeader(TARFILE_ENTRY_NAME_HEADER, current.getName());
            answer.setHeader(Exchange.FILE_NAME, current.getName());
            if (current.getSize() > 0) {
                answer.setBody(new TarElementInputStreamWrapper(tarInputStream));
            } else {
                // Workaround for the case when the entry is zero bytes big
                answer.setBody(new ByteArrayInputStream(new byte[0]));
            }
            return answer;
        } else {
            LOGGER.trace("Closed tarInputStream");
            return null;
        }
    } catch (IOException exception) {
        //Just wrap the IOException as CamelRuntimeException
        throw new RuntimeCamelException(exception);
    }
}
Also used : DefaultMessage(org.apache.camel.impl.DefaultMessage) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage) ByteArrayInputStream(java.io.ByteArrayInputStream) RuntimeCamelException(org.apache.camel.RuntimeCamelException) IOException(java.io.IOException) TarArchiveEntry(org.apache.commons.compress.archivers.tar.TarArchiveEntry)

Example 24 with DefaultMessage

use of org.apache.camel.impl.DefaultMessage in project camel by apache.

the class AbstractProducerTestSupport method before.

@Before
public void before() throws IOException {
    msg = new DefaultMessage();
    when(exchange.getIn()).thenReturn(msg);
}
Also used : DefaultMessage(org.apache.camel.impl.DefaultMessage) Before(org.junit.Before)

Example 25 with DefaultMessage

use of org.apache.camel.impl.DefaultMessage in project camel by apache.

the class RabbitMQMessageConverter method resolveMessageFrom.

private Message resolveMessageFrom(final Exchange camelExchange, final boolean out) {
    Message message;
    if (out) {
        // use OUT message
        message = camelExchange.getOut();
    } else {
        if (camelExchange.getIn() != null) {
            // Use the existing message so we keep the headers
            message = camelExchange.getIn();
        } else {
            message = new DefaultMessage();
            camelExchange.setIn(message);
        }
    }
    return message;
}
Also used : DefaultMessage(org.apache.camel.impl.DefaultMessage) Message(org.apache.camel.Message) DefaultMessage(org.apache.camel.impl.DefaultMessage)

Aggregations

DefaultMessage (org.apache.camel.impl.DefaultMessage)45 Message (org.apache.camel.Message)44 Exchange (org.apache.camel.Exchange)22 DefaultExchange (org.apache.camel.impl.DefaultExchange)19 Test (org.junit.Test)16 HashMap (java.util.HashMap)15 IOException (java.io.IOException)4 Method (java.lang.reflect.Method)3 NoSuchElementException (java.util.NoSuchElementException)3 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)3 Before (org.junit.Before)3 Map (java.util.Map)2 BiFunction (java.util.function.BiFunction)2 BasicAttribute (javax.naming.directory.BasicAttribute)2 BasicAttributes (javax.naming.directory.BasicAttributes)2 ModificationItem (javax.naming.directory.ModificationItem)2 Processor (org.apache.camel.Processor)2 RuntimeCamelException (org.apache.camel.RuntimeCamelException)2 FileStatus (org.apache.hadoop.fs.FileStatus)2 Path (org.apache.hadoop.fs.Path)2