Skip to content

Commit cfebf6c

Browse files
committed
Resolve todos
1 parent 149879b commit cfebf6c

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

latte/src/main/java/gg/beemo/latte/broker/rabbitmq/RabbitConnection.kt

+6-7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import kotlinx.coroutines.sync.Mutex
99
import kotlinx.coroutines.sync.withLock
1010
import java.util.*
1111
import java.util.concurrent.atomic.AtomicBoolean
12+
import javax.net.ssl.SSLContext
1213

1314

1415
private class ChannelData(
@@ -38,13 +39,14 @@ class RabbitConnection(
3839
override suspend fun abstractStart() {
3940
connection = ConnectionFactory().also {
4041
if (useTls) {
41-
// TODO This will trust every cert, even self-signed ones
42-
it.useSslProtocol()
42+
it.useSslProtocol(SSLContext.getDefault())
43+
it.enableHostnameVerification()
4344
}
4445
it.useNio()
4546
it.username = username
4647
it.password = password
47-
// TODO Investogate more properties, such as client-provided name
48+
it.isAutomaticRecoveryEnabled = true
49+
it.isTopologyRecoveryEnabled = true
4850
}.newConnection(rabbitAddresses, instanceId)
4951
}
5052

@@ -65,9 +67,6 @@ class RabbitConnection(
6567
deliveryMode(2) // Persistent
6668
headers(headers.headers) // lol
6769
}.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.
7170
channelData.channel.basicPublish(topic, key, properties, value.toByteArray())
7271
}
7372

@@ -108,7 +107,7 @@ class RabbitConnection(
108107
return
109108
}
110109
log.error("RabbitMQ consumer for topic $topic has shut down unexpectedly", sig)
111-
// TODO Automatic Reconnect?
110+
// The client _should_ automatically recover the connection
112111
}
113112
}
114113
channelData.consumerTag = channelData.channel.basicConsume(createQueueName(topic), false, consumer)

0 commit comments

Comments
 (0)