我使用骆驼框架处理码头组件。
我有两个问题:
1)我处理大消息(大约 1mb),码头组件将消息正文读入骆驼交换标头。它会导致这样的错误:
WARN header full: java.lang.RuntimeException: Header>6144
那么,如何使码头组件不将 HttpRequest 正文放入标头中?
2)当我试图覆盖默认的 HeaderFilterStrategy 我写了这样的代码块:
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")
.....
});
它导致了这样的异常:
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)
引起:org.apache.camel.ResolveEndpointFailedException:无法解析端点:码头:// http://my.host:32278/general-nr/notify?headerFilterStrategy=str由于:找不到合适的属性设置器:headerFilterStrategy,因为没有相同类型的设置器方法:java.lang.String 也没有类型转换:没有可用于从类型转换的类型转换器:java.lang.String 到所需的类型: org.apache.camel.spi.HeaderFilterStrategy 在 org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper. java:50) 在 org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:108) 在 org.apache.camel.impl 的 org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:187) .DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:114) 在 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 更多原因:java.lang.IllegalArgumentException:找不到合适的属性设置器:headerFilterStrategy 因为没有相同类型的设置器方法:java.lang.String 也不可能进行类型转换:没有类型转换器可用于将类型:java.lang.String 转换为所需的类型:org.apache.camel.spi.HeaderFilterStrategy,值 str 在 org.apache.camel.util .IntrospectionSupport.setProperty(IntrospectionSupport.java:347) 在 org.apache.camel.util.IntrospectionSupport.setProperty(IntrospectionSupport.java:第367章.setProperties(DefaultComponent.java:222) 在 org.apache.camel.component.jetty.JettyHttpComponent.createEndpoint(JettyHttpComponent.java:226) 在 org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:91) 在org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:461) ... 20 更多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 更多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 更多
我究竟做错了什么?
问候, 叶夫根尼