我一直在研究在 Tomcat 中使用 Camel 从指定端口路由 HL7 数据以由持久层处理。我真的很难理解如何做到这一点。我使用没有 Spring 代码的 Tomcat作为基本配置示例。Camel HL7 的详细信息在这里。我真的不明白如何更改 uri(或创建适当的 web.xml 和 camel-config-xml 文件),以便它侦听 MLLP 连接,然后路由到适当的处理类。从文档中,uri是:
mina:tcp://localhost:8888?sync=true&codec=#hl7codec
到目前为止,我有一个这样的 spring-servlet.xml(带有错误 cvc-complex-type.2.4.c:匹配的通配符是严格的,但找不到元素'camel:camelContext'的声明):
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jms="http://www.springframework.org/schema/jms"
xmlns:camel="http://activemq.apache.org/camel/schema/spring"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
<bean id="hl7codec" class="org.apache.camel.component.hl7.HL7MLLPCodec">
<property name="charset" value="iso-8859-1"/>
</bean>
<bean id="hl7MessageHandler" class="util.HL7MessageHandlerService"/>
<camelContext id="hl7listener" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="mina:tcp://localhost:8888?sync=true&codec=#hl7codec"/>
<to uri="bean:hl7MessageHandler?method=lookupPatient"/>
</route>
</camelContext>
</beans>
和这样的 web.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>HL7 Consumer</display-name>
<!-- location of spring xml files -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>CamelServlet</servlet-name>
<servlet-class>org.apache.camel.component.servlet.CamelHttpTransportServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CamelServlet</servlet-name>
<url-pattern>/camel/*</url-pattern>
</servlet-mapping>
</web-app>
我真的不明白如何配置 Camel 路由,然后确保传入消息传递给 HL7MessageHandler。