クラス JdbcMessageHandler

実装済みのインターフェース一覧:
org.reactivestreams.Subscriber<Message<?>>, Aware, BeanFactoryAware, BeanNameAware, DisposableBean, InitializingBean, ApplicationContextAware, Ordered, ComponentSourceAware, ExpressionCapable, Orderable, IntegrationPattern, NamedComponent, IntegrationManagement, TrackableComponent, MessageHandler, reactor.core.CoreSubscriber<Message<?>>

public class JdbcMessageHandler extends AbstractMessageHandler
SQL 更新を実行するメッセージハンドラー。動的クエリパラメーターは、SqlParameterSourceFactory 抽象化を通じてサポートされます。SqlParameterSourceFactory のデフォルト実装は、メッセージをラップして、その Bean プロパティをクエリ文字列で名前で参照できるようにします。
INSERT INTO ITEMS (MESSAGE_ID, PAYLOAD) VALUES (:headers[id], :payload)

メッセージペイロードが IterableSE のインスタンスである場合、NamedParameterJdbcOperations.batchUpdate(String, SqlParameterSource[]) が実行されます。各 SqlParameterSource インスタンスは、リクエストメッセージのヘッダーを使用して内部 Message 実装にラップされた項目に基づいています。項目はまだ Message でない場合のみ折り返しされます。

preparedStatementSetter が構成されている場合、適切な JdbcOperations.batchUpdate(String, BatchPreparedStatementSetter) 機能の各項目に適用されます。

NOTE: keysGenerated が使用されている場合、バッチ更新はサポートされません。

N.B. ヘッダーキーをエスケープするために引用符を使用しないでください。デフォルトの SQL パラメーターソース(Spring JDBC から)は、ドット付きの名前のヘッダーも処理できます (たとえば business.id)

導入:
2.0
作成者:
Dave Syer, Artem Bilan, Trung Pham
  • コンストラクターの詳細

    • JdbcMessageHandler

      public JdbcMessageHandler(DataSourceSE dataSource, StringSE updateSql)
      DB 接続を取得できる DataSourceSE と、新しい行を取得するために実行する選択クエリを取得するコンストラクター。
      パラメーター:
      dataSource - null であってはなりません
      updateSql - 実行するクエリ
    • JdbcMessageHandler

      public JdbcMessageHandler(JdbcOperations jdbcOperations, StringSE updateSql)
      クエリの実行に使用する JdbcOperations インスタンスと、新しい行を取得するために実行する選択クエリを取得するコンストラクター。
      パラメーター:
      jdbcOperations - クエリの実行に使用するインスタンス
      updateSql - 実行するクエリ
  • 方法の詳細

    • setKeysGenerated

      public void setKeysGenerated(boolean keysGenerated)
      更新クエリが自動生成キーを使用した挿入であることを示すフラグ。デバッグレベルでログに記録されます。
      パラメーター:
      keysGenerated - 設定するフラグ値
    • setSqlParameterSourceFactory

      public void setSqlParameterSourceFactory(SqlParameterSourceFactory sqlParameterSourceFactory)
      SqlParameterSourceFactory を構成します。
      パラメーター:
      sqlParameterSourceFactory - 使用する SqlParameterSourceFactory。
    • setUsePayloadAsParameterSource

      public void setUsePayloadAsParameterSource(boolean usePayloadAsParameterSource)
      "true" に設定すると、メッセージのペイロードがパラメーターを提供するためのソースとして使用されます。false の場合、Message 全体がパラメーターのソースとして使用できます。setPreparedStatementSetter(MessagePreparedStatementSetter) が提供されていない場合にのみ意味があります。
      パラメーター:
      usePayloadAsParameterSource - パラメーターソースとしての Message 全体に対して false です。
    • setPreparedStatementSetter

      public void setPreparedStatementSetter(@Nullable MessagePreparedStatementSetter preparedStatementSetter)
      MessagePreparedStatementSetter を指定して、PreparedStatementSE のパラメーターに Message コンテキストを設定します。

      これは SqlParameterSourceFactory の低レベルの代替です。

      パラメーター:
      preparedStatementSetter - 設定する MessagePreparedStatementSetter
    • getComponentType

      public StringSE getComponentType()
      次で指定:
      インターフェース NamedComponent 内の getComponentType 
      オーバーライド:
      クラス MessageHandlerSupport の getComponentType 
    • onInit

      protected void onInit()
      クラスからコピーされた説明: IntegrationObjectSupport
      サブクラスは、初期化ロジック用にこれを実装できます。
      オーバーライド:
      クラス IntegrationObjectSupport の onInit 
    • handleMessageInternal

      protected void handleMessageInternal(Message<?> message)
      更新を実行し、メッセージを SqlParameterSourceFactory に渡します。
      次で指定:
      クラス AbstractMessageHandler の handleMessageInternal 
    • executeUpdateQuery

      protected ListSE<? extends MapSE<StringSE,ObjectSE>> executeUpdateQuery(Message<?> message, boolean keysGenerated)
      提供されたメッセージと生成されたキーフラグの更新を実行します。
      パラメーター:
      message - クエリパラメーターの更新に使用するメッセージ。
      keysGenerated - キーを生成するかどうか。
      戻り値:
      更新用に生成されたキー。