2017-04-18 50 views

回答

1

@SendTo目前僅適用於@RabbitListener的回覆,發件人未設置replyTo標頭。

你可以做你想要與它的通道連接到一個RabbitMQ的出站通道適配器Spring Integration @Publisher annotation什麼...

@Publisher(channel = "amqpOutboundChannel") 
public String send() { 
    return myString; 
} 

@Bean 
@ServiceActivator(inputChannel = "amqpOutboundChannel") 
public AmqpOutboundEndpoint amqpOutbound(AmqpTemplate amqpTemplate) { 
    AmqpOutboundEndpoint outbound = new AmqpOutboundEndpoint(amqpTemplate); 
    outbound.setRoutingKey("my.queue.name"); // default exchange - route to queue 'my.queue.name' 
    return outbound; 
} 

的方法必須是公衆和豆本身之外調用。