Приложение Red Hat Fuse Quickstart Content Based Router - Java DSL не создает рабочую папку

Проблема

Приложение Red Hat Fuse Quickstart "Content Based Router - Java DSL" не работает. т.е. при сборке, запуске и развертывании (до «Red Hat Fuse 7.1») «рабочая» папка никогда не создается.

Вот код Java:

package com.mycompany.camel;

import org.apache.camel.builder.RouteBuilder;

public class CamelRoute extends RouteBuilder {

    @Override
    public void configure() throws Exception {

        from("file:work/cbr/input")  //<== "work" folder not created...
            .log("Receiving order ${file:name}")
            .choice()
                .when().xpath("//order/customer/country[text() = 'UK']")
                    .log("Sending order ${file:name} to the UK")
                    .to("file:work/cbr/output/uk")
                .when().xpath("//order/customer/country[text() = 'US']")
                    .log("Sending order ${file:name} to the US")
                    .to("file:work/cbr/output/us")
                .otherwise()
                    .log("Sending order ${file:name} to another country")
                    .to("file:work/cbr/output/others")
            .log("Done processing ${file:name}");
    }

}

Обратите внимание, что «Content Based Router - Blueprint DSL» действительно работает (т. Е. Он использует файл blueprint.xml для определения маршрута, а не код Java).

Я использую шаблон «Быстрый старт» из «Red Hat Developer Studio».

т.е. File -> New -> Fuse Integration Project -> [создать имя проекта] -> выбрать платформу «Standalone», выбрать «Karaf / Fuse on Karaf» -> в разделе «Beginner» выбрать «Content Based Router - Java DSL »-> Готово -> и т. Д.

Построен и развернут. Проект быстрого запуска Java DSL запускается и запускается, но он останавливается перед созданием родительской «рабочей» папки (не говоря уже о других подпапках).

Чего может не хватать в шаблоне проекта и / или конфигурации?

Мне интересно: уходит ли Java DSL на второй план в пользу Spring DSL и / или Blueprint DSL? (Я использовал Java DSL со старым Jboss Fuse 6.3, и он мне понравился).

Вот файл pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mycompany</groupId>
  <artifactId>camel-java-cbr</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>bundle</packaging>
  <name>Fuse CBR Quickstart - Java</name>
  <description>Camel Content-Based Router Example using the Java DSL</description>
  <licenses>
    <license>
      <name>Apache License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  <properties>
    <version.maven-bundle-plugin>3.2.0</version.maven-bundle-plugin>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <jboss.fuse.bom.version>7.1.0.fuse-710023-redhat-00001</jboss.fuse.bom.version>
  </properties>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.jboss.fuse</groupId>
        <artifactId>jboss-fuse-parent</artifactId>
        <version>${jboss.fuse.bom.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-test</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
    </dependency>
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
    </dependency>
  </dependencies>
  <repositories>
    <repository>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>fuse-public-repository</id>
      <name>FuseSource Community Release Repository</name>
      <url>https://repo.fusesource.com/nexus/content/groups/public</url>
    </repository>
    <repository>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>red-hat-ga-repository</id>
      <name>Red Hat GA Repository</name>
      <url>https://maven.repository.redhat.com/ga</url>
    </repository>
    <repository>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>red-hat-ea-repository</id>
      <name>Red Hat EA Repository</name>
      <url>https://maven.repository.redhat.com/earlyaccess/all</url>
    </repository>
    <repository>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>jboss-ea-repository</id>
      <name>Red Hat JBoss Early Access Repository</name>
      <url>http://repository.jboss.org/nexus/content/groups/ea</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>fuse-public-repository</id>
      <name>FuseSource Community Release Repository</name>
      <url>https://repo.fusesource.com/nexus/content/groups/public</url>
    </pluginRepository>
    <pluginRepository>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>red-hat-ga-repository</id>
      <name>Red Hat GA Repository</name>
      <url>https://maven.repository.redhat.com/ga</url>
    </pluginRepository>
    <pluginRepository>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>red-hat-ea-repository</id>
      <name>Red Hat EA Repository</name>
      <url>https://maven.repository.redhat.com/earlyaccess/all</url>
    </pluginRepository>
    <pluginRepository>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>jboss-ea-repository</id>
      <name>Red Hat JBoss Early Access Repository</name>
      <url>http://repository.jboss.org/nexus/content/groups/ea</url>
    </pluginRepository>
  </pluginRepositories>
  <build>
    <defaultGoal>install</defaultGoal>
    <plugins>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>${version.maven-bundle-plugin}</version>
        <extensions>true</extensions>
        <configuration>
          <instructions>
            <Bundle-SymbolicName>myJavaDsl</Bundle-SymbolicName>
            <Bundle-Name>Camel Content-Based Router Example using the Java DSL [myJavaDsl]</Bundle-Name></instructions></configuration>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.7.0</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>3.0.2</version>
        <configuration>
          <encoding>UTF-8</encoding>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.6.0</version>
        <configuration>
          <mainClass>com.mycompany.camel.Launcher</mainClass>
          <includePluginDependencies>false</includePluginDependencies>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

Red Hat Developer Studio, версия: 12.9.0.GA

предохранитель-karaf-7.1.0.fuse-710023-redhat-00001

jdk1.8.0_121

C: \ apache-maven-3.6.0

Использование проектов Quickstart упоминается в Red Hat Fuse Tooling User Руководство - PDF


person sairn    schedule 15.11.2018    source источник
comment
Что произойдет, если вместо этого вы укажете file://C:/AAAInput и file://C:/BBBOutput для конечных точек файла?   -  person Tadayoshi Sato    schedule 19.11.2018
comment
привет Т. - Без разницы. Папка все еще не создана. Спасибо! SD   -  person sairn    schedule 26.11.2018
comment
Создан и развернут в горячем режиме ... Проект быстрого запуска Java DSL запускается и запускается - но он останавливается перед созданием родительской рабочей папки (не говоря уже о других подпапках) .... Какой метод вы используете для сборки и развертывания? Я пробовал, и он работает нормально, если щелкнуть проект правой кнопкой мыши и запустить его как Java-приложение. Затем щелкните правой кнопкой мыши и ›обновите проект. Доступна папка work / cbr / input. Когда вы говорите, что он останавливается, у вас есть какие-то конкретные журналы?   -  person Aurélien Pupier    schedule 10.12.2018
comment
@ AurélienPupier да, он работает как локальное приложение Java, но если я попытаюсь развернуть его во время выполнения Fuse, маршрут не будет запущен   -  person Tomas Sedmik    schedule 10.12.2018


Ответы (3)


Я сделал следующие шаги, чтобы заставить его работать со средой выполнения Fuse:

  1. создать новый проект интеграции Fuse - Standalone, Karaf / Fuse on Karaf, CBR - Java DSL
  2. создайте новые папки и файл "src / main / resources / OSGI-INF / blueprint / blueprint.xml
  3. Содержание файла blueprint.xml:

<?xml version="1.0" encoding="UTF-8"?> <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd"> <bean class="com.mycompany.camel.CamelRoute" id="myRouteBuilder"/> <camelContext id="cbr-example-context" xmlns="http://camel.apache.org/schema/blueprint"> <routeBuilder ref="myRouteBuilder"/> </camelContext> </blueprint>

  1. развернуть проект через представление Серверы в Red Hat Developer Studio

Поскольку файл находится в каталоге OSGI-INF / blueprint внутри нашего JAR, он будет автоматически активирован, как только пакет будет установлен. Это возможно, потому что Red Hat Fuse использует Apache Karaf с программой развертывания Blueprint - см. Развертывание в Apache Karaf - службы OSGi

В любом случае предоставленные шаблоны должны работать «из коробки». Поэтому я поднял вопрос для разработчиков Fuse Tooling - https://issues.jboss.org/browse/FUSETOOLS-3178

person Tomas Sedmik    schedule 10.12.2018
comment
Спасибо, Томас. - person sairn; 11.12.2018
comment
Ха! проверяюсь сегодня ... все еще не исправлено. (еще нужно добавить OSGI-INF / blueprint / bluepring.xml). Ну да ладно ...: D - person sairn; 03.05.2019
comment
Да, ты прав. Зависимая проблема JIRA все еще открыта - issues.jboss.org/browse/FUSETOOLS-3178 :-( - person Tomas Sedmik; 17.05.2019

Проверьте права доступа к папке для C: \, а также используйте uri, как указано ниже:

from ("file: // C: / AAAInput /? autoCreate = true & noop = true")

person VarunKrish    schedule 19.11.2018
comment
Привет В. - Пробовал это раньше, но - если я пропустил какой-то синтаксический нюанс - я повторил. Папка по-прежнему не создается. Спасибо! SD - person sairn; 26.11.2018

Похоже, ваш маршрут вообще не начинался. Попробуйте использовать прямую ссылку на построитель маршрутов вместо сканирования пакетов следующим образом:

<camel:camelContext id="aaa.bbb.ccc.jar" xmlns="http://camel.apache.org/schema/blueprint">
    <camel:routeBuilder ref="routeBuilder"/>
</camel:camelContext>
<bean id="routeBuilder" class="aaa.bbb.ccc.jar.CamelRoute" />
person c0ld    schedule 05.12.2018
comment
спасибо, c0ld. К сожалению, без разницы. интересно, содержит ли предоставленный шаблон быстрого запуска правильные зависимости и т. д. для автономного построителя маршрутов Java DSL. - person sairn; 06.12.2018