Skip to content

feat: Direct consumption of protobuf messages in consumer - #1131

Merged
johanandren merged 1 commit into
mainfrom
wip-support-proto-message-consumers
Nov 11, 2025
Merged

johanandren merged 1 commit into
mainfrom
wip-support-proto-message-consumers

Conversation

@johanandren

Copy link
Copy Markdown
Contributor

Feature to ease integration between existing Kalix services and Akka services, this allows Akka consumers to accept message types generated by protobuf Java, emitted by a Kalix service.

@patriknw patriknw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good

def decodeJavaProtobuf[T](payload: BytesPayload, cls: Class[T]): T = {
if (payload.contentType.startsWith(AnySupport.DefaultTypeUrlPrefix)) {
val parser =
parserCache.computeIfAbsent(cls, cls => cls.getMethod("parser").invoke(null).asInstanceOf[Parser[AnyRef]])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this compare to Akka core's ProtobufSerializer that is looking for method "parseFrom" ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parser is a static final field PARSER, so this is just picking that up for repeated use, while parseFrom uses that field directly doing PARSER.parseFrom(data). No big difference either way.

@patriknw patriknw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@johanandren
johanandren merged commit e7ecce3 into main Nov 11, 2025
1 check passed
@johanandren
johanandren deleted the wip-support-proto-message-consumers branch November 11, 2025 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants