Pulsar: Acktimeout cannot be set in Go Client

Created on 28 Jan 2019  路  3Comments  路  Source: apache/pulsar

Describe the bug
When I create a consumer and specify acktimeout, I can't start it.
To Reproduce

package main

import (
    "context"
    "log"
    "time"
    "fmt"
    "github.com/apache/pulsar/pulsar-client-go/pulsar"
)

func main() {
    // Instantiate a Pulsar client
    client, err := pulsar.NewClient(pulsar.ClientOptions{
        URL:  "pulsar://pulsar.int.mechatim.com:6650",
    })

    if err != nil {
        log.Fatal(err)
    }

    // Use the client object to instantiate a consumer
    consumer, err := client.Subscribe(pulsar.ConsumerOptions{
        Topics: []string{
            "my-topic",
        },
        SubscriptionName: "sub-1",
        Type:             pulsar.Exclusive,
        AckTimeout:       time.Second,
    })

    if err != nil {
        log.Fatal(err)
    }

    defer consumer.Close()

    ctx := context.Background()

    // Listen indefinitely on the topic
    for {
        msg, err := consumer.Receive(ctx)
        if err != nil {
            log.Fatal(err)
        }

        // Do something with the message
        fmt.Printf("[INFO] Message value: %s\n", string(msg.Payload()))

        consumer.Ack(msg)
    }
}

Expected behavior
create a consumer
Screenshots

terminate called after throwing an instance of 'char const*'
SIGABRT: abort
PC=0x7fc8a030ae97 m=0 sigcode=18446744073709551610

goroutine 0 [idle]:
runtime: unknown pc 0x7fc8a030ae97
stack: frame={sp:0x7ffdf87252c0, fp:0x0} stack=[0x7ffdf7f265d8,0x7ffdf8725600)
00007ffdf87251c0:  0000000000000000  0000000000000000 
00007ffdf87251d0:  0000000000000000  0000000000000000 
00007ffdf87251e0:  0000000000000000  0000000000000000 
00007ffdf87251f0:  000000ff00000000  0000ff0000000000 
00007ffdf8725200:  0000000000000000  0000000000000000 
00007ffdf8725210:  0000000000000000  00007fc89fbc9c80 
00007ffdf8725220:  4000000000000000  0000000000000000 
00007ffdf8725230:  0000000000000000  0000000000000000 
00007ffdf8725240:  0000000000000000  0000000000000000 
00007ffdf8725250:  00007ffdf87254e0  00007ffdf87254e8 
00007ffdf8725260:  000000c4200220f0  0000000000000049 
00007ffdf8725270:  000000c4200164e0  000000000000001f 
00007ffdf8725280:  000000c420016500  0000000000000013 
00007ffdf8725290:  000000c420016520  0000000000000013 
00007ffdf87252a0:  000000c420016540  0000000000000016 
00007ffdf87252b0:  0000000000000000  0000000000456d31 <runtime.goexit+1> 
00007ffdf87252c0: <0000000000000000  0000000000000000 
00007ffdf87252d0:  0000000000000000  0000000000000000 
00007ffdf87252e0:  000000c400000000  0000000000000049 
00007ffdf87252f0:  6e6f632072616863  00000000002a7473 
00007ffdf8725300:  000000c420016500  0000000000000013 
00007ffdf8725310:  000000c420016520  0000000000000013 
00007ffdf8725320:  000000c420016540  0000000000000016 
00007ffdf8725330:  0000000000000000  0000000000456d31 <runtime.goexit+1> 
00007ffdf8725340:  fffffffe7fffffff  ffffffffffffffff 
......

Desktop:

  • OS: Ubuntu 18.04.1 LTS
  • version: 2.2.1
typquestion

Most helpful comment

@tfhappy hello, I run the code you provided, and have the same problem, but when I set the timeout time to 10s or more, this code works fine.

the specific reasons are as follows:

/**
 * Set the timeout in milliseconds for unacknowledged messages, the timeout needs to be greater than
 * 10 seconds. An Exception is thrown if the given value is less than 10000 (10 seconds).
 * If a successful acknowledgement is not sent within the timeout all the unacknowledged messages are
 * redelivered.
 * @param timeout in milliseconds
 */
void pulsar_consumer_set_unacked_messages_timeout_ms(pulsar_consumer_configuration_t *consumer_configuration,
                                                     const uint64_t milliSeconds);

expect to be useful to you.

All 3 comments

@tfhappy hello, I run the code you provided, and have the same problem, but when I set the timeout time to 10s or more, this code works fine.

the specific reasons are as follows:

/**
 * Set the timeout in milliseconds for unacknowledged messages, the timeout needs to be greater than
 * 10 seconds. An Exception is thrown if the given value is less than 10000 (10 seconds).
 * If a successful acknowledgement is not sent within the timeout all the unacknowledged messages are
 * redelivered.
 * @param timeout in milliseconds
 */
void pulsar_consumer_set_unacked_messages_timeout_ms(pulsar_consumer_configuration_t *consumer_configuration,
                                                     const uint64_t milliSeconds);

expect to be useful to you.

@tfhappy hello, I run the code you provided, and have the same problem, but when I set the timeout time to 10s or more, this code works fine.

the specific reasons are as follows:

/**
 * Set the timeout in milliseconds for unacknowledged messages, the timeout needs to be greater than
 * 10 seconds. An Exception is thrown if the given value is less than 10000 (10 seconds).
 * If a successful acknowledgement is not sent within the timeout all the unacknowledged messages are
 * redelivered.
 * @param timeout in milliseconds
 */
void pulsar_consumer_set_unacked_messages_timeout_ms(pulsar_consumer_configuration_t *consumer_configuration,
                                                     const uint64_t milliSeconds);

expect to be useful to you.

thanks

This looks more like a question. Thanks @wolfstudy for the help. would like to close this.
If there is anything that need follow up, Please feel free to reopen it.

Was this page helpful?
0 / 5 - 0 ratings