当前位置: 首页>>代码示例>>Scala>>正文


Scala QuartzSchedulerExtension类代码示例

本文整理汇总了Scala中com.typesafe.akka.extension.quartz.QuartzSchedulerExtension的典型用法代码示例。如果您正苦于以下问题:Scala QuartzSchedulerExtension类的具体用法?Scala QuartzSchedulerExtension怎么用?Scala QuartzSchedulerExtension使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QuartzSchedulerExtension类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。

示例1: MessageQuartzScheduler

//设置package包名称以及导入依赖的类
package com.packt.chapter10

import akka.actor.{Actor, ActorLogging}
import com.typesafe.akka.extension.quartz.QuartzSchedulerExtension

object MessageQuartzScheduler {
  case object Every2Seconds
}

class MessageQuartzScheduler extends Actor with ActorLogging {
  import MessageQuartzScheduler._

  override def preStart() = {
    QuartzSchedulerExtension(context.system).schedule("Every2Seconds", self, Every2Seconds)
  }

  override def postStop() = {
    QuartzSchedulerExtension(context.system).cancelJob("Every2Seconds")
  }

  def receive = {
    case x => log.info(s"Received $x")
  }
} 
开发者ID:PacktPublishing,项目名称:Akka-Cookbook,代码行数:25,代码来源:MessageQuartzScheduler.scala

示例2: index

//设置package包名称以及导入依赖的类
package controllers

import javax.inject._
import akka.actor.{Props, ActorSystem}
import com.typesafe.akka.extension.quartz.QuartzSchedulerExtension
import play.api.inject.ApplicationLifecycle
import play.api.mvc._


  def index = Action {
    onStart()
    Ok(views.html.index("Your new application is ready."))
  }

  def onStart(): Unit = {
    val system = ActorSystem("SampleSystem")
    val scheduler = QuartzSchedulerExtension(actorSystem)
    val actor = system.actorOf(Props(classOf[SampleActor]))
    QuartzSchedulerExtension(system).schedule("Every1Second", actor, "1?")
    QuartzSchedulerExtension(system).schedule("Every5Seconds", actor, "5?")
  }
} 
开发者ID:shigemk2,项目名称:my-akka-quartz-scheduler-sample,代码行数:23,代码来源:HomeController.scala

示例3: GlobalModule

//设置package包名称以及导入依赖的类
package modules

import play.api.db.slick.DatabaseConfigProvider
import play.api.inject.ApplicationLifecycle
import play.api.{Environment, Logger, Mode}

import actors.{AlertMail, SplashPost}
import akka.actor.{ActorRef, ActorSystem, Props}
import com.google.inject.{AbstractModule, Inject}
import com.typesafe.akka.extension.quartz.QuartzSchedulerExtension

import scala.concurrent.Future


class GlobalModule extends AbstractModule {
  override def configure() = {
    bind(classOf[GlobalSetting]).asEagerSingleton()
  }
}

class GlobalSetting @Inject()(lifecycle: ApplicationLifecycle, env: Environment, dbConfigProvider: DatabaseConfigProvider) {
  Logger.info("Start application...")

  if (!env.mode.equals(Mode.Dev)) startActor

  lifecycle.addStopHook { () =>
    Future.successful(null)
  }

  def startActor = {
    val system: ActorSystem = ActorSystem("BatchSystem")
    val alertMailActor: ActorRef = system.actorOf(Props(classOf[AlertMail], dbConfigProvider))
    val splashPostActor: ActorRef = system.actorOf(Props(classOf[SplashPost], dbConfigProvider))

    // TODO: send sns search result mail function
    // QuartzSchedulerExtension(system).schedule("AlertMailEveryHour", alertMailActor, "send sns alert mail")
    QuartzSchedulerExtension(system).schedule("SplashPostEveryHour", splashPostActor, "splash posts")

  }

} 
开发者ID:yukihirai0505,项目名称:sns-alert,代码行数:42,代码来源:GlobalModule.scala

示例4: ServerApp

//设置package包名称以及导入依赖的类
package com.mpakhomov

import java.net.InetSocketAddress

import akka.actor.ActorSystem
import com.mpakhomov.actors.CandlestickAggregatorActor.GetDataForLastNMinutes
import com.mpakhomov.actors.ServerActor.SendDataForLastMinute
import com.mpakhomov.actors.{CandlestickAggregatorActor, EventProcessorActor, ServerActor, UpstreamClientActor}
import com.typesafe.config.ConfigFactory

object ServerApp {

  val cronJobName = "EveryMinute"

  def main(args: Array[String]): Unit = {
    val config = ConfigFactory.load()
    val system = ActorSystem("akka-io-demo")
    val candlestickAggregator = system.actorOf(CandlestickAggregatorActor.props(config.getInt("app.keep-data-minutes")))
    val eventProcessor = system.actorOf(EventProcessorActor.props(candlestickAggregator))
    val inetSocketAddress = new InetSocketAddress(
      config.getString("app.upstream.hostname"),
      config.getInt("app.upstream.port"))
    val upstreamClient = system.actorOf(UpstreamClientActor.props(inetSocketAddress, eventProcessor))
    val server = system.actorOf(ServerActor.props(
      new InetSocketAddress(config.getInt("app.server.port")),
      candlestickAggregator
    ))


    // schedule a job that runs at the beginning of every minute
    import com.typesafe.akka.extension.quartz.QuartzSchedulerExtension
    val scheduler = QuartzSchedulerExtension(system)
    scheduler.schedule(cronJobName, server, SendDataForLastMinute)
  }
} 
开发者ID:mpakhomov,项目名称:akka-io-demo,代码行数:36,代码来源:ServerApp.scala

示例5: schedule

//设置package包名称以及导入依赖的类
package com.knoldus.scheduler

import com.knoldus.actors.LocalActorRefFactory
import com.knoldus.configuration.Configuration._
import com.knoldus.messages.{Message1, Message2}
import com.typesafe.akka.extension.quartz.QuartzSchedulerExtension

trait Scheduler {

  val localActorRefFactory: LocalActorRefFactory

  def schedule: Unit = {
    val _system = localActorRefFactory.system
    val firstReceiver = localActorRefFactory getReceiver NAME_FIRST_ACTOR
    val secondReceiver = localActorRefFactory getReceiver NAME_SECOND_ACTOR

    QuartzSchedulerExtension(_system).schedule(CRON_FIRST_EXPRESSION, firstReceiver, Message1)
    QuartzSchedulerExtension(_system).schedule(CRON_SECOND_EXPRESSION, secondReceiver, Message2)
  }

}

object Scheduler extends Scheduler{
  val localActorRefFactory: LocalActorRefFactory = LocalActorRefFactory
} 
开发者ID:knoldus,项目名称:akka-quartz-scheduler-application.g8,代码行数:26,代码来源:Scheduler.scala


注:本文中的com.typesafe.akka.extension.quartz.QuartzSchedulerExtension类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。