Eddie Jamsession
Eddie Jamsession

Reputation: 1006

Extract headers from message using spring-rabbit without declaring queues in annotation

Now I can do like this:

@RabbitListener(queues = {ENTITY_KEY + "-snapshots",  ENTITY_KEY + "-updates"})
public void handleMessage(ProviderOddsOffer offer, @Header("update_type") Long updateType) {
    ...
}

Can I do it without declaring queues in annotation itself?

Upvotes: 2

Views: 1593

Answers (1)

Gary Russell
Gary Russell

Reputation: 174494

It's not clear what you mean; the listener has to be configured to consume from some queue, or queues.

If you that mean you wish to externalize the queue name(s) rather than hard-coding in java, you can use a property placeholder ${...} or a SpEL expression #{...} for the queue name(s); they will be resolved during bean initialization.

Upvotes: 3

Related Questions