Skip to content

Commit

Permalink
Merge pull request #2452 from hongwei1/develop
Browse files Browse the repository at this point in the history
refactor/teaked rabbitMq queue
  • Loading branch information
simonredfern authored Nov 28, 2024
2 parents 1311930 + 5ae8942 commit e5fa13f
Showing 1 changed file with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ object RabbitMQUtils extends MdcLoggable{
// automatically be deleted if it is not used, i.e., if no consumer is connected to it during that time.
args.put("x-expires", Integer.valueOf(60000))
args.put("x-message-ttl", Integer.valueOf(60000))
args.put("x-queue-type", "quorum")
//args.put("x-queue-type", "quorum") // use the classic first.


private implicit val formats = code.api.util.CustomJsonFormats.nullTolerateFormats

val RPC_QUEUE_NAME: String = "obp_rpc_queue"
val RPC_REPLY_TO_QUEUE_NAME_PREFIX: String = "obp_reply_queue"

class ResponseCallback(val rabbitCorrelationId: String, channel: Channel) extends DeliverCallback {

Expand Down Expand Up @@ -86,18 +87,18 @@ object RabbitMQUtils extends MdcLoggable{
val channel = connection.createChannel() // channel is not thread safe, so we always create new channel for each message.
channel.queueDeclare(
RPC_QUEUE_NAME, // Queue name
true, // durable: non-persis
false, // exclusive: non-excl4
false, // autoDelete: delete
args // extra arguments
true, // durable: non-persis, here set durable = true
false, // exclusive: non-excl4, here set exclusive = false
false, // autoDelete: delete, here set autoDelete = false
args // extra arguments,
)

val replyQueueName:String = channel.queueDeclare(
"amq.gen-"+UUID.randomUUID.toString, // Queue name, rabbitMq will create a unique name for this queue, eg:
true, // durable: non-persistent
false, // exclusive: non-exclusive
false, // autoDelete: delete when no consumers
args // extra arguments
s"${RPC_REPLY_TO_QUEUE_NAME_PREFIX}_${messageId.replace("obp_","")}_${UUID.randomUUID.toString}", // Queue name, it will be a unique name for each queue
false, // durable: non-persis, here set durable = false
true, // exclusive: non-excl4, here set exclusive = true
true, // autoDelete: delete, here set autoDelete = true
args // extra arguments,
).getQueue

val rabbitResponseJsonFuture = {
Expand Down

0 comments on commit e5fa13f

Please sign in to comment.