v1.0.0 Added activemq6 and bruno test case files

master
Ng Yat Yan 2 weeks ago
parent 5ba204bd59
commit 7e5d4b6062

@ -0,0 +1,9 @@
{
"version": "1",
"name": "camel-springboot-xml-example",
"type": "collection",
"ignore": [
"node_modules",
".git"
]
}

@ -0,0 +1,11 @@
meta {
name: findUsers
type: http
seq: 2
}
get {
url: http://localhost:9090/services/api/user
body: none
auth: none
}

@ -3,3 +3,6 @@ server:
camel: camel:
springboot: springboot:
main-run-controller: true main-run-controller: true
spring:
activemq:
broker-url: "tcp://localhost:61616"

@ -3,13 +3,13 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId> <groupId>com.example</groupId>
<artifactId>camel-springboot-xml-example</artifactId> <artifactId>camel-springboot-activemq6-example</artifactId>
<version>0.0.2</version> <version>1.0.0</version>
<name>camel-springboot-xml-example</name> <name>camel-springboot-activemq6-example</name>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.2</version> <version>3.3.7</version>
</parent> </parent>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -21,60 +21,67 @@
</properties> </properties>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.apache.camel.springboot</groupId> <groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-bom</artifactId> <artifactId>camel-spring-boot-bom</artifactId>
<version>${camel.version}</version> <version>${camel.version}</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId> <artifactId>spring-boot-dependencies</artifactId>
<version>${springboot.version}</version> <version>${springboot.version}</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<dependencies> <dependencies>
<!-- Spring Boot --> <!-- Spring Boot -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<!-- Camel --> <!-- Camel -->
<dependency> <dependency>
<groupId>org.apache.camel.springboot</groupId> <groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-log-starter</artifactId> <artifactId>camel-log-starter</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.camel.springboot</groupId> <groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-bean-starter</artifactId> <artifactId>camel-bean-starter</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.camel.springboot</groupId> <groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-bean-validator-starter</artifactId> <artifactId>camel-bean-validator-starter</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.camel.springboot</groupId> <groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-cxf-rest-starter</artifactId> <artifactId>camel-cxf-rest-starter</artifactId>
</dependency> </dependency>
<dependency>
<!-- jax-rs json provider from jackson --> <groupId>org.apache.camel.springboot</groupId>
<dependency> <artifactId>camel-activemq6-starter</artifactId>
<groupId>com.fasterxml.jackson.jakarta.rs</groupId> </dependency>
<artifactId>jackson-jakarta-rs-json-provider</artifactId> <dependency>
</dependency> <groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-jackson-starter</artifactId>
</dependency>
<!-- jax-rs json provider from jackson -->
<dependency>
<groupId>com.fasterxml.jackson.jakarta.rs</groupId>
<artifactId>jackson-jakarta-rs-json-provider</artifactId>
</dependency>
<!-- CXF WADL definition--> <!-- CXF WADL definition-->
<dependency> <dependency>
<groupId>org.apache.cxf</groupId> <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-service-description</artifactId> <artifactId>cxf-rt-rs-service-description</artifactId>
<version>${cxf.version}</version> <version>${cxf.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>

@ -23,6 +23,7 @@ public class Boot {
System.setProperty("spring.config.location", configDirectory + "/springboot.yml"); System.setProperty("spring.config.location", configDirectory + "/springboot.yml");
System.setProperty("logging.config", configDirectory + "/logback.xml"); System.setProperty("logging.config", configDirectory + "/logback.xml");
} }
System.setProperty("org.apache.activemq.SERIALIZABLE_PACKAGES","*");
SpringApplication.run(Boot.class, args); SpringApplication.run(Boot.class, args);
} }

@ -3,7 +3,7 @@ package com.example.camel;
import org.apache.camel.Exchange; import org.apache.camel.Exchange;
import org.apache.camel.builder.RouteBuilder; import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.bean.validator.BeanValidationException; import org.apache.camel.component.bean.validator.BeanValidationException;
import org.apache.camel.model.dataformat.JsonLibrary;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import jakarta.ws.rs.core.Response; import jakarta.ws.rs.core.Response;
@ -11,25 +11,18 @@ import jakarta.ws.rs.core.Response;
@Component @Component
public class CamelRouter extends RouteBuilder { public class CamelRouter extends RouteBuilder {
@Override @Override
public void configure() throws Exception { public void configure() throws Exception {
//very raw way, just to handle the validation responses // very raw way, just to handle the validation responses
onException(BeanValidationException.class) onException(BeanValidationException.class).handled(true)
.handled(true) .setHeader(Exchange.HTTP_RESPONSE_CODE, constant(Response.Status.BAD_REQUEST.getStatusCode()))
.setHeader(Exchange.HTTP_RESPONSE_CODE, constant(Response.Status.BAD_REQUEST.getStatusCode())) .setBody(simple("${exchangeProperty.CamelExceptionCaught.getMessage()}"));
.setBody(simple("${exchangeProperty.CamelExceptionCaught.getMessage()}"));
// @formatter:off from("cxfrs:/api?resourceClasses=" + UserService.class.getName() + "&bindingStyle=SimpleConsumer"
from("cxfrs:/api?" + + "&providers=jaxrsProvider&loggingFeatureEnabled=true").to("bean-validator:user")
"resourceClasses="+UserService.class.getName() + .setHeader(Exchange.BEAN_METHOD_NAME, simple("${header.operationName}")).to("activemq6:queue:UserService");
"&bindingStyle=SimpleConsumer" + from("activemq6:queue:UserService").to("log:camel-cxf-log?showAll=true").bean(UserServiceImpl.class).marshal()
"&providers=jaxrsProvider" + .json(JsonLibrary.Jackson);
"&loggingFeatureEnabled=true") }
.to("bean-validator:user")
.to("log:camel-cxf-log?showAll=true")
.setHeader(Exchange.BEAN_METHOD_NAME, simple("${header.operationName}"))
.bean(UserServiceImpl.class);
// @formatter:on
}
} }
Loading…
Cancel
Save