2013-10-01 53 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目標運行它。

希望它有幫助!