Workaround for https://github.com/spring-projects/spring-amqp/issues/1285
This commit is contained in:
committed by
Marcin Grzejszczak
parent
e3d0de106b
commit
ab9d80c483
@@ -5,9 +5,6 @@ buildscript {
|
||||
maven { url "https://repo.spring.io/snapshot" }
|
||||
maven { url "https://repo.spring.io/milestone" }
|
||||
maven { url "https://repo.spring.io/release" }
|
||||
maven { url 'https://repo.spring.io/plugins-snapshot' }
|
||||
maven { url "https://repo.spring.io/plugins-release-local" }
|
||||
maven { url "https://repo.spring.io/plugins-staging-local/" }
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.springframework.boot:spring-boot-gradle-plugin:${findProperty('bootVersion') ?: bootVersion}"
|
||||
|
||||
@@ -2,7 +2,6 @@ buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
maven { url 'https://repo.spring.io/plugins-release' }
|
||||
if (project.hasProperty('fatJar')) {
|
||||
jcenter()
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.example;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -29,7 +28,7 @@ import org.springframework.amqp.rabbit.annotation.QueueBinding;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.messaging.handler.annotation.Headers;
|
||||
import org.springframework.messaging.handler.annotation.Header;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
interface BookService {
|
||||
@@ -61,26 +60,26 @@ public class RabbitManager {
|
||||
this.rabbitTemplate = rabbitTemplate;
|
||||
}
|
||||
|
||||
@RabbitListener(
|
||||
bindings = @QueueBinding(
|
||||
value = @Queue, exchange = @Exchange(value = "input",
|
||||
durable = "true", autoDelete = "false", type = "topic"),
|
||||
key = "event"))
|
||||
public void newBook(Book book, @Headers Map<String, String> headers) {
|
||||
@RabbitListener(bindings = @QueueBinding(value = @Queue,
|
||||
exchange = @Exchange(value = "input", durable = "true", autoDelete = "false", type = "topic"),
|
||||
key = "event"))
|
||||
// Workaround for https://github.com/spring-projects/spring-amqp/issues/1285
|
||||
// public void newBook(Book book, @Headers Map<String, String> headers) {
|
||||
public void newBook(Book book, @Header("amqp_replyTo") String replyTo) {
|
||||
LOG.info("Received new book with bookname = " + book.getName());
|
||||
LOG.info("Headers = " + headers);
|
||||
this.service.sendBook(book, headers.get("amqp_replyTo"));
|
||||
// LOG.info("Headers = " + headers);
|
||||
this.service.sendBook(book, replyTo);
|
||||
}
|
||||
|
||||
@RabbitListener(
|
||||
bindings = @QueueBinding(
|
||||
value = @Queue, exchange = @Exchange(value = "input",
|
||||
durable = "true", autoDelete = "false", type = "topic"),
|
||||
key = "event2"))
|
||||
public void newBook2(Book book, @Headers Map<String, String> headers) {
|
||||
@RabbitListener(bindings = @QueueBinding(value = @Queue,
|
||||
exchange = @Exchange(value = "input", durable = "true", autoDelete = "false", type = "topic"),
|
||||
key = "event2"))
|
||||
// Workaround for https://github.com/spring-projects/spring-amqp/issues/1285
|
||||
// public void newBook2(Book book, @Headers Map<String, String> headers) {
|
||||
public void newBook2(Book book, @Header("amqp_replyTo") String replyTo) {
|
||||
LOG.info("newBook2 Received new book with bookname = " + book.getName());
|
||||
LOG.info("newBook2 Headers = " + headers);
|
||||
this.service.sendBook(book, headers.get("amqp_replyTo"));
|
||||
// LOG.info("newBook2 Headers = " + headers);
|
||||
this.service.sendBook(book, replyTo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user