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

ca.gc.aafc.dina.messaging.producer.RabbitMQMessageProducer Maven / Gradle / Ivy

There is a newer version: 0.134
Show newest version
package ca.gc.aafc.dina.messaging.producer;

import org.springframework.amqp.rabbit.core.RabbitTemplate;

import ca.gc.aafc.dina.messaging.DinaMessage;
import ca.gc.aafc.dina.messaging.config.RabbitMQQueueProperties;

/**
 * Generic class to send DinaMessage using default routing key (queue name).
 */
public class RabbitMQMessageProducer {

  private final RabbitTemplate rabbitTemplate;
  private final String queueName;

  public RabbitMQMessageProducer(RabbitTemplate rabbitTemplate,
                                 RabbitMQQueueProperties queueProperties) {
    this.rabbitTemplate = rabbitTemplate;
    this.queueName = queueProperties.getQueue();
  }

  public void send(DinaMessage dinaMessage) {
    // use the queue name as routing key since we are using the default
    rabbitTemplate.convertAndSend(queueName, dinaMessage);
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy