1 Star 0 Fork 1

寒松/camel-spring-boot-examples2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
README.adoc 3.32 KB
一键复制 编辑 原始数据 按行查看 历史

Spring Boot REST DSL / JPA Example

Introduction

This example demonstrates how to use JPA and Spring Data along with Camel’s REST DSL to expose a RESTful API that performs CRUD operations on a database.

It generates orders for books referenced in database at a regular pace. Orders are processed asynchronously by another Camel route. Books available in database as well as the status of the generated orders can be retrieved via the REST API.

It relies on Swagger to expose the API documentation of the REST service.

Build

You can build this example using:

$ mvn package

Run

You can run this example with Maven using:

$ mvn spring-boot:run -Dspring.profiles.active=dev

Alternatively, you can also run this example using the executable JAR:

$ java -jar -Dspring.profiles.active=dev target/camel-example-spring-boot-rest-jpa-${project.version}.jar

This uses an embedded in-memory HSQLDB database. You can use the default Spring Boot profile in case you have a MySQL server available for you to test.

When the Camel application runs, you should see the following messages being logged to the console, e.g.:

2016-09-02 09:54:29.702  INFO 27253 --- [mer://new-order] generate-order : Inserted new order 1
2016-09-02 09:54:31.597  INFO 27253 --- [mer://new-order] generate-order : Inserted new order 2
2016-09-02 09:54:33.596  INFO 27253 --- [mer://new-order] generate-order : Inserted new order 3
2016-09-02 09:54:34.637  INFO 27253 --- [rts.camel.Order] process-order  : Processed order #id 1 with 7 copies of the «Camel in Action» book
2016-09-02 09:54:34.641  INFO 27253 --- [rts.camel.Order] process-order  : Processed order #id 2 with 4 copies of the «Camel in Action» book
2016-09-02 09:54:34.645  INFO 27253 --- [rts.camel.Order] process-order  : Processed order #id 3 with 1 copies of the «ActiveMQ in Action» book
2016-09-02 09:54:35.597  INFO 27253 --- [mer://new-order] generate-order : Inserted new order 4
2016-09-02 09:54:37.601  INFO 27253 --- [mer://new-order] generate-order : Inserted new order 5
2016-09-02 09:54:39.605  INFO 27253 --- [mer://new-order] generate-order : Inserted new order 6
2016-09-02 09:54:39.668  INFO 27253 --- [rts.camel.Order] process-order  : Processed order #id 4 with 7 copies of the «Camel in Action» book
2016-09-02 09:54:39.671  INFO 27253 --- [rts.camel.Order] process-order  : Processed order #id 5 with 1 copies of the «ActiveMQ in Action» book
2016-09-02 09:54:39.674  INFO 27253 --- [rts.camel.Order] process-order  : Processed order #id 6 with 4 copies of the «Camel in Action» book

You can then access the REST API directly from your Web browser, e.g.:

The Camel application can be stopped pressing ctrl+c in the shell.

Swagger API

The example provides API documentation of the service using Swagger using the context-path camel-rest-jpa/api-doc. You can access the API documentation from your Web browser at http://localhost:8080/camel-rest-jpa/api-doc.

Help and contributions

If you hit any problem using Camel or have some feedback, then please let us know.

We also love contributors, so get involved :-)

The Camel riders!

马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/qqzahng/camel-spring-boot-examples2.git
git@gitee.com:qqzahng/camel-spring-boot-examples2.git
qqzahng
camel-spring-boot-examples2
camel-spring-boot-examples2
camel-3.4.x

搜索帮助

0d507c66 1850385 C8b1a773 1850385