2013-10-01 130 views
0

我一直在寻找在Tomcat中使用Camel来从指定端口路由HL7数据以由持久层处理的问题。我真的很难理解如何做到这一点。我使用Tomcat without Spring code作为基本配置示例。骆驼HL7的细节是here。我真的不知道如何更改uri(或创建适当的web.xml和camel-config-xml文件),以便监听MLLP连接,然后路由到合适的处理类。从文档的URI是:如何使用HL7侦听器配置Apache Camel并部署inTomcat

mina:tcp://localhost:8888?sync=true&codec=#hl7codec 

到目前为止,我有一个弹簧servlet.xml中像这样(有错误CVC-复杂type.2.4.c:匹配通配符是严格的,但没有申报':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> 

我真的不明白如何配置骆驼的路线,然后以保证传入的消息是通过d到HL7MessageHandler。

回答

1

参见在Web应用程序中使用Apache的骆驼本教程:http://camel.apache.org/tutorial-on-using-camel-in-a-web-application.html

然后,你需要在WEB-INF/lib中需要的骆驼组成部分及其在WAR文件依赖性,例如JAR文件。

+0

谢谢你克劳斯 - 我一直在努力通过这个。我已经开始研究基本配置,但是学习曲线相当陡峭。我编辑了原始问题,但仍需要一些指导。我想我需要从试图弄清​​楚我的基本结构是否正确开始。 – skyman

+0

你需要一个骆驼路线,例如< route >< from >< to >< /route >它使用hl7端点,然后路由消息的某处你可以处理数据并准备响应等。我建议更多地研究骆驼。看到这篇文章:http://java.dzone.com/articles/open-source-integration-apache –

+0

谢谢 - 我已经设法得到代码加载没有错误。 – skyman

1

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

在这里你可以找到关于如何创建一个骆驼的HL7侦听器的教程。运行的目标,这是用来从Maven的分叉JVM运行骆驼Spring的配置文件:

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

该项目已使用骆驼开发。所以如果你想在tomcat中运行它,你可以添加tomcat-maven-plugin并使用tomcat:run目标运行它。

希望它有帮助!