@@ -9,6 +9,7 @@ import kotlinx.coroutines.sync.Mutex
9
9
import kotlinx.coroutines.sync.withLock
10
10
import java.util.*
11
11
import java.util.concurrent.atomic.AtomicBoolean
12
+ import javax.net.ssl.SSLContext
12
13
13
14
14
15
private class ChannelData (
@@ -38,13 +39,14 @@ class RabbitConnection(
38
39
override suspend fun abstractStart () {
39
40
connection = ConnectionFactory ().also {
40
41
if (useTls) {
41
- // TODO This will trust every cert, even self-signed ones
42
- it.useSslProtocol ()
42
+ it.useSslProtocol( SSLContext .getDefault())
43
+ it.enableHostnameVerification ()
43
44
}
44
45
it.useNio()
45
46
it.username = username
46
47
it.password = password
47
- // TODO Investogate more properties, such as client-provided name
48
+ it.isAutomaticRecoveryEnabled = true
49
+ it.isTopologyRecoveryEnabled = true
48
50
}.newConnection(rabbitAddresses, instanceId)
49
51
}
50
52
@@ -65,9 +67,6 @@ class RabbitConnection(
65
67
deliveryMode(2 ) // Persistent
66
68
headers(headers.headers) // lol
67
69
}.build()
68
- // TODO Later, we can set mandatory=true here and set up a dead letter exchange.
69
- // This would be especially useful for raid bans, so that they don't get lost.
70
- // Though iirc they should be queued, no? Investigate queueing behavior, again.
71
70
channelData.channel.basicPublish(topic, key, properties, value.toByteArray())
72
71
}
73
72
@@ -108,7 +107,7 @@ class RabbitConnection(
108
107
return
109
108
}
110
109
log.error(" RabbitMQ consumer for topic $topic has shut down unexpectedly" , sig)
111
- // TODO Automatic Reconnect?
110
+ // The client _should_ automatically recover the connection
112
111
}
113
112
}
114
113
channelData.consumerTag = channelData.channel.basicConsume(createQueueName(topic), false , consumer)
0 commit comments