vvijayv opened a new issue #12255:
URL: https://github.com/apache/pulsar/issues/12255
**Describe the bug**
The spring-boot application starts with a consumer, but closes the
connection to the Pulsar broker.
```shell
[event-broadcast-6dc97cf489-7s4l7] 2021-09-30 15:52:32.702 INFO 1 ---
[r-client-io-1-5] o.a.pulsar.client.impl.ConsumerImpl :
[persistent://public/default/schedules] [schedule-handler] Closed consumer
```
The Pulsar is deployed in the Kubernetes with
`examples/values-one-node.yaml` configuration.
Code
```java
@Bean
public PulsarClient pulsarClient(PulsarProperties pulsarProperties)
throws PulsarClientException, MalformedURLException {
ClientBuilder builder =
PulsarClient.builder().serviceUrl("pulsar://pulsar-proxy:6650").build();
}
@Bean
@Primary
public Consumer<Schedule> schedulerPulsarConsumer(PulsarClient
pulsarClient, PulsarProperties pulsarProperties,
ScheduledEventHandler consumer) throws
PulsarClientException {
return
pulsarClient.newConsumer(Schema.JSON(Schedule.class)).ackTimeout(1000,
TimeUnit.MILLISECONDS)
.consumerName("broadcaster").topic(pulsarProperties.getSchedulesTopic())
.subscriptionName("schedule-handler").subscriptionType(SubscriptionType.Shared)
.autoUpdatePartitions(true)
.subscriptionInitialPosition(SubscriptionInitialPosition.Earliest)
.messageListener(consumer).subscribe();
}
@Bean("reschedulerPulsarConsumer")
@Qualifier("reschedulerPulsarConsumer")
public Consumer<Schedule> reschedulerPulsarConsumer(PulsarClient
pulsarClient,
PulsarProperties pulsarProperties,
UnscheduleEventHandler consumer)
throws PulsarClientException {
return
pulsarClient.newConsumer(Schema.JSON(Schedule.class)).ackTimeout(1000,
TimeUnit.MILLISECONDS)
.consumerName("unscheduler").topic(pulsarProperties.getReschedulesTopic())
.subscriptionName("unschedule-handler").subscriptionType(SubscriptionType.Shared)
.autoUpdatePartitions(true)
.subscriptionInitialPosition(SubscriptionInitialPosition.Earliest)
.messageListener(consumer).subscribe();
}
```
This problem come only when the application runs within the same kubernetes
cluster (same namespace). When the same application is run outside the
kubernetes, and connected to the Pulsar (inside the Kubernetes) using ports
exposed with `port-forward` (6650 & 8080) the problem does not occur.
**To Reproduce**
Steps to reproduce the behavior:
1. Create a Pulsar cluster inside a Kubernetes cluster (`Kind` for example),
with `examples/values-one-node.yaml`
2. Create a topic with zero partition
3. Write a consumer that consumes from this topic
3. Deploy the application to the same Kubernetes cluster (same namespace)
4. The consumer closes the connection with the Pulsar server
**Expected behavior**
The consumer should start consuming messages from the topic
**Screenshots**
<img width="1655" alt="image"
src="https://user-images.githubusercontent.com/72122946/135491273-29a93965-4263-463d-9242-d7e7c7eb2db0.png">
**Desktop (please complete the following information):**
- OS: Mac for development
- Kubernetes nodes run in Amazon linux
**Additional context**
How does the consumers behave in case of the zero partition topic against
topics with partition
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]