<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-cdi</artifactId> <version>3.11.0</version> </dependency> public class OrderEvent { private String orderId; public OrderEvent(String orderId) { this.orderId = orderId; } public String getOrderId() { return orderId; } } @ApplicationScoped public class OrderEventListener { public void onOrderEvent(@Observes OrderEvent event) { String orderId = event.getOrderId(); System.out.println("Received order event for order id: " + orderId); } } import org.apache.camel.builder.RouteBuilder; public class OrderRoute extends RouteBuilder { @Override public void configure() throws Exception { from("direct:orderEvent") .to("bean:orderEventListener"); } } import org.apache.camel.cdi.Main; public class Application { public static void main(String[] args) throws Exception { Main main = new Main(); main.run(); } }


上一篇:
下一篇:
切换中文