239.5. 例子

在下面的路由中,我们使用 Netty HTTP 作为 HTTP 服务器,这将返回硬编码"Bye World"消息。

    from("netty-http:http://0.0.0.0:8080/foo")
      .transform().constant("Bye World");

此外,我们还可以使用 Camel 调用此 HTTP 服务器,并带有 ProducerTemplate,如下所示:

    String out = template.requestBody("netty-http:http://localhost:8080/foo", "Hello World", String.class);
    System.out.println(out);

我们再回到"按世界"作为输出。