1 comment

  • Official comment

    Within Publisher, you can programmatically limit the number of topics that a client can subscribe to in two ways, by:

    1. Inside subscription() method:
    if(client.getTopics().size() > #LIMIT) {

    This would get the number of topics that the client is currently subscribed to, if this is more than the limit that you set then close the connection.

    However this could have an impact on performance as every time the size() method is called it creates a list of Topics. Therefore this could be expensive if you have a high limit value.

    1. With Client.attach(Object object), you could attach a counter (like an AtomicInteger) and just increment in subscribe() method and decrement in unsubscribe() and when this counter has exceeded a limit, you disconnect the client.
    Comment actions Permalink

Please sign in to leave a comment.