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

com.infusers.core.sse.requests.PublishActiveRequestsCountToRabbitMQ Maven / Gradle / Ivy

There is a newer version: 2024.12.0008
Show newest version
package com.infusers.core.sse.requests;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
import org.springframework.beans.factory.annotation.Value;

import com.infusers.core.rabbitmq.RabbitMQProperties;
import com.infusers.core.rabbitmq.impl.RabbitMQSender;

@Component
public class PublishActiveRequestsCountToRabbitMQ {
	private final Logger log = LogManager.getLogger(PublishActiveRequestsCountToRabbitMQ.class);
	private static final String CLASS_NAME = "PublishActiveRequestsCountToRabbitMQ";
	
	@Value("${spring.application.name}")
	private String eventSourceApp;
	
    @Autowired
    private RabbitMQProperties properties;
    private final RabbitMQSender rabbitMQSender;	
    
    @Autowired
    public PublishActiveRequestsCountToRabbitMQ(RabbitMQSender rabbitMQSender) {
        this.rabbitMQSender = rabbitMQSender;
    }    
	
    @EventListener
    public void handleActiveRequestCountEvent(ActiveRequestCountEvent event) {    	
        long count = event.getCount();
		log.debug(CLASS_NAME+".handleActiveRequestCountEvent() -> active requests count = "+count);
		
        ActiveRequestsCountRequest req = new ActiveRequestsCountRequest(count, eventSourceApp);
        rabbitMQSender.send(req, properties.getQueues().get(1).getName());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy