org.apache.camel.Headers Java Examples

The following examples show how to use org.apache.camel.Headers. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RngErrorAction.java    From syndesis-extensions with Apache License 2.0 5 votes vote down vote up
@Handler
public void handle(@Body String body, @Headers Map headers, Exchange exchange) {
    Random random = new Random(System.currentTimeMillis());
    if( random.nextBoolean() ) {
        throw new RuntimeCamelException("Random error.. try your luck again next time.");
    }
}
 
Example #2
Source File: MyHelper.java    From iot-ocp with Apache License 2.0 5 votes vote down vote up
public void prepareJdbcHeaders(@Body Measure measure, @Headers Map<String, Object> headers) {

    	headers.put("sensor_type", measure.getSensorType());
    	headers.put("data_type", measure.getDataType());
    	headers.put("device_id", measure.getDeviceId());
    	headers.put("category", measure.getCategory());
    	headers.put("payload", measure.getPayload());
    	headers.put("error_code", measure.getErrorCode());
    	headers.put("error_message", measure.getErrorMessage());
    	headers.put("time_stamp", measure.getTimestamp());

    }
 
Example #3
Source File: OrderToSqlBean.java    From camelinaction2 with Apache License 2.0 5 votes vote down vote up
public String toSql(@XPath("order/@name") String name,
                    @XPath("order/@amount") int amount,
                    @XPath("order/@customer") String customer,
                    @Headers Map<String, Object> outHeaders) {
    outHeaders.put("partName", name);
    outHeaders.put("quantity", amount);
    outHeaders.put("customer", customer);
    return "insert into incoming_orders (part_name, quantity, customer) values (:?partName, :?quantity, :?customer)";
}
 
Example #4
Source File: RoutingSlipAnnotated.java    From camel-cookbook-examples with Apache License 2.0 5 votes vote down vote up
@Consume(uri = "direct:start")
@RoutingSlip(delimiter = ",")
public List<String> routeMe(String body, @Headers Map<String, Object> headers) {
    ArrayList<String> results = new ArrayList<String>();

    Object slip = headers.get("myRoutingSlipHeader");
    if (slip != null) {
        String[] uris = slip.toString().split(",");
        Collections.addAll(results, uris);
    }

    results.add("mock:oneMore");

    return results;
}
 
Example #5
Source File: FailureBean.java    From camelinaction2 with Apache License 2.0 4 votes vote down vote up
public void enrich(@Headers Map headers, Exception cause) throws Exception {
    String failure = "The message failed because " + cause.getMessage();
    headers.put("FailureMessage", failure);
}