public class AsyncRabbitTemplate extends ObjectSE implements AsyncAmqpTemplate, ChannelAwareMessageListener, RabbitTemplate.ReturnsCallback, RabbitTemplate.ConfirmCallback, BeanNameAware, SmartLifecycle
ListenableFuture を返す非同期の送受信操作を提供し、呼び出し元が後で get() またはコールバックを使用して応答を取得できるようにします。 確認が有効になっている場合、未来にはそれ自体が ListenableFuture である確認プロパティがあります。パブリッシャーが確認する前に返信が受信された場合、返信はメッセージが公開されたことを暗黙的に示しているため、確認は破棄されます。
返された (配信不能な) リクエストメッセージは、ExecutionExceptionSE の AmqpMessageReturnedException 原因として提示されます。
内部的には、テンプレートは内部で提供または構築された RabbitTemplate および AbstractMessageListenerContainer ( SimpleMessageListenerContainer ) を使用します。外部 RabbitTemplate が提供され、確認 /return が有効になっている場合、このオブジェクトはコールバックである必要があるため、以前にコールバックが登録されていてはなりません。
| 修飾子と型 | クラスと説明 |
|---|---|
class | AsyncRabbitTemplate.RabbitConverterFuture<C> テンプレートのジェネリクスパラメーターの戻り型を持つ AsyncRabbitTemplate.RabbitFuture。 |
class | AsyncRabbitTemplate.RabbitFuture<T>AsyncRabbitTemplate によって返される ListenableFuture の基底クラス。 |
class | AsyncRabbitTemplate.RabbitMessageFuture 戻り値の型が Message の AsyncRabbitTemplate.RabbitFuture。 |
| 修飾子と型 | フィールドと説明 |
|---|---|
static int | DEFAULT_RECEIVE_TIMEOUT |
DEFAULT_PHASE| コンストラクターと説明 |
|---|
AsyncRabbitTemplate(ConnectionFactory connectionFactory, StringSE exchange, StringSE routingKey) 提供された引数を使用してインスタンスを構築します。 |
AsyncRabbitTemplate(ConnectionFactory connectionFactory, StringSE exchange, StringSE routingKey, StringSE replyQueue) 提供された引数を使用してインスタンスを構築します。 |
AsyncRabbitTemplate(ConnectionFactory connectionFactory, StringSE exchange, StringSE routingKey, StringSE replyQueue, StringSE replyAddress) 提供された引数を使用してインスタンスを構築します。 |
AsyncRabbitTemplate(RabbitTemplate template) 提供された引数を使用してインスタンスを構築します。 |
AsyncRabbitTemplate(RabbitTemplate template, AbstractMessageListenerContainer container) 提供された引数を使用してインスタンスを構築します。 |
AsyncRabbitTemplate(RabbitTemplate template, AbstractMessageListenerContainer container, StringSE replyAddress) 提供された引数を使用してインスタンスを構築します。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, waitSE, waitSE, waitSEonMessage, onMessageBatchcontainerAckMode, onMessageBatchdelegate, returnedMessagestoppublic static final int DEFAULT_RECEIVE_TIMEOUT
public AsyncRabbitTemplate(ConnectionFactory connectionFactory, StringSE exchange, StringSE routingKey, StringSE replyQueue)
connectionFactory - 接続ファクトリ。exchange - リクエストが送信されるデフォルトの交換。routingKey - デフォルトのルーティングキー。replyQueue - 応答をリッスンする応答キューの名前。public AsyncRabbitTemplate(ConnectionFactory connectionFactory, StringSE exchange, StringSE routingKey, StringSE replyQueue, StringSE replyAddress)
connectionFactory - 接続ファクトリ。exchange - リクエストが送信されるデフォルトの交換。routingKey - デフォルトのルーティングキー。replyQueue - 応答をリッスンする応答キューの名前。replyAddress - 返信アドレス(exchange/routingKey)。public AsyncRabbitTemplate(RabbitTemplate template, AbstractMessageListenerContainer container)
template - RabbitTemplatecontainer - AbstractMessageListenerContainer。public AsyncRabbitTemplate(RabbitTemplate template, AbstractMessageListenerContainer container, StringSE replyAddress)
template - RabbitTemplate。container - AbstractMessageListenerContainer。replyAddress - 返信アドレス。public AsyncRabbitTemplate(ConnectionFactory connectionFactory, StringSE exchange, StringSE routingKey)
connectionFactory - 接続ファクトリ。exchange - リクエストが送信されるデフォルトの交換。routingKey - デフォルトのルーティングキー。public AsyncRabbitTemplate(RabbitTemplate template)
template - RabbitTemplatepublic void setAutoStartup(boolean autoStartup)
autoStartup - 自動開始の場合は true。isAutoStartup()public void setPhase(int phase)
phase - フェーズ。getPhase()public void setMandatory(boolean mandatory)
AmqpMessageReturnedException の形式で配信できない返されたメッセージの受信を有効にするには、true に設定します。mandatory - return を有効にする場合は true。public void setMandatoryExpression(Expression mandatoryExpression)
mandatoryExpression - 各リクエストメッセージに対して評価する SpEL Expression。評価の結果は、boolean 値でなければなりません。public void setMandatoryExpressionString(StringSE mandatoryExpression)
mandatoryExpression - 各リクエストメッセージに対して評価する SpEL Expression。評価の結果は、boolean 値でなければなりません。public void setEnableConfirms(boolean enableConfirms)
AsyncRabbitTemplate.RabbitFuture の confirm プロパティに ListenableFuture<Boolean> が含まれます。enableConfirms - パブリッシャーの確認を有効にする場合は true。public StringSE getBeanName()
public void setBeanName(StringSE beanName)
BeanNameAware 内の setBeanName public ConnectionFactory getConnectionFactory()
RabbitTemplate 内の基礎となる接続ファクトリへの参照。public void setReceiveTimeout(long receiveTimeout)
<= 0 は、先物が期限切れにならないことを意味します。応答が受信されない場合、これによりメモリリークが発生することに注意してください。デフォルト: 30000 (30 秒)。receiveTimeout - ミリ秒単位のタイムアウト。public void setTaskScheduler(TaskScheduler taskScheduler)
taskScheduler - タスクスケジューラ setReceiveTimeout(long)public MessageConverter getMessageConverter()
RabbitTemplate の MessageConverter への参照。public RabbitTemplate getRabbitTemplate()
RabbitTemplate を返します。public AsyncRabbitTemplate.RabbitMessageFuture sendAndReceive(Message message)
AsyncAmqpTemplateAsyncAmqpTemplate 内の sendAndReceive message - メッセージ。ListenableFuturepublic AsyncRabbitTemplate.RabbitMessageFuture sendAndReceive(StringSE routingKey, Message message)
AsyncAmqpTemplateAsyncAmqpTemplate 内の sendAndReceive routingKey - ルーティングキー。message - メッセージ。ListenableFuturepublic AsyncRabbitTemplate.RabbitMessageFuture sendAndReceive(StringSE exchange, StringSE routingKey, Message message)
AsyncAmqpTemplateAsyncAmqpTemplate 内の sendAndReceive exchange - 交換。routingKey - ルーティングキー。message - メッセージ。ListenableFuturepublic <C> AsyncRabbitTemplate.RabbitConverterFuture<C> convertSendAndReceive(ObjectSE object)
AsyncAmqpTemplateAsyncAmqpTemplate 内の convertSendAndReceive C - 期待される結果型。object - 変換するオブジェクト。ListenableFuturepublic <C> AsyncRabbitTemplate.RabbitConverterFuture<C> convertSendAndReceive(StringSE routingKey, ObjectSE object)
AsyncAmqpTemplateAsyncAmqpTemplate 内の convertSendAndReceive C - 期待される結果型。routingKey - ルーティングキー。object - 変換するオブジェクト。ListenableFuturepublic <C> AsyncRabbitTemplate.RabbitConverterFuture<C> convertSendAndReceive(StringSE exchange, StringSE routingKey, ObjectSE object)
AsyncAmqpTemplateAsyncAmqpTemplate 内の convertSendAndReceive C - 期待される結果型。exchange - 交換。routingKey - ルーティングキー。object - 変換するオブジェクト。ListenableFuturepublic <C> AsyncRabbitTemplate.RabbitConverterFuture<C> convertSendAndReceive(ObjectSE object, MessagePostProcessor messagePostProcessor)
AsyncAmqpTemplateMessagePostProcessor を呼び出した後、デフォルトのルーティングキーを使用してデフォルトの交換に送信します。ポストプロセッサーが correlationId プロパティを追加する場合、そのプロパティは一意である必要があります。AsyncAmqpTemplate 内の convertSendAndReceive C - 期待される結果型。object - 変換するオブジェクト。messagePostProcessor - ポストプロセッサー。ListenableFuturepublic <C> AsyncRabbitTemplate.RabbitConverterFuture<C> convertSendAndReceive(StringSE routingKey, ObjectSE object, MessagePostProcessor messagePostProcessor)
AsyncAmqpTemplateMessagePostProcessor を呼び出した後、指定されたルーティングキーを使用してデフォルトの交換に送信します。ポストプロセッサーが correlationId プロパティを追加する場合、そのプロパティは一意である必要があります。AsyncAmqpTemplate 内の convertSendAndReceive C - 期待される結果型。routingKey - ルーティングキー。object - 変換するオブジェクト。messagePostProcessor - ポストプロセッサー。ListenableFuturepublic <C> AsyncRabbitTemplate.RabbitConverterFuture<C> convertSendAndReceive(StringSE exchange, StringSE routingKey, ObjectSE object, MessagePostProcessor messagePostProcessor)
AsyncAmqpTemplateMessagePostProcessor を呼び出した後、指定された交換およびルーティングキーに送信します。ポストプロセッサーが correlationId プロパティを追加する場合、そのプロパティは一意である必要があります。AsyncAmqpTemplate 内の convertSendAndReceive C - 期待される結果型。exchange - 交換 routingKey - ルーティングキー。object - 変換するオブジェクト。messagePostProcessor - ポストプロセッサー。ListenableFuturepublic <C> AsyncRabbitTemplate.RabbitConverterFuture<C> convertSendAndReceiveAsType(ObjectSE object, ParameterizedTypeReference<C> responseType)
AsyncAmqpTemplateAsyncAmqpTemplate 内の convertSendAndReceiveAsType C - 期待される結果型。object - 変換するオブジェクト。responseType - レスポンス型。ListenableFuturepublic <C> AsyncRabbitTemplate.RabbitConverterFuture<C> convertSendAndReceiveAsType(StringSE routingKey, ObjectSE object, ParameterizedTypeReference<C> responseType)
AsyncAmqpTemplateAsyncAmqpTemplate 内の convertSendAndReceiveAsType C - 期待される結果型。routingKey - ルーティングキー。object - 変換するオブジェクト。responseType - レスポンス型。ListenableFuturepublic <C> AsyncRabbitTemplate.RabbitConverterFuture<C> convertSendAndReceiveAsType(StringSE exchange, StringSE routingKey, ObjectSE object, ParameterizedTypeReference<C> responseType)
AsyncAmqpTemplateAsyncAmqpTemplate 内の convertSendAndReceiveAsType C - 期待される結果型。exchange - 交換。routingKey - ルーティングキー。object - 変換するオブジェクト。responseType - レスポンス型。ListenableFuturepublic <C> AsyncRabbitTemplate.RabbitConverterFuture<C> convertSendAndReceiveAsType(ObjectSE object, MessagePostProcessor messagePostProcessor, ParameterizedTypeReference<C> responseType)
AsyncAmqpTemplateMessagePostProcessor を呼び出した後、デフォルトのルーティングキーを使用してデフォルトの交換に送信します。ポストプロセッサーが correlationId プロパティを追加する場合、そのプロパティは一意である必要があります。AsyncAmqpTemplate 内の convertSendAndReceiveAsType C - 期待される結果型。object - 変換するオブジェクト。messagePostProcessor - ポストプロセッサー。responseType - レスポンス型。ListenableFuturepublic <C> AsyncRabbitTemplate.RabbitConverterFuture<C> convertSendAndReceiveAsType(StringSE routingKey, ObjectSE object, MessagePostProcessor messagePostProcessor, ParameterizedTypeReference<C> responseType)
AsyncAmqpTemplateMessagePostProcessor を呼び出した後、指定されたルーティングキーを使用してデフォルトの交換に送信します。ポストプロセッサーが correlationId プロパティを追加する場合、そのプロパティは一意である必要があります。AsyncAmqpTemplate 内の convertSendAndReceiveAsType C - 期待される結果型。routingKey - ルーティングキー。object - 変換するオブジェクト。messagePostProcessor - ポストプロセッサー。responseType - レスポンス型。ListenableFuturepublic <C> AsyncRabbitTemplate.RabbitConverterFuture<C> convertSendAndReceiveAsType(StringSE exchange, StringSE routingKey, ObjectSE object, MessagePostProcessor messagePostProcessor, ParameterizedTypeReference<C> responseType)
AsyncAmqpTemplateMessagePostProcessor を呼び出した後、指定された交換およびルーティングキーに送信します。ポストプロセッサーが correlationId プロパティを追加する場合、そのプロパティは一意である必要があります。AsyncAmqpTemplate 内の convertSendAndReceiveAsType C - 期待される結果型。exchange - 交換 routingKey - ルーティングキー。object - 変換するオブジェクト。messagePostProcessor - ポストプロセッサー。responseType - レスポンス型。ListenableFuturepublic int getPhase()
Phased 内の getPhase SmartLifecycle 内の getPhase public boolean isAutoStartup()
SmartLifecycle 内の isAutoStartup public void onMessage(Message message, com.rabbitmq.client.Channel channel)
ChannelAwareMessageListener実装者は、指定されたメッセージを処理し、通常、指定されたセッションを介して応答メッセージを送信します。
ChannelAwareMessageListener 内の onMessage message - 受信した AMQP メッセージ (非 null)channel - 基盤となる Rabbit チャネル (非 null)public void returnedMessage(ReturnedMessage returned)
RabbitTemplate.ReturnsCallbackRabbitTemplate.ReturnCallback 内の returnedMessage RabbitTemplate.ReturnsCallback 内の returnedMessage returned - 返されたメッセージとメタデータ。public void confirm(@NonNull CorrelationData correlationData, boolean ack, @Nullable StringSE cause)
RabbitTemplate.ConfirmCallbackRabbitTemplate.ConfirmCallback 内の confirm correlationData - コールバックの相関データ。ack - ack の場合は true、nack の場合は falsecause - オプションの原因。nack の場合は利用可能な場合、それ以外の場合は null。public StringSE toString()
ObjectSE の toStringSE