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:
springboot:
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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>camel-springboot-xml-example</artifactId>
<version>0.0.2</version>
<name>camel-springboot-xml-example</name>
<artifactId>camel-springboot-activemq6-example</artifactId>
<version>1.0.0</version>
<name>camel-springboot-activemq6-example</name>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.2</version>
<version>3.3.7</version>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -62,7 +62,14 @@
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-cxf-rest-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-activemq6-starter</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>

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

@ -3,7 +3,7 @@ package com.example.camel;
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.stereotype.Component;
import jakarta.ws.rs.core.Response;
@ -14,22 +14,15 @@ public class CamelRouter extends RouteBuilder {
@Override
public void configure() throws Exception {
// very raw way, just to handle the validation responses
onException(BeanValidationException.class)
.handled(true)
onException(BeanValidationException.class).handled(true)
.setHeader(Exchange.HTTP_RESPONSE_CODE, constant(Response.Status.BAD_REQUEST.getStatusCode()))
.setBody(simple("${exchangeProperty.CamelExceptionCaught.getMessage()}"));
// @formatter:off
from("cxfrs:/api?" +
"resourceClasses="+UserService.class.getName() +
"&bindingStyle=SimpleConsumer" +
"&providers=jaxrsProvider" +
"&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
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()
.json(JsonLibrary.Jackson);
}
}
Loading…
Cancel
Save