日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

rabbitmq订单模块_RabbitMQ播放模块! 构架

發布時間:2023/12/3 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 rabbitmq订单模块_RabbitMQ播放模块! 构架 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

rabbitmq訂單模塊

RabbitMQ提供了具有可預測且一致的吞吐量和延遲的高可用性,可伸縮和便攜式消息傳遞系統。 RabbitMQ是AMQP (業務消息傳遞的開放標準)的領先實現 ,并且通過適配器支持XMPP,SMTP,STOMP和HTTP來進行輕量級Web消息傳遞。

這個新模塊允許您在Play上的RabbitMQ實例上消費和產生消息! 框架應用程序。

安裝

play install rabbitmq

組態

module.rabbitmq=${play.path}/modules/rabbitmq-0.0.1 rabbitmq.host=localhost rabbitmq.port=5672 rabbitmq.userName=guest rabbitmq.password=guest rabbitmq.vhost=/ rabbitmq.exchangeType=direct rabbitmq.durable=true rabbitmq.autoAck=false rabbitmq.basicQos=true

定義將由隊列使用的消息(只是一個簡單的POJO)

public class SampleMessage implements Serializable {/** The field1. */private String field1;/** The field2. */private String field2;/*** Instantiates a new sample message.*/public SampleMessage() {}/*** Instantiates a new sample message.** @param field1 the field1* @param field2 the field2*/public SampleMessage(String field1, String field2) {super();this.field1 = field1;this.field2 = field2;}/*** Gets the field1.** @return the field1*/public String getField1() {return field1;}/*** Sets the field1.** @param field1 the new field1*/public void setField1(String field1) {this.field1 = field1;}/*** Gets the field2.** @return the field2*/public String getField2() {return field2;}/*** Sets the field2.** @param field2 the new field2*/public void setField2(String field2) {this.field2 = field2;}/*** To String** @see java.lang.Object#toString()*/@Overridepublic String toString() {return "SampleMessage [field1=" + field1 + ", field2=" + field2 + "]";} }

發布消息

public static void publish(String q) {RabbitMQPublisher.publish("myQueue", new SampleMessage(q, q));render(q);}

創建消息使用者

@OnApplicationStart(async=true) public class RabbitMQSampleConsumer extends RabbitMQConsumer {/*** Consume Message** @see play.modules.rabbitmq.consumer.RabbitMQConsumer#consume(T)*/@Overrideprotected void consume(SampleMessage message) {System.out.println("******************************");System.out.println("* Message Consumed: " + message);System.out.println("******************************");}/*** Name of the Queue that this consumer will be listening to.** @return the string* @see play.modules.rabbitmq.consumer.RabbitMQConsumer#queue()*/@Overrideprotected String queue() {return "myQueue";}/*** Return message type.** @return the message type* @see play.modules.rabbitmq.consumer.RabbitMQConsumer#getMessageType()*/protected Class getMessageType() {return SampleMessage.class;} }

*請注意,這是一場戲! 作業,因此您可以手動啟動它,也可以使用Play提供的其他注釋! 例如@On或@Every。 有關更多信息,請參見“ 異步作業”文檔 。

Firehose –批量發布消息的另一種方法

@OnApplicationStart(async = true) public class RabbitMQSampleFirehose extends RabbitMQFirehose {/** The count. */public int count = 0;/*** Get data to be loaded.** @param n the n* @return the data* @throws Exception the exception* @see play.modules.rabbitmq.producer.RabbitMQFirehose#getData(int)*/@Overrideprotected List getData(int n) throws Exception {if ( count >= 10 ) {return null;}List results = new ArrayList();for (int i = 0; i < n; i++) {results.add(new SampleMessage("field1", "field2"));count++;}return results;}/*** Batch Size - How many records we will select at the time?.** @return the int* @see play.modules.rabbitmq.producer.RabbitMQFirehose#batchSize()*/@Overrideprotected int batchSize() {return 2;}/*** Queue Name.** @return the string* @see play.modules.rabbitmq.producer.RabbitMQFirehose#queueName()*/@Overrideprotected String queueName() {return "myQueue";}}

*請注意,這是一場戲! 作業,因此您可以手動啟動它,也可以使用Play提供的其他注釋! 例如@On或@Every。 有關更多信息,請參見“ 異步作業”文檔 。 當然,該代碼在Github上可用。

現在開始游戲!

參考: RabbitMQ Play模塊! 我們的JCG合作伙伴 Felipe Oliveira在Geeks的 框架 完全在 。

相關文章:

  • Java Code Geeks Andygene Web原型
  • 每個程序員都應該知道的事情
  • Spring MVC開發–快速教程
  • SmartGWT入門,提供出色的GWT界面
  • GWT 2 Spring 3 JPA 2 Hibernate 3.5教程

翻譯自: https://www.javacodegeeks.com/2011/04/rabbitmq-module-play-framework.html

rabbitmq訂單模塊

創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的rabbitmq订单模块_RabbitMQ播放模块! 构架的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。