Luis Munoz
08/06/2020, 3:35 PMinit {
factory = ConnectionFactory().apply {
setUri(config_uri)
// Attempt recovery every 5 seconds
isAutomaticRecoveryEnabled = true
}
rabbitConnection = factory.newConnection()
Nir
08/06/2020, 3:36 PMNir
08/06/2020, 3:36 PMstreetsofboston
08/06/2020, 3:37 PMrabbitConnection
and provide that to the constructor of your class.Luis Munoz
08/06/2020, 4:22 PMNir
08/06/2020, 5:41 PMNir
08/06/2020, 5:41 PMNir
08/06/2020, 5:41 PMNir
08/06/2020, 5:41 PMstreetsofboston
08/06/2020, 5:56 PMNir
08/06/2020, 8:30 PMNir
08/06/2020, 8:30 PMNicholas Bilyk
08/16/2020, 5:07 PMNicholas Bilyk
08/16/2020, 5:11 PMclass MyController(val connectionFactory: IConnectionFactory) {
val rabbitConnection = connectionFactory.newConnection()
}
I prefer to avoid dependency injection that uses reflection, or anything super complicated (especially anything where timing is involved.) Either the interface directly as a constructor parameter, or an 'injector' which can just be a map of interfaces to their implementations.Nicholas Bilyk
08/16/2020, 5:14 PM