package com.njcn.device.pq.controller.file;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;

@Component
public class RedisMessageSubscriber implements MessageListener {
    @Autowired
    private PendingRequestManager pendingRequestManager;

    @Override
    public void onMessage(Message message, byte[] pattern) {
        String msgId = new String(message.getBody(), StandardCharsets.UTF_8);
        pendingRequestManager.completeRequest(msgId);
    }
}
