Skip to content

Exchange binding is not created for @Outgoing channel #2829

Description

@elmodeer

I have the following setup:

@Incoming(PROCESS_VIEWS_CHANNEL)
@Outgoing(PROCESS_VIEWS_DLQ_CHANNEL)
@Acknowledgment(Strategy.MANUAL) // Enable manual ack/nack
@ActivateRequestContext
public Message<byte[]> process(Message<byte[]> message) {
  
  try {
  // some processing logic and if successful 
  return null; // to ack
  } catch(Exception e) {

   var metadata = OutgoingRabbitMQMetadata.Builder().withRoutingKey("processView.lifecycle").build();
   return message.withMetadata(Metadata.of(metadata)); // to send to the dlq
  }
} 

I also tried the following setup but the same issue exists:

  @Inject
  @Channel(PROCESS_VIEWS_DLQ_CHANNEL)
  Emitter<byte[]> failedEventsEmitter;

  @Incoming(PROCESS_VIEWS_CHANNEL)
  @Acknowledgment(Strategy.MANUAL) // Enable manual ack/nack
  @RunOnVirtualThread
  @ActivateRequestContext
  public CompletionStage<Void> process(Message<byte[]> message) {
  try {
  // some processing logic and if successful 
  return message.ack(); // to ack
  } catch(Exception e) {

      // send the event to DLQ
      failedEventsEmitter.send(message.getPayload()).toCompletableFuture().join();
      return message.ack();
  }
  

my properties looks the following:

# Rabbit channel configuration
mp.messaging.incoming.processviews.max-outstanding-messages=1
mp.messaging.incoming.processviews.connector=smallrye-rabbitmq
mp.messaging.incoming.processviews.routing-keys=processView.lifecycle
mp.messaging.incoming.processviews.queue.name=process-view-lifecycle-queue
mp.messaging.incoming.processviews.queue.single-active-consumer=true
mp.messaging.incoming.processviews.exchange.name=process-view-lifecycle-exchange
mp.messaging.incoming.processviews.exchange.type=direct

# Rabbit mq dlq configuration
mp.messaging.outgoing.processviewsdlq.connector=smallrye-rabbitmq
mp.messaging.outgoing.processviewsdlq.default-routing-key=processView.lifecycle
mp.messaging.outgoing.processviewsdlq.exchange.name=process-view-lifecycle-dlx
mp.messaging.outgoing.processviewsdlq.queue.name=process-view-lifecycle-dlq
mp.messaging.outgoing.processviewsdlq.exchange.type=direct

the problem now, is that the failed messages are not routed correctly to the outgoing exchange, i.e. process-view-lifecycle-dlx. Looking at the management ui of rabbitmq using the dev services, I find that the incoming exchange is always created eagerly and properly bound to the queue. But the outgoing exchange is only created when a message is sent and failed and then it has no binding to the queue.

so what is the issue here?

I want to use this exchange as a sink for all failed messages and then later I will have job that consume those messages.

if you ask why I am not using the dlq of rabbit itself, it is because this feature is not supported currently within my org setup for rabbit. so We have to do this custom dlx/dlq stuff.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions