All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.houkunlin.system.applog.AppLogHandlerAmqpImpl Maven / Gradle / Ivy

Go to download

使用 AppLog 注解记录日志信息,或者使用 AppLoggerFactory.getLogger(name) 这种类似 Slf4J 的形式记录日志信息。 需要自行监听 AppLogEvent 事件去保存日志信息。

There is a newer version: 1.2.3
Show newest version
package com.houkunlin.system.applog;

import lombok.RequiredArgsConstructor;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.scheduling.annotation.Async;

/**
 * 把应用日志信息推送到 RabbitMQ 消息队列
 *
 * @author HouKunLin
 */
@RequiredArgsConstructor
public class AppLogHandlerAmqpImpl implements AppLogHandler {
    private final AppLogProperties appLogProperties;
    private final AmqpTemplate amqpTemplate;

    @Async
    @Override
    public void handle(AppLogInfo entity) {
        amqpTemplate.convertAndSend(appLogProperties.getMqExchange(),
                appLogProperties.getMqRoutingKey(),
                entity);
    }

    @Override
    public void handle(AppLogInfo entity, Object oldObject, Object newObject) {
        amqpTemplate.convertAndSend(appLogProperties.getMqExchange(),
                appLogProperties.getMqRoutingKey(),
                entity);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy