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.Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 5. Deploying an Apache Camel Servlet Endpoint
Abstract
5.1. Apache Camel Servlet Example Link kopierenLink in die Zwischenablage kopiert!
Overview Link kopierenLink in die Zwischenablage kopiert!
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 Link kopierenLink in die Zwischenablage kopiert!
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 Link kopierenLink in die Zwischenablage kopiert!
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 Link kopierenLink in die Zwischenablage kopiert!
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.CamelHttpTransportServletclass, 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/URLPatternCopy to Clipboard Copied! Toggle word wrap Toggle overflow Where the base URL,http://Host:Port, is determined by the configuration of the Web server, theWARFileNameis the root of theWARFileName.warWAR file, and theURLPatternis specified by the contents of theurl-patternelement.Assuming that the Web server port is set to 8080, thecamel-example-servlet-tomcatexample 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 Link kopierenLink in die Zwischenablage kopiert!
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