0

我一直在研究在 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&amp;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。

4

2 回答 2

1

请参阅有关在 Web 应用程序中使用 Apache Camel 的教程:http: //camel.apache.org/tutorial-on-using-camel-in-a-web-application.html

然后您需要在WAR 文件中包含所需的Camel 组件及其依赖项,例如WEB-INF/lib 中的JAR。

于 2013-10-01T15:00:21.557 回答
1

我检查了你的代码,对我来说似乎没问题,也许你的问题出在其他地方。

在这里您可以找到有关如何使用骆驼创建 HL7 侦听器的教程。

http://ignaciosuay.com/how-to-create-a-camel-hl7-listener/

该项目是使用 camel:run 目标开发的,该目标用于在来自 Maven 的分叉 JVM 中运行您的 Camel Spring 配置。所以如果你想在 tomcat 中运行它,你可以添加 tomcat-maven-plugin 并使用 tomcat:run 目标运行它。

希望能帮助到你!

于 2013-11-05T10:23:32.490 回答