クラス BlockingQueueConsumer
java.lang.ObjectSE
org.springframework.amqp.rabbit.listener.BlockingQueueConsumer
ブローカー接続の知識をカプセル化し、独自のライフサイクル (開始と停止) を持つ特殊なコンシューマー。
- 作成者:
- Mark Pollack, Dave Syer, Gary Russell, Casper Mout, Artem Bilan, Alex Panchenko, Johno Crawford, Ian Roberts, Cao Weibo
コンストラクターのサマリー
コンストラクターコンストラクター説明BlockingQueueConsumer
(ConnectionFactory connectionFactory, MessagePropertiesConverter messagePropertiesConverter, ActiveObjectCounter<BlockingQueueConsumer> activeObjectCounter, AcknowledgeMode acknowledgeMode, boolean transactional, int prefetchCount, boolean defaultRequeueRejected, StringSE... queues) コンシューマーを作成します。BlockingQueueConsumer
(ConnectionFactory connectionFactory, MessagePropertiesConverter messagePropertiesConverter, ActiveObjectCounter<BlockingQueueConsumer> activeObjectCounter, AcknowledgeMode acknowledgeMode, boolean transactional, int prefetchCount, boolean defaultRequeueRejected, MapSE<StringSE, ObjectSE> consumerArgs, boolean noLocal, boolean exclusive, StringSE... queues) コンシューマーを作成します。BlockingQueueConsumer
(ConnectionFactory connectionFactory, MessagePropertiesConverter messagePropertiesConverter, ActiveObjectCounter<BlockingQueueConsumer> activeObjectCounter, AcknowledgeMode acknowledgeMode, boolean transactional, int prefetchCount, boolean defaultRequeueRejected, MapSE<StringSE, ObjectSE> consumerArgs, boolean exclusive, StringSE... queues) コンシューマーを作成します。BlockingQueueConsumer
(ConnectionFactory connectionFactory, MessagePropertiesConverter messagePropertiesConverter, ActiveObjectCounter<BlockingQueueConsumer> activeObjectCounter, AcknowledgeMode acknowledgeMode, boolean transactional, int prefetchCount, boolean defaultRequeueRejected, MapSE<StringSE, ObjectSE> consumerArgs, StringSE... queues) コンシューマーを作成します。BlockingQueueConsumer
(ConnectionFactory connectionFactory, MessagePropertiesConverter messagePropertiesConverter, ActiveObjectCounter<BlockingQueueConsumer> activeObjectCounter, AcknowledgeMode acknowledgeMode, boolean transactional, int prefetchCount, StringSE... queues) コンシューマーを作成します。メソッドのサマリー
修飾子と型メソッド説明protected void
protected void
basicCancel
(boolean expected) protected boolean
void
外部トランザクションマネージャーでロールバックするときに配信タグをクリアします。boolean
commitIfNecessary
(boolean localTx) 非推奨、削除予定: この API 要素は、将来のバージョンで削除される可能性があります。void
com.rabbitmq.client.Channel
protected boolean
boolean
キャンセルが予想される場合は true を返します。主なアプリケーション側 API: 次のメッセージ配信を待って、それを返します。nextMessage
(long timeout) 主なアプリケーション側 API: 次のメッセージ配信を待って、それを返します。void
ロールバックを実行し、ロールバック例外を適切に処理します。void
rollbackOnExceptionIfNecessary
(ThrowableSE ex, long tag) ロールバックを実行し、ロールバック例外を適切に処理します。void
setApplicationEventPublisher
(ApplicationEventPublisher applicationEventPublisher) void
setBackOffExecution
(BackOffExecution backOffExecution) SimpleMessageListenerContainer
でリカバリに使用するBackOffExecution
を設定します。void
setConsumeDelay
(long consumeDelay) consumerDelay を設定します - 消費するまでの待機時間 (ミリ秒)。void
setDeclarationRetries
(int declarationRetries) パッシブキュー宣言失敗後のリトライ回数を設定します。void
setFailedDeclarationRetryInterval
(long failedDeclarationRetryInterval) パッシブキュー宣言の試行間隔をミリ秒単位で設定します。void
setGlobalQos
(boolean globalQos) チャネル全体にプリフェッチを適用します。void
setLocallyTransacted
(boolean locallyTransacted) チャネルがローカルで処理される場合は true。void
setMessageAckListener
(MessageAckListener messageAckListener) AcknowledgeMode.AUTO
モードでメッセージ (メッセージ) を確認するときに使用するMessageAckListener
を設定します。void
setMissingQueuePublisher
(ConsumerSE<StringSE> missingQueuePublisher) 不足しているキューイベントのパブリッシャーを設定します。void
setRetryDeclarationInterval
(long retryDeclarationInterval) 複数のキューを使用する場合、キューのサブセットのみが使用可能な場合の宣言試行の間隔を設定します (ミリ秒)。void
setShutdownTimeout
(long shutdownTimeout) void
setTagStrategy
(ConsumerTagStrategy tagStrategy) コンシューマータグの生成時に使用するConsumerTagStrategy
を設定します。void
start()
void
stop()
toString()
コンストラクターの詳細
BlockingQueueConsumer
public BlockingQueueConsumer(ConnectionFactory connectionFactory, MessagePropertiesConverter messagePropertiesConverter, ActiveObjectCounter<BlockingQueueConsumer> activeObjectCounter, AcknowledgeMode acknowledgeMode, boolean transactional, int prefetchCount, StringSE... queues) コンシューマーを作成します。コンシューマーは、接続ファクトリを使用したり、ブローカーが開始されるまでブローカーと通信したりしてはなりません。RequeueRejected のデフォルトは true です。- パラメーター:
connectionFactory
- 接続ファクトリ。messagePropertiesConverter
- プロパティコンバーター。activeObjectCounter
- アクティブなオブジェクトカウンター。シャットダウン中に使用されます。acknowledgeMode
- 確認モード。transactional
- チャネルがトランザクションかどうか。prefetchCount
- プリフェッチカウント。queues
- キュー。
BlockingQueueConsumer
public BlockingQueueConsumer(ConnectionFactory connectionFactory, MessagePropertiesConverter messagePropertiesConverter, ActiveObjectCounter<BlockingQueueConsumer> activeObjectCounter, AcknowledgeMode acknowledgeMode, boolean transactional, int prefetchCount, boolean defaultRequeueRejected, StringSE... queues) コンシューマーを作成します。コンシューマーは、接続ファクトリを使用したり、ブローカーが開始されるまでブローカーと通信したりしてはなりません。- パラメーター:
connectionFactory
- 接続ファクトリ。messagePropertiesConverter
- プロパティコンバーター。activeObjectCounter
- アクティブなオブジェクトカウンター。シャットダウン中に使用されます。acknowledgeMode
- 確認応答モード。transactional
- チャネルがトランザクションかどうか。prefetchCount
- プリフェッチカウント。defaultRequeueRejected
- 再キューイングされたメッセージを拒否する場合は true。queues
- キュー。
BlockingQueueConsumer
public BlockingQueueConsumer(ConnectionFactory connectionFactory, MessagePropertiesConverter messagePropertiesConverter, ActiveObjectCounter<BlockingQueueConsumer> activeObjectCounter, AcknowledgeMode acknowledgeMode, boolean transactional, int prefetchCount, boolean defaultRequeueRejected, @Nullable MapSE<StringSE, ObjectSE> consumerArgs, StringSE... queues) コンシューマーを作成します。コンシューマーは、接続ファクトリを使用したり、ブローカーが開始されるまでブローカーと通信したりしてはなりません。- パラメーター:
connectionFactory
- 接続ファクトリ。messagePropertiesConverter
- プロパティコンバーター。activeObjectCounter
- アクティブなオブジェクトカウンター。シャットダウン中に使用されます。acknowledgeMode
- 確認応答モード。transactional
- チャネルがトランザクションかどうか。prefetchCount
- プリフェッチカウント。defaultRequeueRejected
- 再キューイングされたメッセージを拒否する場合は true。consumerArgs
- コンシューマーの引数 (例: x-priority)。queues
- キュー。
BlockingQueueConsumer
public BlockingQueueConsumer(ConnectionFactory connectionFactory, MessagePropertiesConverter messagePropertiesConverter, ActiveObjectCounter<BlockingQueueConsumer> activeObjectCounter, AcknowledgeMode acknowledgeMode, boolean transactional, int prefetchCount, boolean defaultRequeueRejected, @Nullable MapSE<StringSE, ObjectSE> consumerArgs, boolean exclusive, StringSE... queues) コンシューマーを作成します。コンシューマーは、接続ファクトリを使用したり、ブローカーが開始されるまでブローカーと通信したりしてはなりません。- パラメーター:
connectionFactory
- 接続ファクトリ。messagePropertiesConverter
- プロパティコンバーター。activeObjectCounter
- アクティブなオブジェクトカウンター。シャットダウン中に使用されます。acknowledgeMode
- 確認応答モード。transactional
- チャネルがトランザクションかどうか。prefetchCount
- プリフェッチカウント。defaultRequeueRejected
- 再キューイングされたメッセージを拒否する場合は true。consumerArgs
- コンシューマーの引数 (例: x-priority)。exclusive
- コンシューマーが排他的である場合は true。queues
- キュー。
BlockingQueueConsumer
public BlockingQueueConsumer(ConnectionFactory connectionFactory, MessagePropertiesConverter messagePropertiesConverter, ActiveObjectCounter<BlockingQueueConsumer> activeObjectCounter, AcknowledgeMode acknowledgeMode, boolean transactional, int prefetchCount, boolean defaultRequeueRejected, @Nullable MapSE<StringSE, ObjectSE> consumerArgs, boolean noLocal, boolean exclusive, StringSE... queues) コンシューマーを作成します。コンシューマーは、接続ファクトリを使用したり、ブローカーが開始されるまでブローカーと通信したりしてはなりません。- パラメーター:
connectionFactory
- 接続ファクトリ。messagePropertiesConverter
- プロパティコンバーター。activeObjectCounter
- アクティブなオブジェクトカウンター。シャットダウン中に使用されます。acknowledgeMode
- 確認応答モード。transactional
- チャネルがトランザクションかどうか。prefetchCount
- プリフェッチカウント。defaultRequeueRejected
- 再キューイングされたメッセージを拒否する場合は true。consumerArgs
- コンシューマーの引数 (例: x-priority)。noLocal
- コンシューマーが非ローカルである場合は true。exclusive
- コンシューマーが排他的である場合は true。queues
- キュー。- 導入:
- 1.7.4
メソッドの詳細
getChannel
public com.rabbitmq.client.Channel getChannel()getConsumerTags
setShutdownTimeout
public void setShutdownTimeout(long shutdownTimeout) setDeclarationRetries
public void setDeclarationRetries(int declarationRetries) パッシブキュー宣言失敗後のリトライ回数を設定します。- パラメーター:
declarationRetries
- 再試行回数。デフォルトは 3 です。- 導入:
- 1.3.9
- 関連事項:
setFailedDeclarationRetryInterval
public void setFailedDeclarationRetryInterval(long failedDeclarationRetryInterval) パッシブキュー宣言の試行間隔をミリ秒単位で設定します。- パラメーター:
failedDeclarationRetryInterval
- 間隔、デフォルトは 5000。- 導入:
- 1.3.9
- 関連事項:
setRetryDeclarationInterval
public void setRetryDeclarationInterval(long retryDeclarationInterval) 複数のキューを使用する場合、キューのサブセットのみが使用可能な場合の宣言試行の間隔を設定します (ミリ秒)。- パラメーター:
retryDeclarationInterval
- 間隔、デフォルトは 60000。- 導入:
- 1.3.9
setTagStrategy
コンシューマータグの生成時に使用するConsumerTagStrategy
を設定します。- パラメーター:
tagStrategy
- 設定する tagStrategy- 導入:
- 1.4.5
setBackOffExecution
SimpleMessageListenerContainer
でリカバリに使用するBackOffExecution
を設定します。- パラメーター:
backOffExecution
- backOffExecution。- 導入:
- 1.5
getBackOffExecution
setLocallyTransacted
public void setLocallyTransacted(boolean locallyTransacted) チャネルがローカルで処理される場合は true。- パラメーター:
locallyTransacted
- 設定するためにローカルに処理されます。- 導入:
- 1.6.6
setApplicationEventPublisher
public void setApplicationEventPublisher(@Nullable ApplicationEventPublisher applicationEventPublisher) setMissingQueuePublisher
不足しているキューイベントのパブリッシャーを設定します。- パラメーター:
missingQueuePublisher
- パブリッシャー。- 導入:
- 2.1.18
setConsumeDelay
public void setConsumeDelay(long consumeDelay) consumerDelay を設定します - 消費するまでの待機時間 (ミリ秒)。これは、concurrency > 1
でシャーディングプラグインを使用する場合に役立ち、シャード間でのコンシューマーの不均一な分散を回避します。詳細については、プラグインの README を参照してください。- パラメーター:
consumeDelay
- 消費遅延。- 導入:
- 2.3
setMessageAckListener
AcknowledgeMode.AUTO
モードでメッセージ (メッセージ) を確認するときに使用するMessageAckListener
を設定します。- パラメーター:
messageAckListener
- メッセージ AckListener。- 導入:
- 2.4.6
clearDeliveryTags
public void clearDeliveryTags()外部トランザクションマネージャーでロールバックするときに配信タグをクリアします。- 導入:
- 1.6.6
setGlobalQos
public void setGlobalQos(boolean globalQos) チャネル全体にプリフェッチを適用します。- パラメーター:
globalQos
- チャネル全体のプリフェッチの場合は true。- 導入:
- 2.2.17
- 関連事項:
Channel.basicQos(int, boolean)
isNormalCancel
public boolean isNormalCancel()キャンセルが予想される場合は true を返します。- 戻り値:
- 予想される場合は true。
basicCancel
protected void basicCancel()basicCancel
protected void basicCancel(boolean expected) hasDelivery
protected boolean hasDelivery()cancelled
protected boolean cancelled()nextMessage
@Nullable public Message nextMessage() throws InterruptedExceptionSE, com.rabbitmq.client.ShutdownSignalException主なアプリケーション側 API: 次のメッセージ配信を待って、それを返します。- 戻り値:
- 次のメッセージ
- 例外:
InterruptedExceptionSE
- 待機中に割り込みを受けた場合com.rabbitmq.client.ShutdownSignalException
- 待機中に接続が切断された場合
nextMessage
@Nullable public Message nextMessage(long timeout) throws InterruptedExceptionSE, com.rabbitmq.client.ShutdownSignalException 主なアプリケーション側 API: 次のメッセージ配信を待って、それを返します。- パラメーター:
timeout
- ミリ秒単位のタイムアウト- 戻り値:
- 次のメッセージ、またはタイムアウトの場合は null
- 例外:
InterruptedExceptionSE
- 待機中に割り込みを受けた場合com.rabbitmq.client.ShutdownSignalException
- 待機中に接続が切断された場合
start
stop
public void stop()forceCloseAndClearQueue
public void forceCloseAndClearQueue()rollbackOnExceptionIfNecessary
ロールバックを実行し、ロールバック例外を適切に処理します。- パラメーター:
ex
- スローされたアプリケーションの例外またはエラー
rollbackOnExceptionIfNecessary
ロールバックを実行し、ロールバック例外を適切に処理します。- パラメーター:
ex
- スローされたアプリケーションの例外またはエラーtag
- 配送タグ ; 指定した場合 (0 以上)、そのメッセージのみが破棄されます。- 導入:
- 2.2.21.
commitIfNecessary
非推奨、削除予定: この API 要素は、将来のバージョンで削除される可能性があります。commitIfNecessary(boolean, boolean)
を推奨して必要に応じて、コミットまたはメッセージ確認を実行します。注: このメソッドは公開することを意図したものではありません。- パラメーター:
localTx
- チャネルがローカルで処理されるかどうか。- 戻り値:
- 少なくとも 1 つの配信タグが存在する場合は true。
toString
commitIfNecessary(boolean, boolean)
を推奨して