pzx6b666 opened a new issue, #765:
URL: https://github.com/apache/rocketmq-clients/issues/765

   ### Programming Language of the Client
   
   Java
   
   ### Is Your Feature Request Related to a Problem?
   
   
   用下面这种方式监听消息,消息能监听到,但是rocketmq-Dashboard 上面不显示这个监听实例数量,订阅组后面的消息为0,但
   public class PushConsumerExample {
       private static final Logger log = 
LoggerFactory.getLogger(PushConsumerExample.class);
   
       private PushConsumerExample() {
       }
   
       public static void main(String[] args) throws ClientException, 
InterruptedException, IOException {
           final ClientServiceProvider provider = 
ClientServiceProvider.loadService();
   
           // Credential provider is optional for client configuration.
           String accessKey = "yourAccessKey";
           String secretKey = "yourSecretKey";
           SessionCredentialsProvider sessionCredentialsProvider =
               new StaticSessionCredentialsProvider(accessKey, secretKey);
   
           String endpoints = "foobar.com:8080";
           ClientConfiguration clientConfiguration = 
ClientConfiguration.newBuilder()
               .setEndpoints(endpoints)
               // On some Windows platforms, you may encounter SSL 
compatibility issues. Try turning off the SSL option in
               // client configuration to solve the problem please if SSL is 
not essential.
               // .enableSsl(false)
               .setCredentialProvider(sessionCredentialsProvider)
               .build();
           String tag = "yourMessageTagA";
           FilterExpression filterExpression = new FilterExpression(tag, 
FilterExpressionType.TAG);
           String consumerGroup = "yourConsumerGroup";
           String topic = "yourTopic";
           // In most case, you don't need to create too many consumers, 
singleton pattern is recommended.
           PushConsumer pushConsumer = provider.newPushConsumerBuilder()
               .setClientConfiguration(clientConfiguration)
               // Set the consumer group name.
               .setConsumerGroup(consumerGroup)
               // Set the subscription for the consumer.
               .setSubscriptionExpressions(Collections.singletonMap(topic, 
filterExpression))
               .setMessageListener(messageView -> {
                   // Handle the received message and return consume result.
                   log.info("Consume message={}", messageView);
                   return ConsumeResult.SUCCESS;
               })
               .build();
           // Block the main thread, no need for production environment.
           Thread.sleep(Long.MAX_VALUE);
           // Close the push consumer when you don't need it anymore.
           // You could close it manually or add this into the JVM shutdown 
hook.
           pushConsumer.close();
       }
   }
   
![733141aa6dc0049b587e2e039040021](https://github.com/apache/rocketmq-clients/assets/105713870/36f61c51-ca71-466c-9556-99ae00fccbac)
   
   
   ### Describe the Solution You'd Like
   
   1
   
   ### Describe Alternatives You've Considered
   
   1
   
   ### Additional Context
   
   1


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

Reply via email to