Skip to content

Supporting Message output for Java Function #4330

Description

@jerrypeng

We have discussed and implemented Message as an input for a Java Function:
#4313

Perhaps its time to discuss supporting outputting Message as an option to that users can set any of the fields that is support in the Message interface for an outgoing message

We already have a message builder interface exposed via context, perhaps we can reuse it with some modification to just build a message for outputting instead of having to send it?

Maybe the API can be something like below:

public class TestFunction implements Function<String, Message<String>> {

    @Override
    public Message<String> process(String input, Context context) throws Exception {

        FunctionMessageBuilder<String> builder = context.newOutputMessage();

        Message message = builder.key("key").value("val").build();

        context.publish("topic", Schema.STRING, message); // either send the message

        return message; // or return from the function
    }
}

@srkukarni @sijie @merlimat @wolfstudy thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/featureThe PR added a new feature or issue requested a new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions