【问题标题】:Akka Camel and ActiveMQ: How to set delivery modeAkka Camel 和 ActiveMQ:如何设置交付模式
【发布时间】:2015-09-26 23:07:37
【问题描述】:

据我所知,ActiveMQ 默认将传递模式设置为PERSISTENT...那么在使用Akka-Camel 时如何将特定主题的传递模式设置为NON_PERSISTENT?下面是我的示例代码:

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()
}

【问题讨论】:

    标签: scala akka activemq akka-camel


    【解决方案1】:

    options 设置在端点 URI 上。

    "activemq:MyTopic?deliveryPersistent=false"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-19
      • 2023-03-13
      • 1970-01-01
      • 2014-12-15
      • 2017-07-29
      • 2018-06-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多