larry page
larry page

Reputation: 77

Spring Integration Message Driven channel adapter Refresh Scope

My application is using Spring cloud and Refresh Scope is used to dynamically refresh some of the beans when the configuration is change. How can I make the same behavior applicable to the Jms message listener as well. Below is the message listener defined in Spring integration. How can I define this bean to refresh whenever there is a configuration change. In this case I am using the max concurrent consumers and auto-startup attributes to load from properties

<jms:message-driven-channel-adapter
    id="processMessageDrivenChannelAdapter" send-timeout="5000"
    max-messages-per-task="-1"
    idle-task-execution-limit="100"
    max-concurrent-consumers="${consumers}"
    connection-factory="messageConnectionFactory"
    destination="jmsQueue" channel="messageProcessChannel"
    acknowledge="transacted" auto-startup="${autoStartUp}"  />

Upvotes: 2

Views: 426

Answers (1)

Gary Russell
Gary Russell

Reputation: 174574

@RefreshScope is not supported for "active" beans; e.g. those that implement SmartLifecycle that need their lifecycle managed (started/stopped etc).

It is only supported for passive beans that just get new properties after a refresh.

You would have to listen for the refresh event and manually stop/reconfigure/start the adapter.

Upvotes: 1

Related Questions