-
Notifications
You must be signed in to change notification settings - Fork 65
Open
Description
Hi
When I send many ChannelMessage with a high rate to ChannelActor with dropIfNoChannel = false if I stop rabbitmq and after a duration of time like 1 minute start rabbitmq again, the ChannelActor blocked for process many messages and can't process other message and throw heap space error.
I write this code:
import akka.actor.{ActorRef, ActorSystem}
import akka.pattern._
import akka.util.Timeout
import com.newmotion.akka.rabbitmq.{ChannelActor, ChannelCreated, ChannelMessage, ConnectionActor, ConnectionFactory, CreateChannel}
import com.rabbitmq.client.MessageProperties
import scala.annotation.tailrec
import scala.collection.mutable
import scala.concurrent.ExecutionContext
import scala.concurrent.duration._
object Exam1 extends App {
val system = ActorSystem()
implicit val timeout: Timeout = Timeout(2 second)
implicit val executionContext: ExecutionContext = system.dispatcher
val unconfirmed = mutable.Set.empty[Long]
val connFactory = new ConnectionFactory()
connFactory.setHost("127.0.0.1")
connFactory.setPort(5672)
connFactory.setUsername("amqp")
connFactory.setPassword("pass")
val pubConnActor = system.actorOf(ConnectionActor.props(connFactory))
Thread.sleep(5000)
@tailrec
def produce(chActor: ActorRef): Unit = {
chActor ! ChannelMessage({
ch =>
println("------------------------")
ch.basicPublish("amq.direct", "me-topic", MessageProperties.PERSISTENT_BASIC, "message".getBytes("UTF-8"))
}, dropIfNoChannel = false)
produce(chActor)
}
(pubConnActor ? CreateChannel(ChannelActor.props().withMailbox("bounded-mailbox"))).mapTo[ChannelCreated] map {
case ChannelCreated(chActor) =>
produce(chActor)
}
}
When I run my code and after a duration of time stop rabbitmq and after a duration of time start again I get heap space error and stop my program.
I think this is for loop function in ChannelActor.
Please fix it and choose another way.
Metadata
Metadata
Assignees
Labels
No labels