Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache camel Camel Mina和侦听多个端口_Apache Camel_Hl7_Mina - Fatal编程技术网

Apache camel Camel Mina和侦听多个端口

Apache camel Camel Mina和侦听多个端口,apache-camel,hl7,mina,Apache Camel,Hl7,Mina,我已经成功地使用Camel MINA在单个端口上进行侦听。我现在想修改配置,以便可以在多个端口上侦听。我不知道该怎么做。我在下面包含了xml配置和相关类的一个片段: <!-- enable Spring @Component scan --> <context:component-scan base-package="foo.bar.hl7" /> <bean id="properties" class="org.apache.camel.component.pr

我已经成功地使用Camel MINA在单个端口上进行侦听。我现在想修改配置,以便可以在多个端口上侦听。我不知道该怎么做。我在下面包含了xml配置和相关类的一个片段:

<!-- enable Spring @Component scan -->
<context:component-scan base-package="foo.bar.hl7" />

<bean id="properties" class="org.apache.camel.component.properties.PropertiesComponent">
    <property name="ignoreMissingLocation" value="true" />
    <property name="locations">
            <list>
                <value>file:${catalina.home}/application.properties</value>
            </list>
    </property>
</bean>

<bean id="myhl7codec" class="org.apache.camel.component.hl7.HL7MLLPCodec">
    <property name="charset" value="iso-8859-1"/>
    <property name="validate" value="false"/>
</bean>

<camelContext xmlns="http://camel.apache.org/schema/spring" id="camelContext">
    <contextScan />
    <!-- You need to configure your socket in the endpoint.properties file -->
    <camel:endpoint id="hl7listener" uri="mina2:tcp://{{endpoint.server}}:{{endpoint.port}}?sync=true&amp;codec=#myhl7codec" />
</camelContext>

<context:annotation-config />

<bean class="foo.bar.hl7.HL7ListenerConfiguration" />
组件类

@Configuration
public class HL7ListenerConfiguration {
    private static final Logger log = LoggerFactory.getLogger(HL7ListenerConfiguration.class);

    @Bean
    public RespondACK RespondACK() {
        return new RespondACK();
    }

    @Bean
    public ADTInboundRouteBuilder ADTInboundRouteBuilder() {
        log.debug("Building MLLP Route");
        return new ADTInboundRouteBuilder();
    }
}

您需要为每个要侦听的端口创建hl7listener和Camel路由。

我认为您只能加载一组属性,但当然属性可以有不同的名称,如endpoint1.port和endpoint2.port。
@Configuration
public class HL7ListenerConfiguration {
    private static final Logger log = LoggerFactory.getLogger(HL7ListenerConfiguration.class);

    @Bean
    public RespondACK RespondACK() {
        return new RespondACK();
    }

    @Bean
    public ADTInboundRouteBuilder ADTInboundRouteBuilder() {
        log.debug("Building MLLP Route");
        return new ADTInboundRouteBuilder();
    }
}