Hi, In the below snippet I am trying to dynamically build the IMAP route by refreshing my 'exchangeAuthenticator' bean. Camel seemingly supports only bean by name injection into the route. Although I am able to instantiate the bean with new values yet the route refers to the old bean values and fails with error.
public void updateAuthenticator() { String tenantId = emailConfigBean.getTenantId(); String clientId = emailConfigBean.getClientId(); String clientSecret = emailConfigBean.getClientSecret(); String wsAdapterMailBox = emailConfigBean.getWSAdapterMailBox(); try { MicrosoftExchangeOnlineOAuth2MailAuthenticator newExchangeAuthenticator = new MicrosoftExchangeOnlineOAuth2MailAuthenticator( tenantId, clientId, clientSecret, wsAdapterMailBox); // Get the registry DefaultRegistry defaultRegistry = (DefaultRegistry) camelContext.getRegistry(); // Unbind the existing 'exchangeAuthenticator' bean MicrosoftExchangeOnlineOAuth2MailAuthenticator exchangeAuthenticator = (MicrosoftExchangeOnlineOAuth2MailAuthenticator) defaultRegistry .lookupByName("exchangeAuthenticator"); if (null != exchangeAuthenticator) { defaultRegistry.unbind("exchangeAuthenticator"); } defaultRegistry.bind("exchangeAuthenticator", newExchangeAuthenticator); defaultRegistry.setCamelContext(camelContext); } catch (Exception e) { log.error("Exception in updating authenticator bean: {}", e.getMessage()); } } //building the route dynamically through refreshed values of bean public String getImapConfig(String imapUrl, String imapPort, String pollingInterval, String debugMode) { authenticatorService.updateAuthenticator(); return "imaps://" + imapUrl + ":" + imapPort + "?authenticator=#exchangeAuthenticator" + "&debugMode="+ debugMode + "&delete=false" + "&unseen=true" + "&delay=" + pollingInterval + "&mail.imaps.auth.mechanisms=XOAUTH2" + "&disconnect=true" + "&closeFolder=true"; } Regards, Dipak.