Class DefaultGroupEventBus

java.lang.Object
com.tnsai.coordination.groups.DefaultGroupEventBus
All Implemented Interfaces:
com.tnsai.agents.groups.GroupEventBus

public class DefaultGroupEventBus extends Object implements com.tnsai.agents.groups.GroupEventBus
Default implementation of GroupEventBus.

Provides thread-safe publish-subscribe messaging with:

  • Async event dispatch
  • Filtered subscriptions
  • Event history
  • Constructor Details

    • DefaultGroupEventBus

      public DefaultGroupEventBus(String groupId)
    • DefaultGroupEventBus

      public DefaultGroupEventBus(String groupId, int maxHistorySize)
  • Method Details

    • getGroupId

      public String getGroupId()
      Specified by:
      getGroupId in interface com.tnsai.agents.groups.GroupEventBus
    • publish

      public void publish(com.tnsai.agents.groups.GroupEvent event)
      Specified by:
      publish in interface com.tnsai.agents.groups.GroupEventBus
    • publishAsync

      public CompletableFuture<Void> publishAsync(com.tnsai.agents.groups.GroupEvent event)
      Specified by:
      publishAsync in interface com.tnsai.agents.groups.GroupEventBus
    • subscribe

      public String subscribe(Consumer<com.tnsai.agents.groups.GroupEvent> handler)
      Specified by:
      subscribe in interface com.tnsai.agents.groups.GroupEventBus
    • subscribe

      public String subscribe(com.tnsai.agents.groups.GroupEvent.Type type, Consumer<com.tnsai.agents.groups.GroupEvent> handler)
      Specified by:
      subscribe in interface com.tnsai.agents.groups.GroupEventBus
    • subscribe

      public String subscribe(Predicate<com.tnsai.agents.groups.GroupEvent> filter, Consumer<com.tnsai.agents.groups.GroupEvent> handler)
      Specified by:
      subscribe in interface com.tnsai.agents.groups.GroupEventBus
    • subscribeFor

      public String subscribeFor(String agentId, Consumer<com.tnsai.agents.groups.GroupEvent> handler)
      Specified by:
      subscribeFor in interface com.tnsai.agents.groups.GroupEventBus
    • subscribeFrom

      public String subscribeFrom(String agentId, Consumer<com.tnsai.agents.groups.GroupEvent> handler)
      Specified by:
      subscribeFrom in interface com.tnsai.agents.groups.GroupEventBus
    • unsubscribe

      public boolean unsubscribe(String subscriptionId)
      Specified by:
      unsubscribe in interface com.tnsai.agents.groups.GroupEventBus
    • unsubscribeAll

      public int unsubscribeAll(String agentId)
      Specified by:
      unsubscribeAll in interface com.tnsai.agents.groups.GroupEventBus
    • getRecentEvents

      public List<com.tnsai.agents.groups.GroupEvent> getRecentEvents(int limit)
      Specified by:
      getRecentEvents in interface com.tnsai.agents.groups.GroupEventBus
    • getRecentEvents

      public List<com.tnsai.agents.groups.GroupEvent> getRecentEvents(com.tnsai.agents.groups.GroupEvent.Type type, int limit)
      Specified by:
      getRecentEvents in interface com.tnsai.agents.groups.GroupEventBus
    • getSubscriptionCount

      public int getSubscriptionCount()
      Specified by:
      getSubscriptionCount in interface com.tnsai.agents.groups.GroupEventBus
    • start

      public void start()
      Specified by:
      start in interface com.tnsai.agents.groups.GroupEventBus
    • stop

      public void stop()
      Specified by:
      stop in interface com.tnsai.agents.groups.GroupEventBus
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface com.tnsai.agents.groups.GroupEventBus
    • clear

      public void clear()
      Specified by:
      clear in interface com.tnsai.agents.groups.GroupEventBus