微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Karait 消息队列系统

程序名称:Karait

授权协议: 未知

操作系统: 跨平台

开发语言: Python

Karait 介绍

Karait是一个消息队列系统,其消息存储采用了MongoDB的Capped
Collections结构,这一结构的特点就是集合的大小可设定,当数据大小超出设定大小时,新数据会抹掉旧数据。

Karait目前提供Python和Ruby的客户端操作包,也就是说你可以使用Python或Ruby来写消息,用Python或Ruby来读队列。

Ruby 版本示例代码

require 'karait'

queue = Karait::Queue.new(
    :host => 'localhost', # MongoDB host. Defaults to localhost.
    :port => 27017, # MongoDB port. Defaults to 27017.
    :database => 'karait', # Database that will store the karait queue. Defaults to karait.
    :queue => 'messages', # The capped collection that karait writes to. Defaults to messages.
    :average_message_size => 8192, # How big do you expect the messages will be in bytes? Defaults to 8192.
    :queue_size => 4096 # How many messages should be allowed in the queue. Defaults to 4096.
)

queue.write({
    :name => 'Benjamin',
    :action => 'Rock'
})

# or

message = Karait::Message.new
message.name = 'Benjamin'
message.action = 'Rock!'

queue.write(message, :routing_key => 'my_routing_key', :expire => 3.)

Karait 官网

https://github.com/bcoe/karait

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐