-
Notifications
You must be signed in to change notification settings - Fork 0
/
CamelProxy.java
40 lines (27 loc) · 932 Bytes
/
CamelProxy.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package samples.camel.proxy;
import java.util.Date;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.ProxyBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
public class CamelProxy {
public static void main(String[] args) throws Exception {
CamelContext context = new DefaultCamelContext();
OrderService service = new ProxyBuilder(context).endpoint(
"direct:order").build(OrderService.class);
// add our route to the CamelContext
context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
from("direct:order").bean(new OrderProcessor());
}
});
context.start();
// send an order to the Camel route
Order order = new Order(new Date(), 99.90);
String reply = service.sendOrder(order);
// print the result (produced by bean OrderProcessor)
System.out.println(reply);
context.stop();
}
}