public class ProtobufDecoder extends ProtobufCodecSupport implements Decoder<com.google.protobuf.Message>
Message を読み取る Decoder。decode(Publisher, ResolvableType, MimeType, Map) を介してデシリアライズされた Flux は、各メッセージのサイズがメッセージ自体の前に指定された、区切られたProtobuf メッセージを使用することが想定されています。decodeToMono(Publisher, ResolvableType, MimeType, Map) を介してデシリアライズされた単一の値は、通常の Protobuf メッセージ形式 (メッセージの前にサイズが付加されない) を使用することが想定されています。
Protobuf メッセージのデフォルトインスタンスは空のバイト配列を生成するため、ネットワーク経由で送信される Mono.just(Msg.getDefaultInstance()) は空の Mono としてデシリアライズされます。
Message Java クラスを生成するには、protoc バイナリをインストールする必要があります。
このデコーダーは Protobuf 3 以降を必要とし、公式 "com.google.protobuf:protobuf-java" ライブラリで "application/x-protobuf" および "application/octet-stream" をサポートします。
ProtobufEncoder| 修飾子と型 | フィールドと説明 |
|---|---|
protected static int | DEFAULT_MESSAGE_MAX_SIZE メッセージを集約するためのデフォルトの最大サイズ。 |
| コンストラクターと説明 |
|---|
ProtobufDecoder() 新しい ProtobufDecoder を作成します。 |
ProtobufDecoder(com.google.protobuf.ExtensionRegistry extensionRegistry) メッセージ拡張の登録を許可する初期化子を使用して、新しい ProtobufDecoder を作成します。 |
| 修飾子と型 | メソッドと説明 |
|---|---|
boolean | canDecode(ResolvableType elementType, MimeType mimeType) デコーダーが特定のターゲット要素型とソースストリームの MIME 型をサポートするかどうか。 |
com.google.protobuf.Message | decode(DataBuffer dataBuffer, ResolvableType targetType, MimeType mimeType, MapSE<StringSE, ObjectSE> hints) データバッファを型 T のオブジェクトにデコードします。 |
reactor.core.publisher.Flux<com.google.protobuf.Message> | decode(org.reactivestreams.Publisher<DataBuffer> inputStream, ResolvableType elementType, MimeType mimeType, MapSE<StringSE, ObjectSE> hints)DataBuffer 入力ストリームを T の Flux にデコードします。 |
reactor.core.publisher.Mono<com.google.protobuf.Message> | decodeToMono(org.reactivestreams.Publisher<DataBuffer> inputStream, ResolvableType elementType, MimeType mimeType, MapSE<StringSE, ObjectSE> hints)DataBuffer 入力ストリームを T の Mono にデコードします。 |
ListSE<MimeType> | getDecodableMimeTypes() このデコーダーがサポートする MIME 型のリストを返します。 |
int | getMaxMessageSize()configured メッセージのサイズ制限を返します。 |
void | setMaxMessageSize(int maxMessageSize) メッセージごとに許可される最大サイズ。 |
getMimeTypes, supportsMimeTypecloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSEprotected static final int DEFAULT_MESSAGE_MAX_SIZE
public ProtobufDecoder()
ProtobufDecoder を作成します。public ProtobufDecoder(com.google.protobuf.ExtensionRegistry extensionRegistry)
ProtobufDecoder を作成します。extensionRegistry - メッセージ拡張レジストリ public void setMaxMessageSize(int maxMessageSize)
デフォルトでは、これは 256K に設定されています。
maxMessageSize - メッセージごとの最大サイズ、または無制限の場合は -1public int getMaxMessageSize()
configured メッセージのサイズ制限を返します。public boolean canDecode(ResolvableType elementType, @Nullable MimeType mimeType)
Decoderpublic reactor.core.publisher.Flux<com.google.protobuf.Message> decode(org.reactivestreams.Publisher<DataBuffer> inputStream, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable MapSE<StringSE,ObjectSE> hints)
DecoderDataBuffer 入力ストリームを T の Flux にデコードします。Decoder<com.google.protobuf.Message> の decode inputStream - デコードする DataBuffer 入力ストリーム elementType - 出力ストリーム内の要素の予想される型。この型は、事前に Decoder.canDecode(org.springframework.core.ResolvableType, org.springframework.util.MimeType) メソッドに渡されている必要があり、true を返している必要があります。mimeType - 入力ストリームに関連付けられた MIME 型 (オプション)hints - エンコード方法に関する追加情報 public reactor.core.publisher.Mono<com.google.protobuf.Message> decodeToMono(org.reactivestreams.Publisher<DataBuffer> inputStream, ResolvableType elementType, @Nullable MimeType mimeType, @Nullable MapSE<StringSE,ObjectSE> hints)
DecoderDataBuffer 入力ストリームを T の Mono にデコードします。Decoder<com.google.protobuf.Message> の decodeToMono inputStream - デコードする DataBuffer 入力ストリーム elementType - 出力ストリーム内の要素の予想される型。この型は、事前に Decoder.canDecode(org.springframework.core.ResolvableType, org.springframework.util.MimeType) メソッドに渡されている必要があり、true を返している必要があります。mimeType - 入力ストリームに関連付けられた MIME 型 (オプション)hints - エンコード方法に関する追加情報 public com.google.protobuf.Message decode(DataBuffer dataBuffer, ResolvableType targetType, @Nullable MimeType mimeType, @Nullable MapSE<StringSE,ObjectSE> hints) throws DecodingException
DecoderDecoder<com.google.protobuf.Message> の decode dataBuffer - デコードする DataBuffer targetType - 予想される出力型 mimeType - データに関連付けられた MIME 型 hints - エンコード方法に関する追加情報 nullDecodingExceptionpublic ListSE<MimeType> getDecodableMimeTypes()
DecoderDecoder<com.google.protobuf.Message> の getDecodableMimeTypes