1

Below is how I load my redisnode( using redis server) with the configuration as stated on https://github.com/redisson/redisson/wiki/9.-distributed-services#944-distributed-scheduled-executor-service-scheduling-a-task-with-spring-beans where it says to use the BeanFactory to load the spring beans.

@Bean(destroyMethod = "shutdown")
 RedissonNode redissonNode(){
    Config config = new Config();
    config.useSingleServer().setAddress("redis://" + redisHost + ":" + redisPort + "");
    RedissonNodeConfig nodeConfig = new RedissonNodeConfig(config);
    nodeConfig.setExecutorServiceWorkers(Collections.singletonMap("myExecutor", 1));
    nodeConfig.setBeanFactory(beanFactory);
    RedissonNode node = RedissonNode.create(nodeConfig);
    node.start();
    return node;
}

But I still get the NoSuchBeanDefinitionException: No qualifying bean of type 'xx.xx.xx.xx.xx.BrandService' error when the Runnable Task is called where I am auto-wiring my services. Below is how I am using @Autowire in the runnable task

@RInject
private RedissonClient redissonClient;
@Autowired
@Qualifier("brandService")
private BrandService brandService;
@Autowired
private BranchService branchService;

I have used the following on Application as configuration to load all the possible beans

@ComponentScan(basePackages = {"xx.xx.project"})

Any ideas what am I missing ?

Shuja Ahmed
  • 752
  • 5
  • 17
  • Did you make sure that BrandService @Qualifier("brandService") is properly registered in context? – Nikita Koksharov Jul 16 '20 at 07:47
  • Thanks for the update but i managed to solve it by another approach – Shuja Ahmed Jul 16 '20 at 07:50
  • Sounds interesting, which one? – Nikita Koksharov Jul 16 '20 at 07:51
  • Instead of using runnable tasks i used the Executor Service ( Threadpool ) instead of redisson client as even after solving the bean issue of was facing serialization and deserialization issues. So running it on background thread seemed more easy approach. As at the end of the day the purpose of using reddison was to use redis for background tasks which can alternatively be handled by executor service ( threadpool ) – Shuja Ahmed Jul 16 '20 at 07:53
  • @ShujaAhmed, Could you please share your solution? – Hadi J May 04 '21 at 20:19

0 Answers0