第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Spring AMQP 項目不做任何事情

Spring AMQP 項目不做任何事情

慕妹3146593 2021-08-25 17:46:50
我已經(jīng)為這項任務(wù)苦苦掙扎了好幾天,所以我決定在這里問一個問題。好吧,我有一個遠(yuǎn)程 RabbitMQ 服務(wù)器,我只有發(fā)送和接收消息的權(quán)限。這意味著我不能創(chuàng)造任何東西。所以,我想接收和/或發(fā)送消息。但由于某種原因我不能這樣做。應(yīng)用程序啟動、通道創(chuàng)建、bean 初始化等。但是接收方和發(fā)送方什么都不做。我?guī)缀蹩梢钥隙ㄟ@個問題很簡單,我會認(rèn)為我在回答之后是個白癡,但現(xiàn)在我被卡住了。代碼如下。主類是標(biāo)準(zhǔn)的,沒有任何變化。配置類:import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;@Configurationpublic class TestConfiguration {    @Bean    public Sender sender() {        return new Sender();    }    @Bean    public Receiver receiver() {        return new Receiver();    }}發(fā)件人:import org.springframework.amqp.rabbit.core.RabbitTemplate;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.scheduling.annotation.Scheduled;public class Sender {    @Autowired    private RabbitTemplate template;    @Scheduled(fixedDelay = 1000, initialDelay = 500)    public void send() {        String message = "Hello World!";        this.template.convertAndSend("ExchangeName","RoutingKey", message);        System.out.println(" [x] Sent '" + message + "'");    }}接收者:import org.springframework.amqp.rabbit.annotation.RabbitHandler;import org.springframework.amqp.rabbit.annotation.RabbitListener;@RabbitListener(queues = "QueueName")public class Receiver {    @RabbitHandler    public void receive(String in) {        System.out.println(" [x] Received '" + in + "'");    }}應(yīng)用程序?qū)傩裕簊pring.rabbitmq.host=host.comspring.rabbitmq.port=5673spring.rabbitmq.username=usernamespring.rabbitmq.password=passwordspring.rabbitmq.ssl.enabled=true然后什么也沒有發(fā)生。問題是我做錯了什么,為什么它不能按照我想要的方式工作以及如何解決它?我知道復(fù)制粘貼整個項目并要求解決我的所有問題并不是一個很好的做法,對此我深表歉意,但目前我看不出有任何不同的方法可以使我的代碼正常工作。我很樂意得到任何幫助。
查看完整描述

1 回答

?
天涯盡頭無女友

TA貢獻(xiàn)1831條經(jīng)驗 獲得超9個贊

為了能夠使用@Scheduled注釋,您必須首先使用 啟用調(diào)度@EnableScheduling。


嘗試將其添加到您的配置類:


@Configuration

@EnableScheduling

public class TestConfiguration { ... }

一旦你解決了這個問題,你可能還需要看看 wargre 的評論。


查看完整回答
反對 回復(fù) 2021-08-25
  • 1 回答
  • 0 關(guān)注
  • 233 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號