1

I recently started exploring redisson for one of the use-case, where the map should hold string & queue of pojo objects. I tried to add the objects to queue for a particular key but when I'm retrieving it's values, it is giving empty results.

    @Autowired
    private RedissonClient redissonClient;

    private RMapCache<String, Queue<AbstractXXXEvent>> mapCache;

    @PostConstruct()
    public void init() {
        this.mapCache = redissonClient.getMapCache("test8", JsonJacksonCodec.INSTANCE);
    }


    @PreDestroy
    public void cleanup() {
        if (Objects.nonNull(redissonClient)) {
            redissonClient.shutdown();
        }
    }

    @RestController
    class TestController {
        @GetMapping("/get")
        public Set<Map.Entry<String, Queue<AbstractXXXEvent>>> get() {
            return mapCache.entrySet();
        }

        @PostMapping("/post")
        public void post() {
            mapCache.put("test", new ConcurrentLinkedQueue<>());

            Queue<AbstractXXXEvent> queue = mapCache.get("test");
            queue.add(new aXXXEvent().setDescription("compile done"));
            queue.add(new bXXXEvent());
            queue.add(new cXXXEvent().setDescription("completed"));
        }
    }

When I do a get request, it is giving the empty result with given key ex: [{"test":[]}]. Kindly provide your suggestions on how to fix this.

Rajeev
  • 183
  • 2
  • 10

1 Answers1

0

You need to put Redisson's RQueue instead of ConcurrentLinkedQueue

Nikita Koksharov
  • 10,283
  • 1
  • 62
  • 71