Need to initialise a listener only if it required to, based on a flag which is set at app startup from external source and not from application.properties.
class PropertyClass {
boolean flag;
..
getters
setters
..
}
@Configuration
class classSettingProperties () {
@Bean
public PropertyClass propertyClass() {
PropertyClass propertyClass = new PropertClass () ;
propertyClass.setflag(true or false);
// Just an example how this property is set.
return propertyClass;
}
}
@Component
public class ListenerClass {
@JmsListener (... destination and factory details)
public void listenerMethod () {
.
.
.
}
}