|
@@ -6,6 +6,8 @@ import java.util.List;
|
|
|
import java.util.Random;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
|
|
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -18,6 +20,9 @@ public class DocumentService {
|
|
|
@Autowired
|
|
|
NotificationService ns;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ RabbitTemplate rabitt;
|
|
|
+
|
|
|
private List<Document> documents;
|
|
|
private Random rd;
|
|
|
|
|
@@ -35,11 +40,12 @@ public class DocumentService {
|
|
|
}
|
|
|
|
|
|
public boolean add(Document document) {
|
|
|
- this.compute(document);
|
|
|
+ this.rabitt.convertAndSend("", "q.notifications", document);
|
|
|
boolean n = this.documents.add(document);
|
|
|
return n;
|
|
|
}
|
|
|
|
|
|
+ @RabbitListener(queues = {"q.notifications"})
|
|
|
public void compute(Document document) {
|
|
|
try {
|
|
|
Thread.sleep(10 * 1000);
|