3.6. Camel 更新レシピを使用して Red Hat build of Apache Camel on Spring Boot バージョンをアップグレードする
Spring Boot 上の Apache Camel のコードを移行する場合は頻繁に、新しい Camel API の変更に適応し、クラスの名前を変更する必要があります。これを解決するには、OpenRewrite に基づく Camel 更新レシピを使用できます。これらのレシピは手動による移行を支援し、効率化を図ります。
Camel JBang を使用して、Red Hat build of Apache Camel on Spring Boot アプリケーションを更新できます。Camel JBang は、camel update コマンドを提供します。主な操作は 2 つあります。
-
run: 実際の更新プロセスを実行する
更新プロセスでは Apache Camel Open Rewrite レシピ が使用されます。次のアプリケーションタイプをサポートします。
- Plain Camel (camel-main)
- Camel Quarkus
- Camel Spring Boot (Spring Boot で実行)
ここで、Camel および Camel Spring Boot の更新では主に camel-upgrade-recipes が使用され、Camel Quarkus の更新では Quarkus ランタイム (Rewrite Quarkus 経由) と Apache Camel レシピの両方を利用します。
3.6.1. Camel 更新の実行 リンクのコピーリンクがクリップボードにコピーされました!
このバージョンへの更新を実行するには、次を使用します。
$ camel update run {camelSpringBootVersion} --runtime=spring-boot
更新コマンドは、pom.xml ファイルが含まれているプロジェクトディレクトリーで実行する必要があります。
3.6.1.1. 設定オプション リンクのコピーリンクがクリップボードにコピーされました!
利用可能ないくつかのオプションを使用して更新プロセスをカスタマイズできます。
--runtime: アプリケーションの種類を指定します。-
spring-boot- Camel Spring Boot アプリケーション
-
-
--repos: 更新中に使用する追加の Maven リポジトリー -
--dry-run: 変更を適用せずにプレビューする -
--extraActiveRecipes: 適用する追加のレシピ名のコンマ区切りリスト -
--extraRecipeArtifactCoordinates: 追加レシピの Maven 座標のコンマ区切りリスト (形式: groupId:artifactId:version) -
--help: 利用可能なすべてのオプションを表示します。
3.6.1.2. 通常の Camel アプリケーションの更新 リンクのコピーリンクがクリップボードにコピーされました!
次の例は、通常の Camel アプリケーションを更新する方法を示しています。
$ camel update run 4.10.6.redhat-00009 --runtime=camel-main --repos=https://myMaven/repo --extraActiveRecipes=my.first.Recipe,my.second.Recipe --extraRecipeArtifactCoordinates=ex.my.org:recipes:1.0.0
3.6.1.3. Spring Boot アプリケーションの更新 リンクのコピーリンクがクリップボードにコピーされました!
次のコマンドを使用して、Spring Boot アプリケーションを更新できます。-extraActiveRecipes オプションを使用して、追加の Spring Boot アップグレードを実行できます。
$ camel update run 4.10.6.redhat-00009 --runtime=spring-boot --extraActiveRecipes=org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_3 --extraRecipeArtifactCoordinates=org.openrewrite.recipe:rewrite-spring:6.0.2