Active Job
来源:互联网 发布:点对点网速测试软件 编辑:程序博客网 时间:2024/05/28 11:48
rails generate job guests_cleanup
class GuestsCleanupJob < ApplicationJob queue_as :default def perform(*guests) # 稍后做些事情 end end
# 入队作业,作业在队列系统空闲时立即执行 GuestsCleanupJob.perform_later guest# 入队作业,在明天中午执行GuestsCleanupJob.set(wait_until: Date.tomorrow.noon).perform_later(guest)# 入队作业,在一周以后执行GuestsCleanupJob.set(wait: 1.week).perform_later(guest)# `perform_now` 和 `perform_later` 会在幕后调用 `perform`# 因此可以传入任意个参数GuestsCleanupJob.perform_later(guest1, guest2, filter: 'some_filter')
#队列后端设置 # config/application.rb module YourApp class Application < Rails::Application # 要把适配器的 gem 写入 Gemfile # 请参照适配器的具体安装和部署说明 config.active_job.queue_adapter = :sidekiq end
# 如需想现在发送电子邮件,使用 #deliver_now注意确保队列后端“监听”着队列名称。某些后端要求指定要监听的队列。 17.6 回调 - 437UserMailer.welcome(@user).deliver_now# 如果想通过 Active Job 发送电子邮件,使用 #deliver_laterUserMailer.welcome(@user).deliver_later
#sidekiq.yml:concurrency: 5:pidfile: tmp/pids/sidekiq.piddevelopment: :concurrency: 2production: :concurrency: 5#处理消息队列:queues: - [default, 5]:logfile: log/sidekiq.log
#启动sidekiqsidekiq -C config/sidekiq.yml -e development
Rails.application.routes.draw do #sidekiq路由配置 require 'sidekiq/web' mount Sidekiq::Web => '/sidekiq-stat'end
include Sidekiq::Worker sidekiq_options queue: :kuaidi100_subscribe, backtrace: true #backtrace: true
阅读全文
0 0
- Active Job
- ORA-20211: Active job record exists问题解决
- active
- job
- job
- job
- job
- job
- JOB
- job
- Job
- job
- Job
- job
- JOB
- job
- job
- job
- TimeAndMath
- WebHubBot爬虫分享(每天可抓取500万以上)
- 问题:Objective-C 中 C 类型函数不识别 foundation 中的类
- 设计模式
- SpringSecurity学习笔记(三)——自定义登录界面读取数据库用户以及权限
- Active Job
- swift 网络----利用URLSession的Block模式下载多张图片
- 11.ar, nm, objdump
- 华北水利水电大学社会实践--国情社情调研团走进社区
- 慕课HTML基础知识复习
- fabric 开发环境
- 葵花宝典 六
- jsp session
- jQuery