Spring Boot中使用RabbitMQ

This commit is contained in:
翟永超
2016-09-25 17:02:39 +08:00
parent 2e13917cb2
commit e5656ab36f
7 changed files with 153 additions and 0 deletions
@@ -0,0 +1,22 @@
package com.didispace.rabbit;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
@Component
public class Sender {
@Autowired
private AmqpTemplate rabbitTemplate;
public void send() {
String context = "hello " + new Date();
System.out.println("Sender : " + context);
this.rabbitTemplate.convertAndSend("hello", context);
}
}