Ce contenu n'est pas disponible dans la langue sélectionnée.
12.3. Configuring the Gateway
Configuring with the Management Console
To configure the gateway using the Management Console UI, navigate to the Profiles page then click on the Configuration tab, then select either the Fabric8 HTTP Gateway or the Fabric8 MQ Gateway to configure its settings.
Deploying the CXF REST quickstart
To try out the examples described in this section, you must first build and deploy the CXF REST quickstart example, which is provided in the
InstallDir/quickstarts/cxf/rest
directory of your JBoss Fuse installation.
Build and deploy the CXF REST quickstart as follows:
- Start your local JBoss Fuse console (which should be a Fabric server):
cd InstallDir/bin ./fuse
- Build the quickstart project and install it in your local Maven repository, by entering the following commands:
cd InstallDir/quickstarts/cxf/rest mvn clean install
- Install the
quickstarts-cxf-rest
profile into your fabric, by entering the following command:mvn fabric8:deploy
NoteBy default, thefabric8-maven-plugin
connects to the local Fabric server running on the same host. You might also need to set up credentials in your~/.m2/settings.xml
file in order to connect to the local Fabric server. For details, see Section 7.1, “Preparing to Use the Plug-In”. - Use the Fuse Management Console (http://localhost:8181/hawtio) to deploy the
quickstarts-cxf-rest
profile to one of the containers in your fabric.
HTTP mapping rules
When using the HTTP gateway, it is a common requirement to map different versions of Web applications or Web services to different URI paths on the gateway. You can perform very flexible mappings using URI templates.
The default behavior is to expose all Web applications and Web services at the context path they are running in the target server. For example, if you deploy the
quickstarts-cxf-rest
profile, that uses a URI like /cxf/crm/customerservice/customers/123
on whatever host and port it is deployed on. Hence, by default, it is visible on the gateway at http://localhost:9000/cxf/crm/customerservice/customers/123. For this example, the URI template is:
{contextPath}/
Which means take the context path (in the above case,
/cxf/crm
) and append /
, giving /cxf/crm/
. Any request within that path is then passed to an instance of the CXF crm
service.
Selecting part of the ZooKeeper registry
The mapping rules for the MQ gateway and the HTTP gateway are tied to particular regions of the ZooKeeper registry. If you specify a ZooKeeper path for a mapping rule, any services registered under that path become associated with that rule.
For example, in the case of messaging, you could associate a messaging gateway with all message brokers worldwide. Alternatively, you could provide continent-specific, country-specific or region-specific gateways, just by specifying different ZooKeeper paths for each gateway configuration. For regional messaging clusters, use different ZooKeeper folders for geographically distinct broker clusters.
With HTTP then REST APIs, SOAP Web Services, servlets and web applications all live in different parts of the ZooKeeper registry. From the Management Console UI, you can browse the contents of the registry in the Runtime | Registry section of the console (in the Fabric view).
Here are the common ZooKeeper paths:
ZooKeeper Path | Description |
---|---|
/fabric/registry/clusters/apis/rest
|
REST based web services |
/fabric/registry/clusters/apis/ws
|
SOAP based web services |
/fabric/registry/clusters/servlets
|
Servlets (registered usually individually via the OSGI APIs) |
/fabric/registry/clusters/webapps
|
Web Applications (i.e. WARs) |
Segregating URI paths
You might want to segregate servlets, Web services, or Web applications into different URI spaces.
For example, if you want all Web services to be available under
/api/
and Web applications to be available under /app/
, update the URI templates as follows:
For the Web services mapping rule:
ZooKeeperPath: /fabric/registry/clusters/apis URI template: /api{contextPath}/
For the Web applications mapping rule:
ZooKeeperPath: /fabric/registry/clusters/webapps URI template: /app{contextPath}/
If you want to split RESTful APIs and SOAP web services into different URI paths, replace the preceding mapping rule with the following rules:
ZooKeeperPath: /fabric/registry/clusters/apis/rest URI template: /rest{contextPath}/ ZooKeeperPath: /fabric/registry/clusters/apis/ws URI template: /ws{contextPath}/
Configuring HTTP Gateway Timeouts
The Fabric Http gateway enables you to configure HTTP timeouts for the call, to the proxy service. However, the configuration stands for the complete gateway instance and the PIDs:
io.fabric8.gateway.http/connectionTimeout- this set the timeout for connecting to the service, default is 60 seconds. io.fabric8.gateway.http/requestTimeout- this set the idle timeout waiting for the response, the default is -1 which means no timeout.
Note
In both the cases, if the time out occurs, the calling client throws an HTTP 504 response.