apache - 阿帕奇骆驼和码头
问题描述
我想保存来自本地主机的内容({
enter code here
"id": 1,
"prename": "Noel",
"surname": "Reyes",
"dateOfBirth": "1988-09-07",
"birthPlace": "Bad Ems",
"gender": "M"}
) 在 txt.file 中。但:
public void configure() throws Exception {
from("jetty:http://localhost:8091/customers/")
.setHeader(Exchange.HTTP_METHOD, constant("POST"))
.convertBodyTo(String.class)
.log("Test3 ${body}")
.to("file:dest")
.end();
我的 route1 开始并从 localhost 使用,但它没有将其保存在 text.file 中。你能帮助我吗?
解决方案
您的路线不会从本地主机消耗。实际上,您使用 jetty 作为消费者(from),这意味着您提供了端点,以便以后可以从浏览器中调用它。
我认为您想创建一个生产者(to)来调用该服务。这可以通过 camel-http4 组件来完成。
因此,您需要一个开始的路线,比如说通过一个计时器(每 5 秒),并且您需要调用您的端点:
from("timer://foo?period=5s")
.to("http4://localhost:8091/customers/")
.log("Test3 ${body}")
.to("file:dest");
推荐阅读
- amazon-web-services - 列出超过 x 天/月的 ami
- html - Flexbox - same height on all cards
- java - 试图理解java中的类继承
- reporting-services - 如何从多选 ssrs 报告参数中的多维数组中获取两个值?
- arrays - 使用 Powershell 的 ConvertFrom-Json 解析 JSON
- reactjs - 使用服务器端 React 和 React Router v4 在 Redux 操作中进行 URL 重定向
- wix - Wix - ServiceControl 启动需要四分钟才能失败,应该是 30 秒
- r - 如何使用 R 中的 dplyr 获取变量的总和,仅针对另一个变量的一个值
- c - linux lockf、flock和fcntl下C语言锁文件是什么意思?
- azure - Azure 门户中禁用的 Web 应用的“部署选项”