org.apache.camel.Body Java Examples

The following examples show how to use org.apache.camel.Body. 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: ActivitiRouteBuilder.java    From servicemix with Apache License 2.0 5 votes vote down vote up
@Handler
public Map getProcessVariables(@Body String body,
                               @Header(Exchange.FILE_NAME) String filename,
                               @Simple("${date:now:yyyy-MM-dd kk:mm:ss}") String timestamp) {
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("message", body);
    variables.put("orderid", filename);
    variables.put("timestamp", timestamp);
    return variables;
}
 
Example #2
Source File: BusinessRulesBean.java    From iot-ocp with Apache License 2.0 5 votes vote down vote up
public Measure processRules(@Body Measure measure) {
	
	KieServicesConfiguration config = KieServicesFactory.newRestConfiguration(
			kieHost, kieUser,
			kiePassword);
	
	Set<Class<?>> jaxBClasses = new HashSet<Class<?>>();
	jaxBClasses.add(Measure.class);
	
	config.addJaxbClasses(jaxBClasses);
	config.setMarshallingFormat(MarshallingFormat.JAXB);
	RuleServicesClient client = KieServicesFactory.newKieServicesClient(config)
			.getServicesClient(RuleServicesClient.class);

       List<Command<?>> cmds = new ArrayList<Command<?>>();
	KieCommands commands = KieServices.Factory.get().getCommands();
	cmds.add(commands.newInsert(measure));
	
    GetObjectsCommand getObjectsCommand = new GetObjectsCommand();
    getObjectsCommand.setOutIdentifier("objects");

	
	cmds.add(commands.newFireAllRules());
	cmds.add(getObjectsCommand);
	BatchExecutionCommand myCommands = CommandFactory.newBatchExecution(cmds,
			"DecisionTableKS");
	ServiceResponse<ExecutionResults> response = client.executeCommandsWithResults("iot-ocp-businessrules-service", myCommands);
			
	List responseList = (List) response.getResult().getValue("objects");
	
	Measure responseMeasure = (Measure) responseList.get(0);
	
	return responseMeasure;

}
 
Example #3
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 #4
Source File: CartService.java    From camelinaction2 with Apache License 2.0 5 votes vote down vote up
public void addItem(@Header("sessionId") String sessionId, @Body CartDto dto) {
    LOG.info("addItem {} {}", sessionId, dto);

    Set<CartDto> dtos = content.get(sessionId);
    if (dtos == null) {
        dtos = new LinkedHashSet<>();
        content.put(sessionId, dtos);
    }
    dtos.add(dto);
}
 
Example #5
Source File: CartService.java    From camelinaction2 with Apache License 2.0 5 votes vote down vote up
public void addItem(@Header("sessionId") String sessionId, @Body CartDto dto) {
    LOG.info("addItem {} {}", sessionId, dto);

    Set<CartDto> dtos = content.get(sessionId);
    if (dtos == null) {
        dtos = new LinkedHashSet<>();
        content.put(sessionId, dtos);
    }
    dtos.add(dto);
}
 
Example #6
Source File: XmlOrderService.java    From camelinaction2 with Apache License 2.0 5 votes vote down vote up
public Document handleIncomingOrder(@Body Document xml,
                                    @XPath("/order/@customerId") int customerId,
                                    @Bean(ref = "guid", method = "generate") int orderId) {

    Attr attr = xml.createAttribute("orderId");
    attr.setValue("" + orderId);

    Node node = xml.getElementsByTagName("order").item(0);
    node.getAttributes().setNamedItem(attr);

    return xml;
}
 
Example #7
Source File: XmlOrderNamespaceService.java    From camelinaction2 with Apache License 2.0 5 votes vote down vote up
public Document handleIncomingOrder(@Body Document xml,
                                    @XPath(value = "/c:order/@customerId", 
                                           namespaces = @NamespacePrefix(
                                               prefix = "c",
                                               uri = "http://camelinaction.com/order")) int customerId,
                                    @Bean(ref = "guid", method = "generate") int orderId) {

    Attr attr = xml.createAttribute("orderId");
    attr.setValue("" + orderId);

    Node node = xml.getElementsByTagName("order").item(0);
    node.getAttributes().setNamedItem(attr);

    return xml;
}
 
Example #8
Source File: XmlOrderService.java    From camelinaction with Apache License 2.0 5 votes vote down vote up
public Document handleIncomingOrder(@Body Document xml,
                                    @XPath("/order/@customerId") int customerId,
                                    @Bean(ref = "guid", method = "generate") int orderId) {

    Attr attr = xml.createAttribute("orderId");
    attr.setValue("" + orderId);

    Node node = xml.getElementsByTagName("order").item(0);
    node.getAttributes().setNamedItem(attr);

    return xml;
}
 
Example #9
Source File: XmlOrderNamespaceService.java    From camelinaction with Apache License 2.0 5 votes vote down vote up
public Document handleIncomingOrder(@Body Document xml,
                                    @XPath(value = "/c:order/@customerId", 
                                           namespaces = @NamespacePrefix(
                                               prefix = "c",
                                               uri = "http://camelinaction.com/order")) int customerId,
                                    @Bean(ref = "guid", method = "generate") int orderId) {

    Attr attr = xml.createAttribute("orderId");
    attr.setValue("" + orderId);

    Node node = xml.getElementsByTagName("order").item(0);
    node.getAttributes().setNamedItem(attr);

    return xml;
}
 
Example #10
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 #11
Source File: __extension-name__Extension.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Handler
public void log(@Body Object body){
    if(trace) {
        LOGGER.trace("Body is: {}",body);
    } else {
        LOGGER.info("Body is: {}",body);
    }
}
 
Example #12
Source File: ActionStep.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Handler
public List<Out> process(@Body In body) {
    List<Out> out = new ArrayList<>();
    out.add(new Out());

    return out;
}
 
Example #13
Source File: ActionStep.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Handler
public List<Out> process(@Body In body) {
    List<Out> out = new ArrayList<>();
    out.add(new Out());

    return out;
}
 
Example #14
Source File: HelloBean.java    From wildfly-camel with Apache License 2.0 4 votes vote down vote up
public String sayHello(@Body String message) {
    return "Hello " + message;
}
 
Example #15
Source File: ServiceHandler.java    From servicemix with Apache License 2.0 4 votes vote down vote up
public void getPerson(@Body String id,Exchange exchange){
    Person result = persons.get(Integer.parseInt(id));
    checkResult(id, exchange, result);
}
 
Example #16
Source File: ServiceHandler.java    From servicemix with Apache License 2.0 4 votes vote down vote up
public void deletePerson(@Body String id,Exchange exchange){
    Person result = persons.remove(Integer.parseInt(id));
    checkResult(id, exchange, result);
}
 
Example #17
Source File: OrderBean.java    From wildfly-camel with Apache License 2.0 4 votes vote down vote up
public String orderStatus(@Header("customerId") Integer customerId, @Body Integer orderId) {
    return "Order " + orderId + " from customer " + customerId;
}
 
Example #18
Source File: ExtensionStepHandlerTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Handler
public void handle(@Body String body) {
    // NO-OP
}
 
Example #19
Source File: MyBean.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@SuppressWarnings("static-method")
public String myProcessor(@Body String body) {
    return body.toUpperCase(Locale.US);
}
 
Example #20
Source File: ComponentProxyComponentTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
public String process(@Body String body) {
    return body.toUpperCase(Locale.US);
}
 
Example #21
Source File: ComponentProxyCustomizerWithPlaceholdersTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
public String process(@Body String body) {
    return body.toUpperCase(Locale.US);
}
 
Example #22
Source File: ComponentProxyCustomizerTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
public String process(@Body String body) {
    return body.toUpperCase(Locale.US);
}
 
Example #23
Source File: ComponentProxyGlobalCustomizerTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
public String process(@Body String body) {
    return body.toUpperCase(Locale.US);
}
 
Example #24
Source File: ComponentProxyFactoryTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
public String process(@Body String body) {
    return body.toUpperCase(Locale.US);
}
 
Example #25
Source File: ComponentProxyCustomizerAddPropertyTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
public String process(@Body String body) {
    return body.toUpperCase(Locale.US);
}
 
Example #26
Source File: OutMessageCaptureProcessorTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Handler
public String[] apply(@Body String body) {
    return new String[]{ "Hiram", "World" };
}
 
Example #27
Source File: OutMessageCaptureProcessorTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Handler
public int apply(@Body String body) {
    return body.hashCode();
}
 
Example #28
Source File: OutMessageCaptureProcessorTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Handler
public String apply(@Body String body) {
    return "Hello " + body;
}