Uploaded image for project: 'Red Hat Fuse'
  1. Red Hat Fuse
  2. ENTESB-6613

CXF http-jetty transport Reverse Proxy configuration will not work when using Camel annotation @BeanInject in RouteBuilder bean

    XMLWordPrintable

    Details

      Description

      I build my Camel CXF routes using Java DSL. Inside my RouteBuilder I inject another bean from registry using Camel annotation @BeanInject.

      public class GreeterBuilder extends RouteBuilder {
      
          @BeanInject
          Configuration configuration;
      
          private CxfEndpoint endpoint;
      
          @Override
          public void configure() throws Exception {
      
              registerWsEndpoint();
      
              buildRoutes();
          }
      
          //public GreeterBuilder() {
          //    this.configuration = configuration;
          //}
      
          public void buildRoutes() {
      ...
      

      I also configure CXF http-jetty transport with reverse proxy inside blueprint context and set "forwarder=true" on org.eclipse.jetty.server.nio.SelectChannelConnector.

      <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                 xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
                 xsi:schemaLocation="
                 http://www.osgi.org/xmlns/blueprint/v1.0.0
                 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
                ">
      
        <httpj:engine-factory bus="cxf">
          <httpj:engine port="7771">
            <httpj:connector>
              <bean id="connector" class="org.eclipse.jetty.server.nio.SelectChannelConnector">
                <property name="port" value="7771"/>
                <property name="forwarded" value="true"/>
              </bean>
            </httpj:connector>
      
          </httpj:engine>
        </httpj:engine-factory>
      
        <bean id="greeterId" class="org.jboss.fuse.samples.camelcxf.GreeterBuilder"/>
      
        <bean id="config" class="org.jboss.fuse.samples.camelcxf.config.ConfigurationImpl"/>
      
        <camelContext id="camel-demo" xmlns="http://camel.apache.org/schema/blueprint"
                      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                      xsi:schemaLocation="http://camel.apache.org/schema/blueprint ">
          <routeBuilder ref="greeterId"/>
        </camelContext>
      </blueprint>
      

      However, the reverse proxy won't work as long as the Camel annotation @BeanInject is present in the RouteBuilder bean.

      The workaround is not to use @BeanInject annotation at all. For instance, either passing the "configuration" bean through the RouteBuilder constructor or use blueprint annotation @Inject on the "configuration" instead.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              tadayosi Tadayoshi Sato
              Reporter:
              joe.luo Joe Luo
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: