labuladong commented on PR #17449:
URL: https://github.com/apache/pulsar/pull/17449#issuecomment-1362824456

   Hi @Denovo1998! I'm glad that you have this idea too, so I'll close my pr.
   
   For your discussion above, my solution is to only count the consumer which 
specifies a schema:
   
   ```java
   int numActiveConsumersWithSchema = subscriptions.values().stream()
     .mapToInt(subscription -> (int) subscription.getConsumers().stream()
           // filter out the consumers have specific schema
           .filter((c) -> c.getSchemaType() != null && 
c.getSchemaType().getValue() > 0).count())
     .sum();
   ```
   
   If so, the original schema won’t be changed, and this code can ignore the 
consumers with null, AUTO_CONSUME, NONE or BYTES schema, because these schemas 
are all non-positive enums:
   
   
https://github.com/apache/pulsar/blob/90f67587e31cc0cfb27773f85f18d607c9c5c324/pulsar-client-api/src/main/java/org/apache/pulsar/common/schema/SchemaType.java#L140-L175
   


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