title: How to Configure Apache Camel with an HL7 Listener and deploy inTomcat
body: <p>I have been looking at using Camel in Tomcat to route HL7 data from a specified port to be processed by a persistence layer.  I am really struggling to understand how to do this. I am using the <a href="http://camel.apache.org/servlet-tomcat-no-spring-example.html" rel="nofollow">Tomcat without Spring code</a> as a basic configuration example.  The Camel HL7 details are <a href="http://camel.apache.org/hl7.html" rel="nofollow">here</a>.  I don't really understand how to change the uri (or create the appropriate web.xml and camel-config-xml files) so that it will listen for MLLP connections and then route to an appropriate processing class.  From the documentation the uri is:</p>
  
  <pre><code>mina:tcp://localhost:8888?sync=true&amp;amp;codec=#hl7codec
  </code></pre>
  
  <p>So far, I have a spring-servlet.xml like this (with an error cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'camel:camelContext'):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;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"&gt;
    &lt;bean id="hl7codec" class="org.apache.camel.component.hl7.HL7MLLPCodec"&gt;
      &lt;property name="charset" value="iso-8859-1"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="hl7MessageHandler" class="util.HL7MessageHandlerService"/&gt;
  
  &lt;camelContext id="hl7listener" xmlns="http://camel.apache.org/schema/spring"&gt;
      &lt;route&gt;
          &lt;from uri="mina:tcp://localhost:8888?sync=true&amp;amp;codec=#hl7codec"/&gt;
          &lt;to uri="bean:hl7MessageHandler?method=lookupPatient"/&gt;
      &lt;/route&gt;
  &lt;/camelContext&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>and a web.xml like this: </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;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"&gt;
  
    &lt;display-name&gt;HL7 Consumer&lt;/display-name&gt;
  
    &lt;!-- location of spring xml files --&gt;
    &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;classpath:spring-servlet.xml&lt;/param-value&gt;
    &lt;/context-param&gt;
  
    &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
    &lt;/listener&gt;
  
    &lt;servlet&gt;
      &lt;servlet-name&gt;CamelServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.apache.camel.component.servlet.CamelHttpTransportServlet&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
  
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;CamelServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/camel/*&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p>I don't really understand how to configure Camel route and then to ensure that incoming messages are passed to the HL7MessageHandler.</p>