Golang Parallel For One Consumer?

Options
klauszi
klauszi Member Posts: 3

How can I increase the number of connections for a consumer using pubsubplus-go-client? We pass a callback to ReceiveAsync for a consumer via PersistentMessageReceiver, but only one message is processed at a time.

Answers

  • Aaron
    Aaron Member, Administrator, Moderator, Employee Posts: 537 admin
    Options

    I don't know Go, but this sounds like a threading issue. The API only has one thread to dispatch the messages to you. If I wanted to build a parallel-processing consumer in Java, I would receive the message via Async, and then place it onto an in-memory Queue/List for processing, and let the callback return right away. Then I'd have 3, 5, 10 threads that I've started trying to pull of that in-memory queue, processing the messages, and the ACKing the message once complete. I made a video about this. (just think of Persistent messages + ACKing instead of request/reply).

    Or, do it the microservice way and just have many instances of your app running?

This Month's Leaders