0

Here are my two RabbitMQ queues and the method:

private final Queue igListenerQueue;
private final Queue igDlxQueue;

@WriteOperation
public void sendDeadMessages(String serviceName, Integer messageCount) {
    //igListenerQueue.addArgument("messages", igDlxQueue.getArguments());
}

I need to take n=messageCount messages from DlxQueue and to relocate them to igListenerQueue. Here are my queues beans:

@Bean(IG_LISTENER)
@Profile("!qa")
public Queue igListenerQueue() {
    Map<String, Object> args = new HashMap<>();
    args.put("x-dead-letter-exchange", rabbitIgDlxProperties.getExchangeName());
    args.put("x-dead-letter-routing-key", rabbitIgDlxProperties.getRoutingKey());
    return new Queue(rabbitIgListenerProperties.getQueueName(), true, false, false, args);
}

@Bean
@Profile("!qa")
public Queue igDlxQueue() {
    Map<String, Object> args = new HashMap<>();
    args.put("x-dead-letter-exchange", rabbitListenerProperties.getExchangeName());
    return new Queue(rabbitIgDlxProperties.getQueueName(), true, false, false, args);
}

How can I do it?

Maksym Rybalkin
  • 453
  • 1
  • 8
  • 22

1 Answers1

1

Add a @RabbitListener method to consume from the queue and send them to the other queue using a RabbitTemplate.

There's an example in the Spring Cloud Stream documentation.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179