Class PayloadUtils
java.lang.Object
org.springframework.messaging.rsocket.PayloadUtils
Static utility methods to create 
Payload from DataBuffers
 and vice versa.- Since:
- 5.2
- Author:
- Rossen Stoyanchev
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic io.rsocket.PayloadcreatePayload(DataBuffer data) Create a Payload with data only.static io.rsocket.PayloadcreatePayload(DataBuffer data, DataBuffer metadata) Create a Payload from the given metadata and data.static DataBufferretainDataAndReleasePayload(io.rsocket.Payload payload, DataBufferFactory bufferFactory) Use this method to slice, retain and wrap the data portion of thePayload, and also to release thePayload.
- 
Constructor Details- 
PayloadUtilspublic PayloadUtils()
 
- 
- 
Method Details- 
retainDataAndReleasePayloadpublic static DataBuffer retainDataAndReleasePayload(io.rsocket.Payload payload, DataBufferFactory bufferFactory) Use this method to slice, retain and wrap the data portion of thePayload, and also to release thePayload. This assumes the Payload metadata has been read by now and ensures downstream code need only be aware ofDataBuffers.- Parameters:
- payload- the payload to process
- bufferFactory- the DataBufferFactory to wrap with
- Returns:
- the created DataBufferinstance
 
- 
createPayloadCreate a Payload from the given metadata and data.If at least one is NettyDataBufferthenByteBufPayloadis created with either obtaining the underlying nativeByteBufor usingUnpooled.wrappedBuffer(ByteBuffer...)if necessary. Otherwise, if both areDefaultDataBuffer, thenDefaultPayloadis created.- Parameters:
- data- the data part for the payload
- metadata- the metadata part for the payload
- Returns:
- the created payload
 
- 
createPayloadCreate a Payload with data only. The created payload isByteBufPayloadif the input isNettyDataBufferor otherwise it isDefaultPayload.- Parameters:
- data- the data part for the payload
- Returns:
- created payload
 
 
-