【问题标题】:How to Configure Apache Camel with an HL7 Listener and deploy inTomcat如何使用 HL7 侦听器配置 Apache Camel 并在 Tomcat 中部署
【发布时间】:2014-03-23 20:21:15
【问题描述】:

我一直在研究在 Tomcat 中使用 Camel 从指定端口路由 HL7 数据以由持久层处理。我真的很难理解如何做到这一点。我使用Tomcat without Spring code 作为基本配置示例。 Camel HL7 的详细信息是here。我真的不明白如何更改 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。

【问题讨论】:

    标签: java tomcat apache-camel


    【解决方案1】:

    请参阅本教程,了解如何在 Web 应用程序中使用 Apache Camel:http://camel.apache.org/tutorial-on-using-camel-in-a-web-application.html

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

    【讨论】:

    • 谢谢克劳斯 - 我一直在努力解决这个问题。我已经开始研究基本配置,但学习曲线相当陡峭。我已经编辑了原始问题,但仍需要一些指导。我想我需要从尝试确定我的基本结构是否正确开始?
    • 您需要一个 Camel 路由,例如 ,它使用 hl7 端点,然后将消息路由到可以处理数据并准备响应等的地方. 我建议多学习Camel。见这篇文章:java.dzone.com/articles/open-source-integration-apache
    • 谢谢 - 我已经设法让代码加载没有错误。
    【解决方案2】:

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

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

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

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

    希望对你有帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-06-14
      • 2020-08-01
      • 2010-12-30
      • 1970-01-01
      • 2017-09-08
      • 2015-04-22
      • 1970-01-01
      相关资源
      最近更新 更多