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

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

駱駝 RabbitMQ 到 REST 端點 SpringBootTest 失敗

駱駝 RabbitMQ 到 REST 端點 SpringBootTest 失敗

回首憶惘然 2023-06-08 19:46:20
我正在嘗試編寫一個 SpringBootTest 來測試 Camel 路由。我的路線是這樣的: restConfiguration().producerComponent("http4")            .host("http://127.0.0.1);    from("rabbitmq:foo")            .to(rest:post")            .log("Hello!: ${body}");這是我的測試:@RunWith(CamelSpringRunner.class)@MockEndpoints@UseAdviceWith@SpringBootTestpublic class SimpleCamelRouteTest extends CamelTestSupport {@EndpointInject(uri = "mock:rest")private MockEndpoint mockEndpoint;@AutowiredCamelContext context;@AutowiredProducerTemplate template;@Beforepublic void setUp() throws Exception {    context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {       @Override        public void configure() throws Exception {           interceptSendToEndpoint("rabbitmq:foo")                   .skipSendToOriginalEndpoint()                   .to("mock:foo");           interceptSendToEndpoint("http://*")                   .skipSendToOriginalEndpoint()                   .to("mock:rest");        }    });    context.start();}@Testpublic void test() throws InterruptedException {    String body = "Camel";    mockEndpoint.expectedMessageCount(1);    template.sendBody("mock:foo", body);    mockEndpoint.assertIsSatisfied();}}看起來它正試圖在啟動時連接到一個真正運行的 RabbitMq 實例:(18-08-2019 13:20:07.729 [Camel (camel-1) thread #3 - RabbitMQConsumer] INFO  o.a.c.c.rabbitmq.RabbitMQConsumer.call - Connection failed, will retry in 5000msjava.net.ConnectException: 連接被拒絕 (Connection refused)任何人都可以給我一些建議,告訴我如何告訴我的 SpringBootTest 不要尋找正在運行的代理并尊重我設(shè)置的模擬(假設(shè)模擬設(shè)置正確。)
查看完整描述

1 回答

?
白衣非少年

TA貢獻1155條經(jīng)驗 獲得超0個贊

您正在嘗試使用攔截消費者 (?from)?interceptSendToEndpoint。這不可能。為此你需要replaceFromWith。

context.getRouteDefinitions().get(0).adviceWith(context,?new?AdviceWithRouteBuilder()?{
???@Override
????public?void?configure()?throws?Exception?{
???????replaceFromWith("direct:triggerFoo");?
?????????????//...
????}
});

然后像這樣觸發(fā)路由:

template.sendBody("direct:triggerFoo",?body);

你也在攔截http4生產(chǎn)者,但從你的路線看來你可能想要攔截rest*。


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

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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