2017-01-31 60 views
0

我正在嘗試使用camel-hl7組件在駱駝中創建一個hl7偵聽器。當我在駱駝春天使用它時,它正在工作。但是,當我嘗試使用同一個Java中的DSL如下,Camel HL7codec在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方法:編解碼器,因爲ISN '相同類型的setter方法: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屬性:codec as theren沒有類型轉換器: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)

回答

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); 

現在路線開始了。

相關問題