SolaceIO: support binary content (text, bytes) data payload - #39876
Merged
Conversation
ngibanel
marked this pull request as ready for review
August 24, 2026 15:04
Contributor
|
Assigning reviewers: R: @Abacn for label java. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
Contributor
|
R:@iht |
stankiewicz
requested changes
Aug 28, 2026
Contributor
Author
|
thanks @stankiewicz for the review. |
Contributor
|
Nicolas, |
stankiewicz
approved these changes
Aug 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extend Solace.Record with a per-record payload type to support JCSMP TextMessage and BytesMessage type for reading and writing data.
The default remains through BytesXMLMessage to preserve existing users' behavior and source compatibility.
Fixes #39875
Motivation
Solace messages support several distinct payload types (https://docs.solace.com/API/API-Developer-Guide/Adding-Data-Payloads.htm):
The previous SolaceIO implementation always wrote the payload using BytesXMLMessage.writeBytes(), which places data in the XML content part of the message. This is a legacy behavior: it works, but it is not the recommended way to carry arbitrary binary payloads, and it creates interoperability issues. When a Solace message is produced by other SDKs - JMS in particular - the payload is serialized into the binary attachment, not the XML content part. A consumer using SolaceIO would therefore receive an empty payload when reading messages written by a JMS producer, and vice versa.
This PR aligns SolaceIO with the recommended Solace practices by introducing explicit payload type selection, covering:
BYTES_XML(default)BytesXMLMessageTEXTTextMessageBYTESBytesMessageChanges
1. New
PayloadTypefield onSolace.RecordA
Record.PayloadTypeenum is introduced with three values:BYTES_XML(default) - legacy behavior, fully backward-compatible.TEXT- UTF-8 text payload.BYTES- raw binary payload (binary attachment).The payload is always stored as
byte[]insideRecord, regardless of type.For
TEXT, those bytes are the UTF-8 encoding of the string. This avoids adding a separateStringfield to the Beam schema and keeps a uniform data model. ThegetText()accessor decodes on demand with strict UTF-8 validation.2. Builder convenience method
setText(String)A shorthand on
Record.Builderthat encodes the string to UTF-8, stores the bytes inpayload,and sets
payloadTypetoTEXTin a single call.3.
SolaceRecordMapperrefactoringmap()renamed totoRecord()(more expressive, symmetric with the newtoMessage()).toMessage(Record): centralizes theRecord → BytesXMLMessageconversion previously scattered inMessageProducerUtils. It maps only the fields that are common to both theRecordmodel and a JCSMP message: the payload (dispatched byPayloadType),senderTimestamp(defaulting toSystem.currentTimeMillis()), andapplicationMessageId. Protocol-specific publishing fields - delivery mode, correlation key, etc. - are intentionally left out and remain the responsibility ofMessageProducerUtils.decodePayload(BytesXMLMessage): detects the actual JCSMP type viainstanceof(
TextMessage,BytesMessage, or fallback toBytesXMLMessage) and builds the appropriateRecord.Builder.encodePayload(Record): creates the correct JCSMP object based onPayloadType.4.
MessageProducerUtilssimplificationMessage construction logic is delegated to
SolaceRecordMapper.toMessage(). Only protocol-specific publishing fields are set.Backward compatibility
Record.builder()defaults toPayloadType.BYTES_XML; existing pipelines require no changes.SolaceRecordMapper.map()is renamed totoRecord(); callers using the defaultread()API areunaffected (the internal reference is updated).
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>instead.CHANGES.mdwith noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.