【问题标题】:Camel HL7codec not working in Java DSLCamel HL7codec 在 Java DSL 中不起作用
【发布时间】:2017-01-31 22:33:05
【问题描述】:

我试图使用 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: 找不到合适的属性设置器:编解码器,因为没有相同类型的设置器方法:java.lang.String 也无法进行类型转换:没有可用于转换的类型转换器从类型:java.lang.String 到所需类型:org.apache.mina.filter.codec.ProtocolCodecFactory,值为 hl7codec !在 org.apache.camel.util.IntrospectionSupport.setProperty(IntrospectionSupport.java:588) !在 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) !在 org.apache.camel.impl.DefaultComponent.setProperties(DefaultComponent.java:257) !在 org.apache.camel.component.mina.MinaComponent.createEndpoint(MinaComponent.java:92) !在 org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:114) !在 org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:568) ! ...省略了33个常用框架 !原因:org.apache.camel.ResolveEndpointFailedException:无法解析端点:mina://tcp://localhost:4444?codec=hl7codec&sync=true 由于:找不到合适的属性设置器:编解码器,因为没有具有相同类型的 setter 方法:java.lang.String 也不可能进行类型转换:没有类型转换器可用于从类型:java.lang.String 转换为所需的类型:org.apache.mina.filter.codec.ProtocolCodecFactory带有值 hl7codec !在 org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:588) !在 org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:79)

【问题讨论】:

    标签: apache-camel hl7


    【解决方案1】:

    我必须将 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);
    

    现在路线开始了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-03-31
      • 1970-01-01
      • 2016-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-21
      相关资源
      最近更新 更多