springboot使用redis队列作为后台任务处理队列
1.maven依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
2. java config
@Bean
public JedisPoolConfig getJedisPoolConfig(){
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
jedisPoolConfig.setMaxIdle(4);
jedisPoolConfig.setMaxTotal(8);
jedisPoolConfig.setMinIdle(1);
jedisPoolConfig.setMaxWaitMillis(15000);
jedisPoolConfig.setMinEvictableIdleTimeMillis(300000);
jedisPoolConfig.setNumTestsPerEvictionRun(3);
jedisPoolConfig.setTimeBetweenEvictionRunsMillis(60000);
jedisPoolConfig.setBlockWhenExhausted(true);
return jedisPoolConfig;
}
@Bean(name = "jedisConnectionFactory")
public JedisConnectionFactory getJedisConnectionFactory(JedisPoolConfig jedisPoolConfig){
JedisConnectionFactory jedisConnectionFactory = new