I'm very newbie to this messaging queue and just started learning some basic stuffs in this.
So for our spring boot application we followed an architecture like contoller talks to service & service talks to repository so here i have to create one controller that will accept a class DTO as a json and post these information to the message queue specified in the apache camel. I'm following this link ! for my reference that works well but when i tried to implement it in my project , it saying me an error listed below.
Error
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'trackerQueueController': Unsatisfied dependency expressed through field 'camelContext'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.apache.camel.CamelContext' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
I have created an controller,routes & processor as below:
Controller
@RestController
@RequestMapping("/deviceinfo")
public class TrackerQueueController {
@Autowired
CamelContext camelContext;
@Autowired
private
ProducerTemplate producerTemplate;
@PostMapping()
public void startCamel(@RequestBody FieldUpdate fieldUpdate) {
producerTemplate.sendBody("activemq:topic:in", fieldUpdate);
}
}
Routes
@Component
public class TrackerQueueRoutes extends RouteBuilder {
@Override
public void configure() throws Exception {
from("activemq:topic:in")
.process(new TrackerProcessor() {
@Override
public void process(Exchange exchange) throws
Exception {
log.info("I'm in");
FieldUpdate body =
exchange.getIn().getBody(FieldUpdate.class);
log.info("Hello from camel processed message!
Received payload: {}" , body.getSerialNumber());
exchange.getOut().setHeader(Exchange.HTTP_RESPONSE_CODE,
HttpStatus.ACCEPTED);
}
});
}
}
Processor
public class TrackerProcessor implements Processor {
@Override
public void process(Exchange exchange) throws Exception {
}
}
Can any one provide me some tutorial link that fulfil my need or any ideas.