此内容没有您所选择的语言版本。

Chapter 3. Getting Started with Apache Karaf


3.1. Log in to the Customer Portal

Before you can download the required packages, you need an account on Red Hat’s Customer Portal which has a Red Hat Fuse subscription. Using this account, log in to the portal at https://access.redhat.com/login.

3.2. Download the required packages

Click each of the Download buttons to get the required packages from the Customer Portal:

get started with fuse on karaf download devstudio download fuse on karaf

3.3. Install and configure Fuse on Apache Karaf

To install and configure Fuse on Apache Karaf, perform the following steps:

  1. Unpack the downloaded .zip archive file for Fuse on Apache Karaf to a convenient location on your file system, FUSE_INSTALL.
  2. Add an administrator user to the Fuse runtime.

    1. Open the FUSE_INSTALL/etc/users.properties file in a text editor.
    2. Delete the # character at the start of the line that starts with #admin = admin.
    3. Delete the # character at the start of the line that starts with #g\:admingroup.
    4. Customize the username, USERNAME, and password, PASSWORD, of the user entry, so that you have a user entry and an admin group entry like the following (on consecutive lines):

      USERNAME = PASSWORD,_g_:admingroup
      _g_\:admingroup = group,admin,manager,viewer,systembundles,ssh
    5. Save the etc/users.properties file.

3.4. Set up your development environment

To set up your development environment, perform the following steps:

  1. Run the CodeReady Studio installer, as follows:

    java -jar DOWNLOAD_LOCATION/devstudio-12.11.0.GA-installer-standalone.jar
  2. During installation:

    1. Accept the terms and conditions.
    2. Choose your preferred installation path.
    3. Select the Java 8 JVM.
    4. At the Select Platforms and Servers step, configure the Fuse on Karaf runtime by clicking Add and browsing to the location of the FUSE_INSTALL directory (see Section 3.3, “Install and configure Fuse on Apache Karaf”).
    5. At the Select Additional Features to Install step, select Red Hat Fuse Tooling.
  3. CodeReady Studio starts up. When the Searching for runtimes dialog appears, click OK to create the Fuse on Karaf runtime.
  4. (Optional) In order to use Apache Maven from the command line, you need to install and configure Maven as described in Appendix A, Preparing to use Maven.

    Note

    If you are using CodeReady Studio exclusively, it is not strictly necessary to install Maven, because CodeReady Studio has Maven pre-installed and configured for you. But if you plan to invoke Maven from the command line, it is necessary to perform this step.

3.5. Build your first application

To build your first application with Fuse on Karaf, perform the following steps:

  1. In CodeReady Studio, create a new project, as follows:

    1. Select File→New→Fuse Integration Project.
    2. Enter fuse-camel-cbr in the Project Name field.
    3. Click Next.
    4. In the Select a Target Environment pane, choose the following settings:

      • Select Standalone as the deployment platform.
      • Select Karaf/Fuse on Karaf as the runtime environment and use the Runtime (optional) dropdown menu to select the Red Had JBoss Middleware> Red Hat Fuse 7+ Runtime server as the target runtime.
    5. After selecting the target runtime, the Camel Version is automatically selected for you and the field is grayed out.
    6. Click Next.
    7. In the Advanced Project Setup pane, select the Beginner→Content Based Router - Blueprint DSL template.
    8. Click Finish.
    9. If prompted to open the associated Fuse Integration perspective, click Yes.
    10. Wait while CodeReady Studio downloads required artifacts and builds the project in the background.

      Important

      If this is the first time you are building a Fuse project in CodeReady Studio, it will take several minutes for the wizard to finish generating the project, as it downloads dependencies from remote Maven repositories. Do not attempt to interrupt the wizard or close CodeReady Studio while the project is building in the background.

  2. Deploy the project to the server, as follows:

    1. In the Servers view (bottom left corner of the Fuse Integration perspective), if the server is not already started, select the fuse-karaf-7.3.0.fuse-730079-redhat-00001 Runtime Server server and click the green arrow to start it.

      Note

      If you see the dialog, Warning: The authenticity of host 'localhost' can’t be established., click Yes to connect to the server and access the Karaf console.

    2. Wait until you see a message like the following in the Console view:

      Karaf started in 1s. Bundle stats: 12 active, 12 total
    3. After the server has started, switch back to the Servers view, right-click on the server and select Add and Remove from the context menu.
    4. In the Add and Remove dialog, select the fuse-camel-cbr project and click the Add > button.
    5. Click Finish.
    6. You can check whether the project’s OSGi bundle has started up by going to the Terminal view and entering bundle:list | tail. You should see some output like the following:

      ...
      228 │ Active │  80 │ 1.0.0.201505202023          │ org.osgi:org.osgi.service.j
      232 │ Active │  80 │ 1.0.0.SNAPSHOT              │ Fuse CBR Quickstart

3.5.1. Verify the project

As soon as the Camel route starts up, it will create a directory, work/cbr/input in the fuse-camel-cbr project.

Now you can test your Camel route and see it in action.

  1. In the Project Explorer view, click Refresh to see the newly created work/cbr/input directory.
  2. Copy the files you find in the project’s src/main/data directory to the work/cbr/input directory.
  3. Wait a few moments and then refresh the Project Explorer view again to see the same files organized by country under the work/cbr/output directory:
  4. order1.xml in work/cbr/output/others
  5. order2.xml and order4.xml in work/cbr/output/uk
  6. order3.xml and order5.xml in work/cbr/output/us

3.5.2. Undeploy the project

Undeploy the project, as follows:

  1. In the Servers view, select the Red Hat Fuse 7+ Runtime Server server.
  2. Right-click on the server and select Add and Remove from the context menu.
  3. In the Add and Remove dialog, select your fuse-camel-cbr project and click the < Remove button.
  4. Click Finish.
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.