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

com.gracerun.summermq.producer.SummerMQTemplate Maven / Gradle / Ivy

There is a newer version: 1.0.6
Show newest version
package com.gracerun.summermq.producer;

import com.gracerun.summermq.annotation.PushMessage;
import com.gracerun.summermq.bean.MessageBody;
import com.gracerun.summermq.service.MessagePersistentService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Objects;

public class SummerMQTemplate {

    @Autowired(required = false)
    public MessagePersistentService messagePersistentService;

    @Autowired
    public RedisMessageProducer redisMessageProducer;

    @PushMessage
    public void sendAndSave(MessageBody messageBody) {
        if (Objects.nonNull(messagePersistentService)) {
            messageBody.setPersistent(true);
            messagePersistentService.save(messageBody);
        }
    }

    @PushMessage
    public void send(MessageBody messageBody) {
        messageBody.setPersistent(false);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy