[英]Spring Remoting with AMQP - Client is not seeing the beans exposed from Server
我正在嘗試從http://www.baeldung.com/spring-remoting-amqp運行示例,即使我將專用虛擬主機的連接設置為我的 RabbitMQ 代理,我也只能發送來自客戶端的請求(我在 RabbitMQ UI 中看到它),但我從未從服務器得到答案。
服務器似乎使用getBeanDefinitionNames()
對服務(返回的 Impl 類)進行getBeanDefinitionNames()
,但我絕對沒有在客戶端看到這些 bean。 我使用注釋來設置 bean,而不是 .xml 文件。
所以問題是 - 為什么我的客戶端沒有看到服務器 bean,我通過以下方式發現它更多:
@Autowired
private ApplicationContext appContext;
public GetResponse get(String id) {
Service service = appContext.getBean(Service.class);
System.out.println(service.ping());
return new GetResponse();
}
我在網絡服務級別得到的答案是:
{
"timestamp": "2018-02-01T10:09:00.809Z",
"status": 500,
"error": "Internal Server Error",
"exception": "org.springframework.remoting.RemoteProxyFailureException",
"message": "No reply received from 'toString' with arguments '[]' - perhaps a timeout in the template?",
"path": "/v3/app/r"
}
服務:
public interface Service extends Serializable{
String ping();
}
服務實現:
public class ServiceImpl implements Service {
@Override
public String ping() {
System.out.println("ponged");
return "pong";
}
@Override
public String toString() {
return "to string";
}
編輯 + 賞金
在鏈接中,您可以找到我想連接在一起的提取模塊。 我想它仍然是關於“沒有看到”來自第二個模塊中的一個模塊的 bean。
該操作可以通過 GET http://localhost:8081/v3/app/u觸發 RabbitMQ 設置必須根據您的設置進行調整。
https://bitbucket.org/herbatnic/springremotingexample/overview
我認為你不應該在你的客戶端中設置路由鍵,在 amqpFactoryBean 中(你設置的似乎無效):
您是否嘗試運行他們的示例?
https://github.com/eugenp/tutorials/tree/master/spring-remoting/remoting-amqp
3 年后偶然發現了這個問題.. 試圖運行Baeldung 示例!
我嘗試調試這個問題,據我所知,spring remoting 的 AMQP 實現內部的一些東西在發送客戶端消息時沒有使用正確的路由密鑰,這意味着有效負載到達代理並且永遠不會被放入隊列中處理,然后我們在客戶端 5 秒(默認)后超時。
我嘗試了 Syl 的另一個答案來刪除 routingKey 但是它似乎不允許我們在沒有綁定的情況下創建綁定,即使直接在代理管理頁面上創建綁定(沒有路由密鑰),它也不會路由消息。
我沒有設法讓這個例子的工作,但是我發現了一個博客帖子上fatalerrors.org,顯示的自定義實現AmqpProxyFactoryBean
它已自定義處理的路由項,這一項工作。
我已經使用對我有用的示例創建了這個要點,以防上面的博客文章失敗。
要注意的另一件事是,在Baeldung 示例中,他們使用的是DirectExchange
,而在這里我們使用的是TopicExchange
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.