ragaur-tibco commented on issue #22529:
URL: https://github.com/apache/pulsar/issues/22529#issuecomment-2067874464
Hi @visortelle
I tried creating subscriber before sending the messages
````
package Pulsar;
import org.apache.pulsar.client.admin.PulsarAdmin;
import org.apache.pulsar.client.admin.PulsarAdminException;
import org.apache.pulsar.client.api.*;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern;
public class AllTopicsConsumerExample {
private static PulsarAdmin adm;
private static final String SERVICE_URL = "pulsar://localhost:6650";
private static final String NAMESPACE = "my-tenant/new-name";
private static final String SUBSCRIPTION_NAME = "your-subscription-1";
public static void main(String[] args) throws PulsarClientException {
PulsarClient pulsarClient = PulsarClient.builder()
.serviceUrl(SERVICE_URL)
.build();
// Pattern allTopicsPattern =
Pattern.compile("tenant-1/name/topic.*");
Consumer<byte[]> allTopicsConsumer = pulsarClient.newConsumer()
.topicsPattern("tenant-1/name/topic.*").subscriptionType(SubscriptionType.Shared)
.subscriptionName(SUBSCRIPTION_NAME).subscriptionTopicsMode(RegexSubscriptionMode.AllTopics)
.subscribe();
Producer<String> producer = pulsarClient.newProducer(Schema.STRING)
.topic("non-persistent://tenant-1/name/topic-1")
.enableBatching(false).create();
System.out.println("new producer");
producer.send("=========from topic
non-persistent://tenant-1/name/topic-1 ");
Producer<String> producer1 = pulsarClient.newProducer(Schema.STRING)
.topic("persistent://tenant-1/name/topic-8")
.enableBatching(false).create();
producer1.send("=======from topic
persistent://tenant-1/name/topic-8 ");
while (true) {
Message<byte[]> message = allTopicsConsumer.receive();
System.out.println("Received message from topic " +
message.getTopicName()
+ ": " + new String(message.getValue()));
allTopicsConsumer.acknowledge(message);
}
}
}
```
`
response: only getting the response from persistent topic but not from
non-persistent

--
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]