小编gas*_*ton的帖子

我是否需要多次创建ActorMaterializer?

我有一个使用akka-http + akka-actors + akka-camel + akka-streams生成报告的应用程序。当发布请求到达时,ActiveMqProducerActor将请求排队到ActiveMq Broker中。然后ActiveMqConsumerActor使用消息并使用akka-streams启动任务(在这个actor中,我需要实现器)。主类创建ActorSystem和ActorMaterializer,但是我不知道将物化器“注入” akka-actor的正确方法是什么

object ReportGeneratorApplication extends App {

  implicit val system: ActorSystem = ActorSystem()
  implicit val executor = system.dispatcher
  implicit val materializer = ActorMaterializer()

 val camelExtension: Camel = CamelExtension(system);
 val amqc: ActiveMQComponent = ActiveMQComponent.activeMQComponent(env.getString("jms.url"))
 amqc.setUsePooledConnection(true)
 amqc.setAsyncConsumer(true)
 amqc.setTrustAllPackages(true)
 amqc.setConcurrentConsumers(1)
 camelExtension.context.addComponent("jms", amqc);
 val jmsProducer: ActorRef = system.actorOf(Props[ActiveMQProducerActor])

 //Is this the correct way to pass the materializer?
 val jmsConsumer: ActorRef = system.actorOf(Props(new ActiveMQConsumerActor()(materializer)), name = "jmsConsumer")

 val endpoint: ReportEndpoint = new ReportEndpoint(jmsProducer);
 Http().bindAndHandle(endpoint.routes, "localhost", 8881)
}
Run Code Online (Sandbox Code Playgroud)

具有jmsProducerActor的ReportEndPoint类。Mongo是CRUD方法的一个特征。JsonSupport(== …

scala akka akka-stream akka-http

5
推荐指数
0
解决办法
1605
查看次数

标签 统计

akka ×1

akka-http ×1

akka-stream ×1

scala ×1