package com.sikey.wa04.business.application.service.websocket;

import io.nats.client.Connection;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @Author: qin
 * @Date: 2025/3/18
 * @Description: nats 发布者
 */
@Slf4j
@Service
public class NatsPublisherService {

    @Resource
    private Connection natsConnection;

    /**
     * 发布消息
     *
     * @param subject
     * @param message
     * @return
     */
    public void publishMessage(String subject, String message) {
        natsConnection.publish(subject, message.getBytes());
        log.info("Published message: {}", message);
    }
}
