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 nodeval node = nodebuilder.withinmemorystorage().build()// then we can expose the native client using the sqs rest interfaceval server = sqsrestserverfactory.start(node.nativeclient, 8888, http://localhost:8888)// now we need to create the sqs clientclient = new amazonsqsclient(new basicawscredentials(x, x))client.setendpoint(http://localhost:8888)// using the client is quite straightforwardval queueurl = client.createqueue(new createqueuerequest(queue1)) .getqueueurlclient.sendmessage(new sendmessagerequest(queueurl, message1))client.shutdown()// finally we need to stop the server and the nodeserver.stop()node.shutdown()
本文来自:开源中国社区
