Fix client to use an address, not a Queue for replyTo
This commit is contained in:
@@ -70,7 +70,7 @@ public class RabbitClientConfiguration extends AbstractStockAppRabbitConfigurati
|
||||
public StockServiceGateway stockServiceGateway() {
|
||||
RabbitStockServiceGateway gateway = new RabbitStockServiceGateway();
|
||||
gateway.setRabbitTemplate(rabbitTemplate());
|
||||
gateway.setDefaultReplyToQueue(traderJoeQueue());
|
||||
gateway.setDefaultReplyTo(traderJoeQueue().getName());
|
||||
return gateway;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.springframework.amqp.AmqpException;
|
||||
import org.springframework.amqp.core.Address;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.core.MessagePostProcessor;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.amqp.rabbit.core.support.RabbitGatewaySupport;
|
||||
import org.springframework.amqp.rabbit.stocks.domain.TradeRequest;
|
||||
|
||||
@@ -34,20 +33,16 @@ import org.springframework.amqp.rabbit.stocks.domain.TradeRequest;
|
||||
*/
|
||||
public class RabbitStockServiceGateway extends RabbitGatewaySupport implements StockServiceGateway {
|
||||
|
||||
private String defaultReplyToQueue;
|
||||
private String defaultReplyTo;
|
||||
|
||||
public void setDefaultReplyToQueue(String defaultReplyToQueue) {
|
||||
this.defaultReplyToQueue = defaultReplyToQueue;
|
||||
public void setDefaultReplyTo(String defaultReplyTo) {
|
||||
this.defaultReplyTo = defaultReplyTo;
|
||||
}
|
||||
|
||||
public void setDefaultReplyToQueue(Queue defaultReplyToQueue) {
|
||||
this.defaultReplyToQueue = defaultReplyToQueue.getName();
|
||||
}
|
||||
|
||||
public void send(TradeRequest tradeRequest) {
|
||||
getRabbitTemplate().convertAndSend(tradeRequest, new MessagePostProcessor() {
|
||||
public Message postProcessMessage(Message message) throws AmqpException {
|
||||
message.getMessageProperties().setReplyTo(new Address(defaultReplyToQueue));
|
||||
message.getMessageProperties().setReplyTo(new Address(defaultReplyTo));
|
||||
try {
|
||||
message.getMessageProperties().setCorrelationId(UUID.randomUUID().toString().getBytes("UTF-8"));
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
<import resource="classpath:client-handlers.xml" />
|
||||
|
||||
<import resource="classpath:client-messaging.xml" />
|
||||
<!-- XML version of RabbitClientConfiguration -->
|
||||
<!-- import resource="classpath:client-messaging.xml" /-->
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<bean id="stockServiceGateway" class="org.springframework.amqp.rabbit.stocks.gateway.RabbitStockServiceGateway">
|
||||
<property name="rabbitTemplate" ref="rabbitTemplate" />
|
||||
<property name="defaultReplyToQueue" value="#{traderJoeQueue.name}" />
|
||||
<property name="defaultReplyTo" value="#{traderJoeQueue.name}" />
|
||||
</bean>
|
||||
|
||||
<listener-container concurrency="5" connection-factory="connectionFactory" message-converter="jsonMessageConverter"
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<property name="messageConverter" ref="jsonMessageConverter" />
|
||||
</bean>
|
||||
</property>
|
||||
<property name="defaultReplyToQueue" ref="tradeQueue" />
|
||||
<property name="defaultReplyTo" value="fanout://broadcast.responses/" />
|
||||
</bean>
|
||||
|
||||
<rabbit:queue id="tradeQueue" />
|
||||
|
||||
Reference in New Issue
Block a user