Class TopicController

java.lang.Object
com.loomcache.springboot.controller.TopicController

@RestController @Conditional(LoomServerEnabledCondition.class) @ConditionalOnBean(LoomCache.class) @RequestMapping("/api/topic") public class TopicController extends Object
REST controller for DistributedTopic operations.

Endpoints: POST /api/topic — publish a message to all subscribers GET /api/topic/stats — get topic statistics

  • Constructor Details

    • TopicController

      public TopicController(DistributedTopic<String> defaultTopic, CacheNode cacheNode, LoomCache loomCache)
      Create a TopicController with a DistributedTopic.
      Parameters:
      defaultTopic - the distributed topic to use (must not be null)
      Throws:
      NullPointerException - if defaultTopic is null
  • Method Details

    • publish

      @RolesAllowed({"ADMIN","USER"}) @PostMapping public org.springframework.http.ResponseEntity<Map<String,Object>> publish(@RequestBody @Nullable String message)
      Publish a message to all subscribers of the topic.
      Parameters:
      message - the message to publish (plain string in request body, must not be null)
      Returns:
      response with published flag, subscriber count, and total published count
    • stats

      @RolesAllowed({"ADMIN","USER","READONLY"}) @GetMapping("/stats") public org.springframework.http.ResponseEntity<Map<String,Object>> stats()
      Get statistics about the topic.
      Returns:
      response with subscriber count, total published, and total delivered messages