evgeniy44
evgeniy44

Reputation: 3162

Camel jetty component, custom header filter strategy

I work with jetty component using camel framework.

I have two questions:

1) I work with big messages(about 1mb) and jetty component reads the message body into camel exchange header. It causes such errors:

WARN  header full: java.lang.RuntimeException: Header>6144

So, how can I make jetty component do not put HttpRequest body into headers?

2) When I tried to override default HeaderFilterStrategy I wrote such chunk of code:

SimpleRegistry registry = new SimpleRegistry();
CamelContext context = new DefaultCamelContext(registry);

HeaderFilterStrategy strategy = new NewHeaderFilterStrategy();

registry.put("str", strategy);
context.addRoutes(new RouteBuilder() {
  public void configure() {

    from("jetty:http://my.host:32278/general-nr/notify?headerFilterStrategy=str")
    .....
});

It caused such exception:

Exception in thread "main" org.apache.camel.FailedToCreateRouteException: Failed to create route route1: Route[[From[jetty:http://my.host:32278/general-nr/notify?hea... because of Failed to resolve endpoint: jetty://http://my.host:32278/general-nr/notify?headerFilterStrategy=str due to: Could not find a suitable setter for property: headerFilterStrategy as there isn't a setter method with same type: java.lang.String nor type conversion possible: No type converter available to convert from type: java.lang.String to the required type: org.apache.camel.spi.HeaderFilterStrategy with value str
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:177)
at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:722)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1789)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1575)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1444)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1412)
at org.apache.camel.example.jmstofile.ElfRouterExample.main(ElfRouterExample.java:98)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: jetty://http://my.host:32278/general-nr/notify?headerFilterStrategy=str due to: Could not find a suitable setter for property: headerFilterStrategy as there isn't a setter method with same type: java.lang.String nor type conversion possible: No type converter available to convert from type: java.lang.String to the required type: org.apache.camel.spi.HeaderFilterStrategy with value str at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:479) at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:50) at org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:187) at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:108) at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:114) at org.apache.camel.model.FromDefinition.resolveEndpoint(FromDefinition.java:72) at org.apache.camel.impl.DefaultRouteContext.getEndpoint(DefaultRouteContext.java:90) at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:857) at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:172) ... 12 more Caused by: java.lang.IllegalArgumentException: Could not find a suitable setter for property: headerFilterStrategy as there isn't a setter method with same type: java.lang.String nor type conversion possible: No type converter available to convert from type: java.lang.String to the required type: org.apache.camel.spi.HeaderFilterStrategy with value str at org.apache.camel.util.IntrospectionSupport.setProperty(IntrospectionSupport.java:347) at org.apache.camel.util.IntrospectionSupport.setProperty(IntrospectionSupport.java:367) at org.apache.camel.util.IntrospectionSupport.setProperties(IntrospectionSupport.java:297) at org.apache.camel.util.EndpointHelper.setProperties(EndpointHelper.java:249) at org.apache.camel.impl.DefaultComponent.setProperties(DefaultComponent.java:222) at org.apache.camel.component.jetty.JettyHttpComponent.createEndpoint(JettyHttpComponent.java:226) at org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:91) at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:461) ... 20 more

What am I doing wrong?

Regards, Evgeniy

Upvotes: 0

Views: 2660

Answers (1)

evgeniy44
evgeniy44

Reputation: 3162

The only one decision I found - it's to extend DefaultHttpBinding class in jetty component and override populateRequestParameters() method where JettyComponent fills HttpServletRequest from HttpMessage.

Regards, Evgeniy

Upvotes: 2

Related Questions