
com.thenewmotion.akka.rabbitmq.BlockedConnectionSupport.scala Maven / Gradle / Ivy
The newest version!
package com.thenewmotion.akka.rabbitmq
import akka.actor.ActorRef
import com.rabbitmq.client.BlockedListener
import com.thenewmotion.akka.rabbitmq.BlockedConnectionHandler.{ QueueBlocked, QueueUnblocked }
/**
* @author Mateusz Jaje
*/
/**
* Support for blocked connections for publishing
* More info https://www.rabbitmq.com/connection-blocked.html
*/
object BlockedConnectionSupport {
def setupConnection(connection: Connection, connectionMaintainer: ActorRef): Any = {
val handler = new BlockedConnectionHandler(connectionMaintainer)
connection.addBlockedListener(handler)
}
}
object BlockedConnectionHandler {
case class QueueBlocked(reason: String)
case object QueueUnblocked
}
class BlockedConnectionHandler(listener: ActorRef) extends BlockedListener {
override def handleUnblocked(): Unit = listener ! QueueUnblocked
override def handleBlocked(reason: String): Unit = listener ! QueueBlocked(reason)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy