Powered by Zoomin Software. For more details please contactZoomin

MarkLogic Data Hub

データハブAPIを使用

  • Last Updated: April 5, 2026
  • 5 minute read

データハブクライアントJARによるフローの実行

Javaアプリケーション(外部のオーケストレーションツールやカスタムのwebアプリケーション)内でMarkLogicデータハブJava APIを使用すると、フローをプログラム的に実行できます。

FlowRunnerクラスはrunFlowメソッドを提供します。これはローカルファイルシステム内にプロジェクトファイルを必要としません。このメソッドは、FlowInputsタイプのパラメータ1つを受け取ります。フローをプログラム的に実行する場合、このメソッドが推奨されます。

手順

  1. ビルド設定ファイルで、MarkLogicデータハブのJava APIとの依存関係を宣言します。

    Gradle

   dependencies {
    compile('com.marklogic:marklogic-data-hub:5.2.0')
  }

**Maven**
   <dependency>
    <groupId>com.marklogic</groupId>
    <artifactId>marklogic-data-hub</artifactId>
    <version>5.2.0</version>
    <type>pom</type>
  </dependency>

**Ivy**
   <dependency org='com.marklogic' name='marklogic-data-hub' rev='5.2.0'>
    <artifact name='$AID' ext='pom'></artifact>
  </dependency>

  1. 以下のコードをコピーし、必要に応じてカスタマイズします。
   package org.example;

  import com.marklogic.hub.flow.FlowInputs;
  import com.marklogic.hub.flow.FlowRunner;
  import com.marklogic.hub.flow.RunFlowResponse;
  import com.marklogic.hub.flow.impl.FlowRunnerImpl;

  public class Main {

      public static void main(String[] args) {
          // Create a FlowRunner instance.
          FlowRunner flowRunner = new FlowRunnerImpl("myHost", "myUser", "myPassword");

          // Specify the flow to run.
          FlowInputs inputs = new FlowInputs("my-flow-name");

          // To run only a subset of the steps in the flow, uncomment the following line and specify the sequence numbers of the steps to run.
          // inputs.setSteps(Arrays.asList("2,3,4"));

          // Run the flow.
          RunFlowResponse response = flowRunner.runFlow(inputs);

          // Wait for the flow to end.
          flowRunner.awaitCompletion();

          // Display the response.
          System.out.println("Response: " + response);
      }
  }

  1. このコードを実行します。

GitHubのdh-5-exampleプロジェクトには、以下のようなサンプルコードのファイルがあります。

See Also

関連概念

関連タスク

TitleResults for “How to create a CRG?”Also Available inAlert