GatewayRouterBuilder.java 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package camel.central.gateway.route;
  2. import camel.central.gateway.processor.GatewayProcessor;
  3. import camel.central.gateway.processor.WsProcessor;
  4. import org.apache.camel.Exchange;
  5. import org.apache.camel.builder.RouteBuilder;
  6. import org.springframework.stereotype.Component;
  7. /**
  8. * @author HZY
  9. * @vsrsion 1.0
  10. * Created at 2017/3/13.
  11. */
  12. @Component
  13. public class GatewayRouterBuilder extends RouteBuilder {
  14. protected static final String SIMPLE_ENDPOINT_ADDRESS = "http://0.0.0.0:3333/ws/api";
  15. protected static final String SIMPLE_ENDPOINT_URI = "cxf:" + SIMPLE_ENDPOINT_ADDRESS
  16. + "?serviceClass=camel.central.gateway.processor.WsService"
  17. // + "&dataFormat=CXF_MESSAGE"
  18. ;
  19. @Override
  20. public void configure() throws Exception {
  21. from("jetty:http://0.0.0.0:9998?matchOnUriPrefix=true").routeId("proxy")
  22. .to("jetty:http://192.168.1.221:10000?bridgeEndpoint=true&throwExceptionOnFailure=false");
  23. from("jetty:http://0.0.0.0:9999/api").routeId("api")
  24. .process(new GatewayProcessor())
  25. .routingSlip(method(GatewayProcessor.class, "route"));
  26. from("jetty:http://0.0.0.0:9999/healthy").routeId("healthy")
  27. .log("=========================心跳测试=====================");
  28. from(SIMPLE_ENDPOINT_URI)
  29. .setHeader(Exchange.BEAN_MULTI_PARAMETER_ARRAY, constant(true))
  30. .process(new WsProcessor())
  31. .routingSlip(method(GatewayProcessor.class, "route"))
  32. .to("bean:wsProcessor?method=responseWs");
  33. }
  34. }