我想使用一些回调API为我的Rabbitmq生产者找出失败的消息。我已经用[{rabbit,[{vm_memory_high_watermark,0.001}]}]配置了Rabbitmq。并尝试发送大量消息,但是所有消息都被接受,并且TimeoutException稍后再出现,消息没有发送到Queue enter code here
,请告诉我如何捕获它。
发送消息的代码:
// #create-sink - producer
final Sink<ByteString, CompletionStage<Done>> amqpSink =
AmqpSink.createSimple(
AmqpSinkSettings.create(connectionProvider)
.withRoutingKey(AkkaConstants.queueName)
.withDeclaration(queueDeclaration));
// #run-sink
//final List<String> input = Arrays.asList("one", "two", "three", "four", "five");
//Source.from(input).map(ByteString::fromString).runWith(amqpSink, materializer);
String filePath = "D:\\subrata\\code\\akkaAmqpTest-master\\akkaAmqpTest-master\\logs2\\dummy.txt";
Path path = Paths.get(filePath);
// List containing 78198 individual message
List<String> contents = Files.readAllLines(path);
System.out.println("********** file reading done ....");
int times = 5;
// Send 78198*times message to Queue [From console i can see 400000 number of messages being sent]
for(int i=0;i<times;i++) {
Source.from(contents).map(ByteString::fromString).runWith(amqpSink, materializer);
}
System.out.println("************* sending to queue is done");
答案 0 :(得分:0)
不幸的是,目前不支持该功能。理想情况下,生产者将被建模为Flow
,它将把所有传入消息发送到AMQP代理,并且会发送相同的消息,其结果是天气是否已成功发送到代理。 Alpakka问题跟踪器上有a ticket to track this possible improvement。