if ((producer == null) && (this.exchangeName == null)) {
throw new RuntimeException("Please define annotation @RabbitMQProducer.");
}
// Create Channel
RabbitMQPlugin plugin = Play.plugin(RabbitMQPlugin.class);
channel = plugin.createPublishersChannel(this.exchangeName);
if (channel == null) {
throw new RuntimeException("Error creating a communication channel with RabbitMQ. Please verify the health of your RabbitMQ node and check your configuration.");
}
// Publish Message - to an exchange
channel.basicPublish(this.exchangeName, this.routingKey, plugin.getBasicProperties(), this.getBytes());
// Execution Time
executionTime = new java.util.Date().getTime() - start;
Logger.info("Message %s has been published to exchange %s with routing key %s (execution time: %s ms)", this.message, this.exchangeName , this.routingKey, executionTime);