Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3641

How to make post request in apache camel rest

$
0
0

I am new apache rest dsl with spring boot, have made following changes

Main Class

package com.javaoutofbounds.pojo;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication(scanBasePackages = {"com.ccs.batchfile"})public class BatchFileApplication {    public static void main(String[] args) {        SpringApplication.run(BatchFileApplication.class, args);    }}

Service class

package com.ccs.batchfile.service;import org.apache.camel.builder.RouteBuilder;import org.apache.camel.model.rest.RestBindingMode;import org.springframework.stereotype.Component;@Componentpublic class BatchFileService extends RouteBuilder {    @Override    public void configure() throws Exception {        restConfiguration().component("servlet").bindingMode(RestBindingMode.json);        rest("/batchFile").consumes("application/json").produces("application/json").get("/routeStart").to("direct:startRoute");    }}

Route class

package com.ccs.batchfile.routes;import org.apache.camel.builder.RouteBuilder;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Component;import com.ccs.batchfile.processor.StartRouteProcessor;@Componentpublic class StartRoute  extends RouteBuilder{     @Autowired     private StartRouteProcessor startRouteProcessor;    @Override    public void configure() throws Exception {        from("direct:startRoute").log("Inside StartRoute")        .process(startRouteProcessor);    }}

Processor class

package com.ccs.batchfile.processor;import org.apache.camel.Exchange;import org.apache.camel.Processor;import org.springframework.stereotype.Component;@Component("startRouteProcessor")public class StartRouteProcessor implements Processor{    public void process(Exchange exchange) throws Exception {        String message = exchange.getIn().getBody(String.class);        System.out.println(message);    }}

I am not getting control to StartRouteProcessor, when i make below post request in postman

http://localhost:8080/batchFile/routeStart/

I have used below test payload to check if works.

{"title" : "test title","singer" : "some singer"}

When i post the above request i am getting 404 error. Kindly help on this please


Viewing all articles
Browse latest Browse all 3641

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>