Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

ISSUE-5840: Subscription mode Key_Shared not working as expected #28

Closed
sijie opened this issue Dec 27, 2019 · 0 comments
Closed

ISSUE-5840: Subscription mode Key_Shared not working as expected #28

sijie opened this issue Dec 27, 2019 · 0 comments

Comments

@sijie
Copy link
Member

sijie commented Dec 27, 2019

Original Issue: apache#5840


Expected behavior

When running two instances of my app, i expect that pulsar should loadbalance between the two instances. Also, messages with the same key should always go to the same instance.

Actual behavior

However, all messages are handled by instance 1. Instance 2 only receive messages when instance 1 is down.

Steps to reproduce

Create a SpringBoot app with a single Pulsar Consumer Bean:

@Slf4j
@Component
public class CustomerCommandHandler {

  @Autowired
  private PulsarClient pulsarClient;

  @Bean
  public Consumer<Customer> consumer() throws PulsarClientException {
    return pulsarClient.newConsumer(Schema.JSON(Customer.class))
        .topic("eu-west/app1/customers-topic")
        .subscriptionType(SubscriptionType.Key_Shared)
        .subscriptionName("my-subscription")
        .messageListener((MessageListener<Customer>) (consumer, message) -> {
          try {
            log.info("Message received: {}", message.getValue());
            consumer.acknowledge(message);
          } catch (Exception e) {
            consumer.negativeAcknowledge(message);
            e.printStackTrace();
          }
        })
        .subscribe();
  }
}`

Run two instances of this app and puplish messages to the customers-topic.

System configuration

Pulsar version: 2.4.1 and 2.4.2

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

No branches or pull requests

1 participant