가능한 한 빨리 ActiveMQ 대기열에 게시하려는 아주 기본적인 스켈레톤 스칼라 응용 프로그램 (Akka, Camel 및 ActiveMQ 사용)이 있지만 그 대기열에서만 소비합니다 특정 비율 (예 : 초당 1). 여기 Akka, Camel 및 ActiveMQ : 소비자 제한
는 것을 설명하는 일부 코드입니다 : 내 주요 방법에서 MyConsumer.scalaclass MyConsumer extends Actor with Consumer {
def endpointUri = "activemq:myqueue"
def receive = {
case msg: CamelMessage => println("Ping!")
}
}
MyProducer.scala
class Producer extends Actor with Producer with Oneway {
def endpointUri = "activemq:myqueue"
}
, 나는 그 모든 보일러가 Camel을 설정하고 ActiveMQ와 통화하게하고 나서 :
// Start the consumer
val consumer = system.actorOf(Props[MyConsumer])
val producer = system.actorOf(Props[MyProducer])
// Imagine I call this line 100+ times
producer ! "message"
MyProducer
이 가능한 한 빨리 ActiveMQ로 항목을 전송하도록하려면 어떻게해야합니까? 제한 없음) MyConsumer
은 모든 메시지를 x 초 단위로만 읽습니다. 나는 각 메시지가 마지막 순간 (즉, MyConsumer
에 의해 읽혀질 때까지) ActiveMQ 큐에 남아 있기를 바란다.
지금까지 나는 특정 비율로 섭취하기 위해 TimerBasedThrottler
을 사용했으나, 여전히 모든 메시지를 한 번에 소비합니다.
나는 길을 따라 뭔가를 놓친 경우 사과, 나는 Akka/Camel에 비교적 새로운입니다.
매번 새 제작자를 만들면 안됩니다. ActorRef를 만들고 저장하십시오. – Ryan
감사합니다. Ryan, 좋은 장소 - 이제는 한 번만 인스턴스화하고 있습니다. –