2015-09-26 51 views
0

據我所知,ActiveMQ默認設置傳送模式爲PERSISTENT ...因此,在使用Akka-Camel時,如何爲特定主題設置傳送模式爲NON_PERSISTENT?以下是我的示例代碼:Akka Camel和ActiveMQ:如何設置傳送模式

import akka.actor._ 
import akka.camel._ 
import org.apache.activemq.camel.component.ActiveMQComponent 

case class MyMessage(body: String) 

class MyProducer() extends Actor with Producer with Oneway { 
    def endpointUri: String = "activemq:MyTopic" 
} 

class SimpleConsumer() extends Actor with Consumer { 
    def endpointUri: String = "activemq:MyTopic" 

    def receive = { 
    case msg: CamelMessage => println(msg) 
    } 
} 

object MyApp extends App { 

    val actorSystem = ActorSystem("MyApp") 
    val system = CamelExtension(actorSystem) 

    system.context.addComponent(
    "activemq", 
    ActiveMQComponent.activeMQComponent("nio://localhost:61616") 
) 

    val consumer = actorSystem.actorOf(Props[MyConsumer]) 
    val producer = actorSystem.actorOf(Props[MyProducer]) 

    ... 

    producer ! MyMessage("hello") 

    ... 

    actorSystem.shutdown() 
} 

回答

1

options設置在端點URI上。

"activemq:MyTopic?deliveryPersistent=false"