クラス RabbitUtils


  • public abstract class RabbitUtils
    extends ObjectSE
    作成者:
    Mark Fisher, Mark Pollack, Gary Russell, Artem Bilan
    • コンストラクターのサマリー

      コンストラクター  
      コンストラクター 説明
      RabbitUtils()
    • メソッドのサマリー

      すべてのメソッド   静的メソッド   具象メソッド  
      修飾子と型 メソッド 説明
      static voidcancel​(com.rabbitmq.client.Channel channel, StringSE consumerTag)
      static voidclearPhysicalCloseRequired()
      physicalCloseRequired フラグをクリアします。
      static voidcloseChannel​(com.rabbitmq.client.Channel channel)
      指定された RabbitMQ チャネルを閉じ、スローされた例外を無視します。
      static voidcloseConnection​(Connection connection)
      指定された RabbitMQ 接続を閉じ、スローされた例外を無視します。
      static voidcloseMessageConsumer​(com.rabbitmq.client.Channel channel, CollectionSE<StringSE> consumerTags, boolean transactional)
      static voidcommitIfNecessary​(com.rabbitmq.client.Channel channel)
      JTA トランザクション内にない場合は、チャネルをコミットします。
      static voiddeclareTransactional​(com.rabbitmq.client.Channel channel)
      チャネルがトランザクションで使用されることをそのブローカーに宣言し、発生した例外を変換します。
      static intgetMaxFrame​(ConnectionFactory connectionFactory)
      ネゴシエートされた frame_max を返します。
      static booleanisExchangeDeclarationFailure​(ExceptionSE e)
      原因ツリーに ShutdownSignalException があり、その理由が "COMMAND_INVALID" であり、実行中の操作が exchangeDeclare である場合は、true を返します。
      static booleanisExclusiveUseChannelClose​(com.rabbitmq.client.ShutdownSignalException sig)
      ShutdownSignalException の理由が AMQP.Channel.Close で、失敗した操作が basicConsumer で、失敗のテキストに "exclusive" が含まれている場合は、true を返します。
      static booleanisMismatchedQueueArgs​(ExceptionSE e)
      原因ツリーに ShutdownSignalException があり、その理由が "PRECONDITION_FAILED" で、実行中の操作が queueDeclare である場合は、true を返します。
      static booleanisNormalChannelClose​(com.rabbitmq.client.ShutdownSignalException sig)
      ShutdownSignalException の理由が AMQP.Channel.Close で、応答コードが AMQP.REPLY_SUCCESS (200) で、テキストが "OK" の場合、true を返します。
      static booleanisNormalShutdown​(com.rabbitmq.client.ShutdownSignalException sig)
      ShutdownSignalException の理由が AMQP.Connection.Close で、応答コードが AMQP.REPLY_SUCCESS (200) で、テキストが "OK" の場合、true を返します。
      static booleanisPassiveDeclarationChannelClose​(com.rabbitmq.client.ShutdownSignalException sig)
      ShutdownSignalException の理由が AMQP.Channel.Close であり、失敗した操作が exchangeDeclare または queueDeclare である場合は、true を返します。
      static booleanisPhysicalCloseRequired()
      チャネルを物理的に閉じる必要があることを示す ThreadLocal を取得および削除します。
      static voidrollbackIfNecessary​(com.rabbitmq.client.Channel channel)
      static voidsetPhysicalCloseRequired​(com.rabbitmq.client.Channel channel, boolean b)
      チャネルを物理的に閉じなければならないことを示す ThreadLocal を設定します。
      static com.rabbitmq.client.SaslConfigstringToSaslConfig​(StringSE saslConfig, com.rabbitmq.client.ConnectionFactory connectionFactory)
      String 値を SaslConfig に変換します。
    • フィールドの詳細

      • DECLARE_METHOD_ID_10

        public static final int DECLARE_METHOD_ID_10
        AMQP 宣言メソッド。
        関連事項:
        定数フィールド値
      • CONSUME_METHOD_ID_20

        public static final int CONSUME_METHOD_ID_20
        AMQP 消費メソッド。
        関連事項:
        定数フィールド値
      • EXCHANGE_CLASS_ID_40

        public static final int EXCHANGE_CLASS_ID_40
        AMQP 交換クラス ID。
        関連事項:
        定数フィールド値
      • CONNECTION_PROTOCOL_CLASS_ID_10

        public static final int CONNECTION_PROTOCOL_CLASS_ID_10
        AMQP 接続プロトコルクラス ID。
        関連事項:
        定数フィールド値
      • CHANNEL_PROTOCOL_CLASS_ID_20

        public static final int CHANNEL_PROTOCOL_CLASS_ID_20
        AMQP チャネルプロトコルクラス ID。
        関連事項:
        定数フィールド値
    • コンストラクターの詳細

      • RabbitUtils

        public RabbitUtils()
    • メソッドの詳細

      • closeConnection

        public static void closeConnection​(@Nullable
                                           Connection connection)
        指定された RabbitMQ 接続を閉じ、スローされた例外を無視します。これは、手動の RabbitMQ コードの典型的な finally ブロックに役立ちます。
        パラメーター:
        connection - 閉じる RabbitMQ 接続 (null の場合があります)
      • closeChannel

        public static void closeChannel​(@Nullable
                                        com.rabbitmq.client.Channel channel)
        指定された RabbitMQ チャネルを閉じ、スローされた例外を無視します。これは、手動の RabbitMQ コードの典型的な finally ブロックに役立ちます。
        パラメーター:
        channel - 閉じる RabbitMQ チャネル (null の場合があります)
      • commitIfNecessary

        public static void commitIfNecessary​(com.rabbitmq.client.Channel channel)
        JTA トランザクション内にない場合は、チャネルをコミットします。
        パラメーター:
        channel - コミットする RabbitMQ チャネル
      • rollbackIfNecessary

        public static void rollbackIfNecessary​(com.rabbitmq.client.Channel channel)
      • closeMessageConsumer

        public static void closeMessageConsumer​(com.rabbitmq.client.Channel channel,
                                                CollectionSE<StringSE> consumerTags,
                                                boolean transactional)
      • cancel

        public static void cancel​(com.rabbitmq.client.Channel channel,
                                  StringSE consumerTag)
      • declareTransactional

        public static void declareTransactional​(com.rabbitmq.client.Channel channel)
        チャネルがトランザクションで使用されることをそのブローカーに宣言し、発生した例外を変換します。
        パラメーター:
        channel - 使用するチャネル
      • setPhysicalCloseRequired

        public static void setPhysicalCloseRequired​(com.rabbitmq.client.Channel channel,
                                                    boolean b)
        チャネルを物理的に閉じなければならないことを示す ThreadLocal を設定します。
        パラメーター:
        channel - チャンネル。
        b - チャネルを閉じる必要がある場合 (プロキシの場合) は true。
      • isPhysicalCloseRequired

        public static boolean isPhysicalCloseRequired()
        チャネルを物理的に閉じる必要があることを示す ThreadLocal を取得および削除します。
        戻り値:
        チャネルを物理的に閉じる必要がある場合は true
      • clearPhysicalCloseRequired

        public static void clearPhysicalCloseRequired()
        physicalCloseRequired フラグをクリアします。
      • isNormalShutdown

        public static boolean isNormalShutdown​(com.rabbitmq.client.ShutdownSignalException sig)
        ShutdownSignalException の理由が AMQP.Connection.Close で、応答コードが AMQP.REPLY_SUCCESS (200) で、テキストが "OK" の場合、true を返します。
        パラメーター:
        sig - 例外。
        戻り値:
        通常の接続クローズの場合は true。
      • isNormalChannelClose

        public static boolean isNormalChannelClose​(com.rabbitmq.client.ShutdownSignalException sig)
        ShutdownSignalException の理由が AMQP.Channel.Close で、応答コードが AMQP.REPLY_SUCCESS (200) で、テキストが "OK" の場合、true を返します。
        パラメーター:
        sig - 例外。
        戻り値:
        通常のチャネルクローズの場合は true。
      • isPassiveDeclarationChannelClose

        public static boolean isPassiveDeclarationChannelClose​(com.rabbitmq.client.ShutdownSignalException sig)
        ShutdownSignalException の理由が AMQP.Channel.Close であり、失敗した操作が exchangeDeclare または queueDeclare である場合は、true を返します。
        パラメーター:
        sig - 例外。
        戻り値:
        失敗が条件を満たしている場合は true。
      • isExclusiveUseChannelClose

        public static boolean isExclusiveUseChannelClose​(com.rabbitmq.client.ShutdownSignalException sig)
        ShutdownSignalException の理由が AMQP.Channel.Close で、失敗した操作が basicConsumer で、失敗のテキストに "exclusive" が含まれている場合は、true を返します。
        パラメーター:
        sig - 例外。
        戻り値:
        排他キューが原因で宣言が失敗した場合は true。
      • isMismatchedQueueArgs

        public static boolean isMismatchedQueueArgs​(ExceptionSE e)
        原因ツリーに ShutdownSignalException があり、その理由が "PRECONDITION_FAILED" で、実行中の操作が queueDeclare である場合は、true を返します。これは、キューに一致しないプロパティ (auto-delete など) または引数 (x-message-ttl など) がある場合に発生する可能性があります。
        パラメーター:
        e - 例外。
        戻り値:
        キュー宣言の前提条件が失敗したために例外が発生した場合は true。
        導入:
        1.6
      • isExchangeDeclarationFailure

        public static boolean isExchangeDeclarationFailure​(ExceptionSE e)
        原因ツリーに ShutdownSignalException があり、その理由が "COMMAND_INVALID" であり、実行中の操作が exchangeDeclare である場合は、true を返します。たとえば、ブローカーまたはそのプラグインでサポートされていない交換を宣言しようとしています。
        パラメーター:
        e - 例外。
        戻り値:
        交換宣言の失敗が原因で例外が発生した場合は true。
        導入:
        1.6
      • getMaxFrame

        public static int getMaxFrame​(ConnectionFactory connectionFactory)
        ネゴシエートされた frame_max を返します。
        パラメーター:
        connectionFactory - 接続ファクトリ。
        戻り値:
        サイズを決定できない場合は -1。
      • stringToSaslConfig

        public static com.rabbitmq.client.SaslConfig stringToSaslConfig​(StringSE saslConfig,
                                                                        com.rabbitmq.client.ConnectionFactory connectionFactory)
        String 値を SaslConfig に変換します。有効な文字列値:
        • DefaultSaslConfig.PLAIN
        • DefaultSaslConfig.EXTERNAL
        • JDKSaslConfig
        • CRDemoSaslConfig
        パラメーター:
        saslConfig - 文字列値。
        connectionFactory - 名前、pw、ホストを取得する接続ファクトリ。
        戻り値:
        saslConfig。