Skip to content

[Bug] Go Pulsar functions recieves message from only one topic even when provided multiple input topics #19981

Closed

Description

@jdattatr-tibco

Search before asking

  • I searched in the issues and found nothing similar.

Version

OS: Ubuntu 20.04(LTS)
Pulsar: 2.10.1

Minimal reproduce step

Create a pulsar function in golang:

package main

import (
	"context"
	"fmt"

	"github.com/apache/pulsar/pulsar-function-go/pf"
)

func HandleResponse(ctx context.Context, in []byte) error {
	fmt.Printf("Processed: %s", string(in))
	return nil
}

func main() {
	pf.Start(HandleResponse)
}

Build and pass the file to pulsar-admin:

./pulsar-admin functions localrun \
     --go /pulsar/bin/pulsarFuncGolang \
     --inputs persistent://public/default/sourcetopic1,persistent://public/default/sourcetopic2 \
     --tenant public \
     --namespace default \
     --name flogoPulsarFunction

Publish message on both the topics, we could only see the function logs of recieved messages on the last topic mentioned (which is sourcetopic2 in the example above)

What did you expect to see?

Pulsar function should listen to all the topics mentioned

What did you see instead?

Pulsar function listens to only the last topic mentioned

Anything else?

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Activity

  1. added
    type/bug
    on Mar 31, 2023
  2. jiangpengcheng commented on Apr 3, 2023

    @jiangpengcheng
    Contributor

    As far as I know, the GO runtime hasn't yet supported multiple topics, below is the code:

            if (instanceConfig.getFunctionDetails().getSource().getInputSpecsMap() != null) {
                for (String inputTopic : instanceConfig.getFunctionDetails().getSource().getInputSpecsMap().keySet()) {
                    goInstanceConfig.setSourceSpecsTopic(inputTopic);
                }
            }

    We can see that when multiple topics are specified, the last one will overwrite the previous topics.

    https://github.com/apache/pulsar/blob/master/pulsar-functions/runtime/src/main/java/org/apache/pulsar/functions/runtime/RuntimeUtils.java#L206-L210

    It may take some time to support such a feature, but I will take a look

  3. github-actions commented on May 4, 2023

    @github-actions

    The issue had no activity for 30 days, mark with Stale label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Staletype/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions