[Python] How do I handle json/protobuf messages in Temporal Python SDK?

Discussão em 'Python' iniciado por Stack, Março 9, 2025.

  1. Stack

    Stack Membro Participativo

    I tried to adapt the greeting example to include Protobuf

    message EchoRequest {
    string message = 1;
    }


    @workflow.defn
    class GreetingWorkflowProtobuf:
    @workflow.run
    async def run(self, request: template_pb2.EchoRequest) -> str:
    return await workflow.execute_activity(
    compose_greeting,
    ComposeGreetingInput("Hello", request.message),
    start_to_close_timeout=timedelta(seconds=10),
    # Always set a heartbeat timeout for long-running activities
    heartbeat_timeout=timedelta(seconds=2),
    )


    But when I send the message from Temporal UI I get the following error setting the type as json/protobuf

    { "message": "Archie" }


    The default converters seem to include support for it

    (<temporalio.converter.BinaryNullPayloadConverter object at 0x000001E2C833BE00>, <temporalio.converter.BinaryPlainPayloadConverter object at 0x000001E2C87C4050>, <temporalio.converter.JSONProtoPayloadConverter object at 0x000001E2C87C41A0>, <temporalio.converter.BinaryProtoPayloadConverter object at 0x000001E2C87C42F0>, <temporalio.converter.JSONPlainPayloadConverter object at 0x000001E2C87C4440>)

    [​IMG]

    Continue reading...

Compartilhe esta Página