diff --git a/conf/springboot.yml b/conf/springboot.yml index d175418..1fea45b 100644 --- a/conf/springboot.yml +++ b/conf/springboot.yml @@ -6,3 +6,5 @@ camel: spring: activemq: broker-url: "tcp://localhost:61616" +app: + queue-name: "UserServiceQueue" \ No newline at end of file diff --git a/pom.xml b/pom.xml index 1cd9ca9..d7ece2d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 com.example camel-springboot-activemq6-example - 1.0.0 + 1.0.1 camel-springboot-activemq6-example org.springframework.boot @@ -15,8 +15,7 @@ UTF-8 17 17 - 4.8.2 - 4.0.6 + 4.8.3 ${project.parent.version} @@ -70,17 +69,15 @@ org.apache.camel.springboot camel-jackson-starter - - com.fasterxml.jackson.jakarta.rs - jackson-jakarta-rs-json-provider + org.apache.camel.springboot + camel-disruptor-starter - + - org.apache.cxf - cxf-rt-rs-service-description - ${cxf.version} + com.fasterxml.jackson.jakarta.rs + jackson-jakarta-rs-json-provider diff --git a/src/main/java/com/example/camel/CamelRouter.java b/src/main/java/com/example/camel/CamelRouter.java index 634f915..bb36e5c 100644 --- a/src/main/java/com/example/camel/CamelRouter.java +++ b/src/main/java/com/example/camel/CamelRouter.java @@ -4,6 +4,7 @@ import org.apache.camel.Exchange; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.bean.validator.BeanValidationException; import org.apache.camel.model.dataformat.JsonLibrary; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import jakarta.ws.rs.core.Response; @@ -11,6 +12,9 @@ import jakarta.ws.rs.core.Response; @Component public class CamelRouter extends RouteBuilder { + @Value("${app.queue-name}") + private String queueName; + @Override public void configure() throws Exception { // very raw way, just to handle the validation responses @@ -19,9 +23,13 @@ public class CamelRouter extends RouteBuilder { .setBody(simple("${exchangeProperty.CamelExceptionCaught.getMessage()}")); from("cxfrs:/api?resourceClasses=" + UserService.class.getName() + "&bindingStyle=SimpleConsumer" - + "&providers=jaxrsProvider&loggingFeatureEnabled=true").to("bean-validator:user") - .setHeader(Exchange.BEAN_METHOD_NAME, simple("${header.operationName}")).to("activemq6:queue:UserService"); - from("activemq6:queue:UserService").to("log:camel-cxf-log?showAll=true").bean(UserServiceImpl.class).marshal() + + "&providers=jaxrsProvider&loggingFeatureEnabled=true").to("log:cxfrs-log?showAll=true") + .to("bean-validator:user").setHeader(Exchange.BEAN_METHOD_NAME, simple("${header.operationName}")) + .to("activemq6:queue:"+queueName); + + from("activemq6:queue:"+queueName).to("log:activemq6-log?showAll=true").to("disruptor:UserDisruptor"); + + from("disruptor:UserDisruptor").to("log:disruptor-log?showAll=true").bean(UserServiceImpl.class).marshal() .json(JsonLibrary.Jackson); }