Customizing payload converter by activity or task queue

I’m looking into customizing the payload converter that is used for an activity. I see that I am able to define converters based on the message type in the payload metadata. But is there a way to annotate (or something) an @ActivityMethod (or its parameters/return types) so that I can set the payload metadata for that particular activity?

The use case is that a particular activity is being handled by a worker in a system which needs a Protobuf serialization, whereas our usual serialization is JSON. I need to somehow let the SDK know to use the registered Protobuf serializer for the activity inputs and outputs (or alternatively, the task queue) rather than the JSON serializer.

It wouldn’t be as clean as some kind of annotation, but perhaps I can use Payload directly in the activity parameters/return types rather than relying on the SDK to convert the types?

(Initially asked on Slack).

Solved through experimentation and SDK code analysis.

I see that the default converters include the ProtobufJsonPayloadConverter and the ProtobufPayloadConverter, which are in the converters list before my JSON converter.

Therefore, it is sufficient to simply use any generated protobuf object, and the payload conversion will use protobuf serialization rather than JSON serialization automatically, because these generated objects all implement the MessageOrBuilder interface.

Nice!