検索

このコンテンツは選択した言語では利用できません。

Chapter 6. Running routes inside Red Hat Fuse Tooling

download PDF

There are two ways to run your routes using the tooling:

6.1. Running routes as a local Camel context

Overview

The simplest way to run an Apache Camel route is as a Local Camel Context. This method enables you to launch the route directly from the Project Explorer view’s context menu. When you run a route from the context menu, the tooling automatically creates a runtime profile for you. You can also create a custom runtime profile for running your route.

Your route runs as if it were invoked directly from the command line and uses Apache Camel’s embedded Spring container. You can configure a number of the runtime parameters by editing the runtime profile.

Procedure

To run a route as a local Camel context:

  1. In the Project Explorer view, select a routing context file.
  2. Right-click it to open the context menu, and then select Run As Local Camel Context.

    Note

    Selecting Local Camel Context (without tests) directs the tooling to run the project without performing validation tests, which may be faster.

Result

The Console view displays the output generated from running the route.

6.2. Running routes using Maven

Overview

If the project containing your route is a Maven project, you can use the m2e plug-in to run your route. Using this option, you can execute any Maven goals, before the route runs.

Procedure

To run a route using Maven:

  1. In the Project Explorer view, select the root of the project .
  2. Right-click it to open the context menu, and then select Run As Maven build.

    1. The first time you run the project using Maven, the Edit Configuration and launch editor opens, so you can create a Maven runtime profile.

      To create the runtime profile, on the Maven tab:

      1. Make sure the route directory of your Apache Camel project appears in the Base directory: field.

        For example, on Linux the root of your project is similar to ~/workspace/simple-router.

      2. In the Goals: field, enter camel:run.

        Important

        If you created your project using the Java DSL, enter exec:java in the Goals: field.

      3. Click Apply and then Run.
    2. Subsequent Maven runs use this profile, unless you modify it between runs.

Results

The Console view displays the output from the Maven run.

6.3. Working with runtime profiles

Red Hat Fuse Tooling stores information about the runtime environments for each project in runtime profiles. The runtime profiles keep track of such information as which Maven goals to call, the Java runtime environment to use, any system variables that need to be set, and so on. A project can have more than one runtime profile.

6.3.1. Editing a Local Camel Context runtime profile

Overview

A Local Camel Context runtime profile configures how Apache Camel is invoked to execute a route. A Local Camel Context runtime profile stores the name of the context file in which your routes are defined, the name of the main to invoke, the command line options passed into the JVM, the JRE to use, the classpath to use, any environment variables that need to be set, and a few other pieces of information.

The runtime configuration editor for a Local Camel Context runtime profile contains the following tabs:

  • Camel Context File — specifies the name of the new configuration and the full path of the routing context file that contains your routes.
  • JMX — specifies JMX connection details, including the JMX URI and the user name and password (optional) to use to access it.
  • Main — specifies the fully qualified name of the project’s base directory, a few options for locating the base directory, any goals required to execute before running the route, and the version of the Maven runtime to use.
  • JRE — specifies the JRE and command line arguments to use when starting the JVM.
  • Refresh — specifies how Maven refreshes the project’s resource files after a run terminates.
  • Environment — specifies any environment variables that need to be set.
  • Common — specifies how the profile is stored and the output displayed.

The first time an Apache Camel route is run as a Local Camel Context, Red Hat Fuse Tooling creates for the routing context file a default runtime profile, which should not require editing.

Accessing the Local Camel Context’s runtime configuration editor

  1. In the Project Explorer view, select the Camel context file for which you want to edit or create a custom runtime profile.
  2. Right-click it to open the context menu, and then select Run As Run Configurations to open the Run Configurations dialog.
  3. In the context selection pane, select Local Camel Context, and then click New profile icon at the top, left of the context selection pane.
  4. In the Name field, enter a new name for your runtime profile.

Figure 6.1. Runtime configuration editor for Local Camel Context

Local camel context runtime configuration editor

Setting the camel context file

The Camel Context File tab has one field, Select Camel Context file…​. Enter the full path to the routing context file that contains your route definitions.

The Browse button accesses the Open Resource dialog, which facilitates locating the target routing context file. This dialog is preconfigured to search for files that contain Apache Camel routes.

Changing the command line options

By default the only command line option passed to the JVM is:

-fa context-file

If you are using a custom main class you may need to pass in different options. To do so, on the Main tab, click the Add button to enter a parameter’s name and value. You can click the Add Parameter dialog’s Variables…​ button to display a list of variables that you can select.

To add or modify JVM-specific arguments, edit the VM arguments field on the JRE tab.

Changing where output is sent

By default, the output generated from running the route is sent to the Console view. But you can redirect it to a file instead.

To redirect output to a file:

  1. Select the Common tab.
  2. In the Standard Input and Output pane, click the checkbox next to the Output File: field, and then enter the path to the file where you want to send the output.

    The Workspace, File System, and Variables buttons facilitate building the path to the output file.

6.3.2. Editing a Maven runtime profile

Overview

A Maven runtime profile configures how Maven invokes Apache Camel. A Maven runtime profile stores the Maven goals to execute, any Maven profiles to use, the version of Maven to use, the JRE to use, the classpath to use, any environment variables that need to be set, and a few other pieces of information.

Important

The first time an Apache Camel route is run using Maven, you must create a default runtime profile for it.

The runtime configuration editor for a Fuse runtime profile contains the following tabs:

  • Main — specifies the name of the new configuration, the fully qualified name of the project’s base directory, a few options for locating the base directory, any goals required to execute before running the route, and the version of the Maven runtime to use.
  • JRE — specifies the JRE and command line arguments to use when starting the JVM.
  • Refresh — specifies how Maven refreshes the project’s resource files after a run terminates.
  • Source — specifies the location of any additional sources that the project requires.
  • Environment — specifies any environment variables that need to be set.
  • Common — specifies how the profile is stored and the output displayed.

Accessing the Maven runtime configuration editor

  1. In the Project Explorer view, select the root of the project for which you want to edit or create a custom runtime profile.
  2. Right-click it to open the context menu, and then select Run As Run Configurations to open the Run Configurations dialog.
  3. In the context selection pane, select Maven Build, and then click New profile icon at the top, left of the context selection pane.

Figure 6.2. Runtime configuration editor for Maven

Maven runtime configuration editor

Changing the Maven goal

The most commonly used goal when running a route is camel:run. It loads the routes into a Spring container running in its own JVM.

The Apache Camel plug-in also supports a camel:embedded goal that loads the Spring container into the same JVM used by Maven. The advantage of this is that the routes should bootstrap faster.

Projects based on Java DSL use the exec:java goal.

If your POM contains other goals, you can change the Maven goal used by clicking the Configure…​ button next to the Maven Runtime field on the Main tab. On the Installations dialog, you edit the Global settings for <selected_runtime> installation field.

Changing the version of Maven

By default, Red Hat Fuse Tooling for Eclipse uses m2e, which is embedded in Eclipse. If you want to use a different version of Maven or have a newer version installed on your development machine, you can select it from the Maven Runtime drop-down menu on the Main tab.

Changing where the output is sent

By default, the output from the route execution is sent to the Console view. But you can redirect it to a file instead.

To redirect output to a file:

  1. Select the Common tab.
  2. Click the checkbox next to the Output File: field, and then enter the path to the file where you want to send the output.

    The Workspace, File System, and Variables buttons facilitate building the path to the output file.

Red Hat logoGithubRedditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

© 2024 Red Hat, Inc.