Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 5. Deploying an Apache Camel Servlet Endpoint
Abstract
5.1. Apache Camel Servlet Example Copier lienLien copié sur presse-papiers!
Overview Copier lienLien copié sur presse-papiers!
url-pattern
setting from web.xml
, and the endpoint URI of the Camel servlet endpoint are combined to give the URL, http://localhost:8080/camel-example-servlet-tomcat-2.15.1.redhat-621084/camel/hello
.
Figure 5.1. Camel Servlet Example Deployed in a Web Server
camel-example-servlet-tomcat example Copier lienLien copié sur presse-papiers!
examples/camel-example-servlet-tomcat
directory. For details of how to install the Apache Camel distribution, see the section called “Install Apache Camel”.
Camel servlet component Copier lienLien copié sur presse-papiers!
org.apache.camel.component.servlet.CamelHttpTransportServlet
org.apache.camel.component.servlet.CamelHttpTransportServlet
servlet://RelativePath[?Options]
servlet://RelativePath[?Options]
RelativePath
specifies the tail segment of the HTTP URL path for this servlet.
web.xml file Copier lienLien copié sur presse-papiers!
web.xml
file. In the camel-example-servlet-tomcat
project, the web.xml
file is stored at the following location:
camel-example-servlet-tomcat/src/main/webapp/WEB-INF/web.xml
camel-example-servlet-tomcat/src/main/webapp/WEB-INF/web.xml
web.xml
file.
Example 5.1. web.xml File for the camel-example-servlet-tomcat Example
web.xml
file are:
servlet/servlet-class
- Specifies the
org.apache.camel.component.servlet.CamelHttpTransportServlet
class, which implements the Camel servlet component. servlet-mapping/url-pattern
- Determines which URLs are routed to this servlet. In general, the servlet URL has the following form:
http://Host:Port/WARFileName/URLPattern
http://Host:Port/WARFileName/URLPattern
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Where the base URL,http://Host:Port
, is determined by the configuration of the Web server, theWARFileName
is the root of theWARFileName.war
WAR file, and theURLPattern
is specified by the contents of theurl-pattern
element.Assuming that the Web server port is set to 8080, thecamel-example-servlet-tomcat
example servlet will match URLs of the following form:http://localhost:8080/camel-example-servlet-tomcat-2.15.1.redhat-621084/camel/*
http://localhost:8080/camel-example-servlet-tomcat-2.15.1.redhat-621084/camel/*
Copy to Clipboard Copied! Toggle word wrap Toggle overflow listener/listener-class
- This element launches the Spring container.
context-param
- This element specifies the location of the Spring XML file,
camel-config.xml
, in the WAR. The Spring container will read this parameter and load the specified Spring XML file, which contains the definition of the Camel route.
Example Camel route Copier lienLien copié sur presse-papiers!
Example 5.2. Route Definition for the Camel Servlet Example
servlet:///hello
, specifies the relative path, /hello
, the complete URL to access this servlet is the following:
http://localhost:8080/camel-example-servlet-tomcat-2.15.1.redhat-621084/camel/hello
http://localhost:8080/camel-example-servlet-tomcat-2.15.1.redhat-621084/camel/hello