Camel HL7codec无法在Java DSL中运行

时间:2017-01-31 22:33:05

标签: apache-camel hl7

我试图使用camel-hl7组件在驼峰中创建一个hl7监听器。当我在骆驼春天使用它时,它正在工作。但是当我尝试在Java DSL中使用相同的内容时,

HL7MLLPCodec hl7codec = new HL7MLLPCodec();
        hl7codec.setCharset("iso-8859-1");
        camelContext.addRoutes(new RouteBuilder() {
            public void configure() {
                from("mina:tcp://localhost:4444?sync=true&codec=hl7codec").to("file://test");
            }
        });

抛出异常,

java.lang.IllegalArgumentException:找不到合适的属性setter:codec,因为没有相同类型的setter方法:java.lang.String或类型转换可能:没有可用的类型转换器从类型:java.lang.String转换为所需类型:org.apache.mina.filter.codec.ProtocolCodecFactory,其值为hl7codec !在org.apache.camel.util.IntrospectionSupport.setProperty(IntrospectionSupport.java:588) ! at org.apache.camel.util.IntrospectionSupport.setProperty(IntrospectionSupport.java:616) !在org.apache.camel.util.IntrospectionSupport.setProperties(IntrospectionSupport.java:473) !在org.apache.camel.util.IntrospectionSupport.setProperties(IntrospectionSupport.java:483) !在org.apache.camel.util.EndpointHelper.setProperties(EndpointHelper.java:255) ! at org.apache.camel.impl.DefaultComponent.setProperties(DefaultComponent.java:257) !在org.apache.camel.component.mina.MinaComponent.createEndpoint(MinaComponent.java:92) ! at org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:114) ! at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:568) ! ...省略了33个常用帧 !导致:org.apache.camel.ResolveEndpointFailedException:无法解析端点:mina:// tcp:// localhost:4444?codec = hl7codec& sync = true由于:找不到合适的属性setter:codec as asn& #39;具有相同类型的set setter方法:java.lang.String或类型转换可能:没有类型转换器可用于从类型:java.lang.String转换为所需类型:org.apache.mina.filter。 codec.ProtocolCodecFactory,其值为hl7codec ! at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:588) ! at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:79)

1 个答案:

答案 0 :(得分:0)

我必须将hl7codec注册到注册表以供使用它的驼峰路由。

 final org.apache.camel.impl.SimpleRegistry registry = new org.apache.camel.impl.SimpleRegistry();
        final org.apache.camel.impl.CompositeRegistry compositeRegistry = new org.apache.camel.impl.CompositeRegistry();
        compositeRegistry.addRegistry(camelContext.getRegistry());
        compositeRegistry.addRegistry(registry);
        ((org.apache.camel.impl.DefaultCamelContext) camelContext).setRegistry(compositeRegistry);
    registry.put("hl7codec", hl7codec);

现在路线开始了。