Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not enough arguments in call to msg.Accept while initializing receiver #186

Closed
johnklee opened this issue Aug 25, 2020 · 3 comments · Fixed by #197
Closed

Not enough arguments in call to msg.Accept while initializing receiver #186

johnklee opened this issue Aug 25, 2020 · 3 comments · Fixed by #197

Comments

@johnklee
Copy link

johnklee commented Aug 25, 2020

Expected Behavior

With the sample code below (the connection string is given correctly):

package main

import (
    "context"
    "fmt"
    "os"
    "os/signal"
    "time"

    "github.com/Azure/azure-event-hubs-go"
)

func main(){
    connStr := "..."

    hub, err := eventhub.NewHubFromConnectionString(connStr)

    if err != nil {
        fmt.Println(err)
        return
    }

    ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
    defer cancel()

    handler := func(c context.Context, event *eventhub.Event) error {
        fmt.Println(string(event.Data))
        return nil
    }

    // listen to each partition of the Event Hub
    runtimeInfo, err := hub.GetRuntimeInformation(ctx)
    if err != nil {
        fmt.Println(err)
        return
    }
    
    for _, partitionID := range runtimeInfo.PartitionIDs {
        // Start receiving messages
        //
        // Receive blocks while attempting to connect to hub, then runs until listenerHandle.Close() is called
        // <- listenerHandle.Done() signals listener has stopped
        // listenerHandle.Err() provides the last error the receiver encountered
        fmt.Println("Start receiving...")
        _, err := hub.Receive(ctx, partitionID, handler, eventhub.ReceiveWithLatestOffset())
        if err != nil {
            fmt.Println(err)
            return
        }
    }

    // Wait for a signal to quit:
    signalChan := make(chan os.Signal, 1)
    signal.Notify(signalChan, os.Interrupt, os.Kill)
    <-signalChan

    err = hub.Close(context.Background())
    if err != nil {
        fmt.Println(err)
    }
}

The execution will have below error:

# go run main.go
# github.com/Azure/azure-event-hubs-go
../github.com/Azure/azure-event-hubs-go/receiver.go:269:18: not enough arguments in call to msg.Accept
        have ()
        want (context.Context)

Actual Behavior

The code should work properly to start receiving the message from eventhb.
I manually modify ../github.com/Azure/azure-event-hubs-go/receiver.go from local and it will work.

Environment

  • OS: CentOS8
  • Go version: go version go1.13.4 linux/amd64
  • Version of Library: latest
@cosmin-margarit
Copy link

Hello,
I'm having the same issue with v3. I've created a new clean project and installed only the eventhub dependencies through
go get -u github.com/Azure/azure-event-hubs-go/v3. At the moment of importing something from the library, the build fails.

Here is the main.go code:

package main

import (
	"fmt"
	eventhub "github.com/Azure/azure-event-hubs-go/v3"
)

func main() {
	hub := eventhub.Hub{}
	fmt.Println("Hello world!", hub)
}

And here is the error:

# github.com/Azure/azure-event-hubs-go/v3
../../../../../../go/pkg/mod/github.com/!azure/azure-event-hubs-go/[email protected]/receiver.go:262:19: not enough arguments in call to msg.Modify
	have (bool, bool, nil)
	want (context.Context, bool, bool, amqp.Annotations)
../../../../../../go/pkg/mod/github.com/!azure/azure-event-hubs-go/[email protected]/receiver.go:269:18: not enough arguments in call to msg.Accept
	have ()
	want (context.Context)

Compilation finished with exit code 2

I've tried with versions: 3.3.0, 3.2.0, 3.1.2, 3.1.1, 3.0.0, and all of them failed with the same error.

OS: macOS Catalina 10.15.5
GO version: 1.14

@princjef
Copy link
Member

princjef commented Sep 2, 2020

I saw the same. The issue appears to be coming from v0.13 of go-amqp. Try this and see if it fixes your problem:

go get github.com/Azure/[email protected]

@cosmin-margarit
Copy link

I saw the same. The issue appears to be coming from v0.13 of go-amqp. Try this and see if it fixes your problem:

go get github.com/Azure/[email protected]

Indeed, the 0.12.8 version of azure/go-amqp fixes the build process, not sure if it has other consequences though.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants