Search in sources :

Example 26 with InvalidPayloadException

use of org.apache.camel.InvalidPayloadException in project camel by apache.

the class InfluxDbProducer method doInsert.

private void doInsert(Exchange exchange, String dataBaseName, String retentionPolicy) throws InvalidPayloadException {
    if (!endpoint.isBatch()) {
        Point p = exchange.getIn().getMandatoryBody(Point.class);
        try {
            LOG.debug("Writing point {}", p.lineProtocol());
            connection.write(dataBaseName, retentionPolicy, p);
        } catch (Exception ex) {
            exchange.setException(new CamelInfluxDbException(ex));
        }
    } else {
        BatchPoints batchPoints = exchange.getIn().getMandatoryBody(BatchPoints.class);
        try {
            LOG.debug("Writing BatchPoints {}", batchPoints.lineProtocol());
            connection.write(batchPoints);
        } catch (Exception ex) {
            exchange.setException(new CamelInfluxDbException(ex));
        }
    }
}
Also used : BatchPoints(org.influxdb.dto.BatchPoints) Point(org.influxdb.dto.Point) InvalidPayloadException(org.apache.camel.InvalidPayloadException)

Aggregations

InvalidPayloadException (org.apache.camel.InvalidPayloadException)26 InputStream (java.io.InputStream)10 Exchange (org.apache.camel.Exchange)9 Message (org.apache.camel.Message)9 Processor (org.apache.camel.Processor)6 IOException (java.io.IOException)5 ByteArrayInputStream (java.io.ByteArrayInputStream)3 UnsupportedEncodingException (java.io.UnsupportedEncodingException)3 XMLStreamException (javax.xml.stream.XMLStreamException)3 Endpoint (org.apache.camel.Endpoint)3 GenericFileOperationFailedException (org.apache.camel.component.file.GenericFileOperationFailedException)3 Entry (java.util.Map.Entry)2 ServletOutputStream (javax.servlet.ServletOutputStream)2 JAXBException (javax.xml.bind.JAXBException)2 GenericFileEndpoint (org.apache.camel.component.file.GenericFileEndpoint)2 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)2 StopWatch (org.apache.camel.util.StopWatch)2 Builder (com.google.protobuf.Message.Builder)1 JSchException (com.jcraft.jsch.JSchException)1 SftpException (com.jcraft.jsch.SftpException)1