Skip to content

Commit

Permalink
fix(queue): Fix stupid spring wiring
Browse files Browse the repository at this point in the history
  • Loading branch information
robzienert committed Sep 19, 2017
1 parent cbab4cc commit 20f4d5c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import java.time.Duration

@Configuration
@ConditionalOnExpression("\${queue.redis.enabled:true}")
class RedisQueueShovelConfiguration {
open class RedisQueueShovelConfiguration {

@Bean(name = arrayOf("previousQueueJedisPool")) open fun previousQueueJedisPool(
@Value("\${redis.connection:redis://localhost:6379}") mainConnection: String,
Expand All @@ -50,32 +50,41 @@ class RedisQueueShovelConfiguration {
return RedisConfiguration.createPool(redisPoolConfig, previousConnection, timeout, registry, "previousQueueJedisPool")
}

@Bean(name = arrayOf("previousQueueImpl")) open fun previousRedisQueue(
@Qualifier("previousQueueJedisPool") redisPool: Pool<Jedis>,
@Bean(name = arrayOf("previousQueueImpl"))
@ConditionalOnBean(name = arrayOf("previousQueueJedisPool")) open fun previousRedisQueue(
@Qualifier("previousQueueJedisPool") redisPool: Pool<Jedis>?,
redisQueueProperties: RedisQueueProperties,
clock: Clock,
deadMessageHandler: RedisDeadMessageHandler,
publisher: ApplicationEventPublisher
) =
RedisQueue(
): RedisQueue? {
if (redisPool == null) {
return null
}
return RedisQueue(
queueName = redisQueueProperties.queueName,
pool = redisPool,
clock = clock,
deadMessageHandler = deadMessageHandler::handle,
publisher = publisher,
ackTimeout = Duration.ofSeconds(redisQueueProperties.ackTimeoutSeconds.toLong())
)
}


@Bean()
@ConditionalOnBean(name = arrayOf("previousQueueJedisPool")) open fun redisQueueShovel(
@Qualifier("queueImpl") queueImpl: RedisQueue,
@Qualifier("previousQueueImpl") previousQueueImpl: RedisQueue,
@Qualifier("previousQueueImpl") previousQueueImpl: RedisQueue?,
registry: Registry
) =
QueueShovel(
): QueueShovel? {
if (previousQueueImpl == null) {
return null
}
return QueueShovel(
queue = queueImpl,
previousQueue = previousQueueImpl,
registry = registry
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.netflix.spinnaker.orca.q.ApplicationAware
import com.netflix.spinnaker.orca.q.Queue
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Qualifier
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean
import org.springframework.context.ApplicationListener
import org.springframework.scheduling.annotation.Scheduled
Expand All @@ -39,7 +40,7 @@ import javax.annotation.PostConstruct
@ConditionalOnBean(MonitorableQueue::class)
open class AtlasQueueMonitor
@Autowired constructor(
private val queue: MonitorableQueue,
@Qualifier("queueImpl") private val queue: MonitorableQueue,
private val registry: Registry,
private val clock: Clock
) : ApplicationListener<QueueEvent> {
Expand Down

0 comments on commit 20f4d5c

Please sign in to comment.