>  기사  >  데이터 베이스  >  ElasticMQ 0.2 – 支持延迟队列和消息

ElasticMQ 0.2 – 支持延迟队列和消息

WBOY
WBOY원래의
2016-06-07 15:06:591384검색

ElasticMQ 是一个使用 Scala 编写的简单消息队列系统。当前使用嵌入式数据库 H2 来存储消息。ElasticMQ 实现了 SQS REST 接口的子集,提供一个 SQS 的可选方案。 ElasticMQ 0.2 最值得关注的就是支持延迟队列和消息,另外实现了 Amazon SQS 接口。 // First

ElasticMQ 是一个使用 Scala 编写的简单消息队列系统。当前使用嵌入式数据库 H2 来存储消息。ElasticMQ 实现了 SQS REST 接口的子集,提供一个 SQS 的可选方案。

ElasticMQ 0.2 最值得关注的就是支持延迟队列和消息,另外实现了 Amazon SQS 接口。

// First we need to create a Node
val node = NodeBuilder.withInMemoryStorage().build()
// Then we can expose the native client using the SQS REST interface
val server = SQSRestServerFactory.start(node.nativeClient, 8888,
      "http://localhost:8888")

// Now we need to create the sqs client
client = new AmazonSQSClient(new BasicAWSCredentials("x", "x"))
client.setEndpoint("http://localhost:8888")

// Using the client is quite straightforward
val queueUrl = client.createQueue(new CreateQueueRequest("queue1"))
      .getQueueUrl
client.sendMessage(new SendMessageRequest(queueUrl, "message1"))

client.shutdown()

// Finally we need to stop the server and the node
server.stop()
node.shutdown()

本文来自:开源中国社区

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.