| | |
| | | //5. `null`:指定其他队列属性的参数。在这里设置为`null`,表示没有其他属性需要设置。
|
| | | //执行`channel.queueDeclare()`方法后,如果队列不存在,将会创建一个新的队列,如果队列已经存在,则不做任何操作。
|
| | | Map<String, Object> args = new HashMap<>();
|
| | | args.put("x-max-length-bytes",20000);
|
| | | args.put("x-max-length-bytes",1024 * 1024);
|
| | | // args.put("x-max-length",5000);
|
| | | channel.queueDeclare(QUEUE_NAME, false, false, false, args);
|
| | |
|
| | | String message = "你";
|
| | |
|
| | | for ( int i=1;i< 5000;i++)
|
| | | for ( int i=1;i< 20000;i++)
|
| | | {
|
| | | message+="你";
|
| | |
|
| | |
| | | // 将消息发布到指定的队列中。空字符串""表示默认的交换机,QUEUE_NAME指定了目标队列名称,null表示没有指定其他属性,message.getBytes()将消息内容转换为字节数组进行传输。
|
| | | channel.basicPublish("", QUEUE_NAME, null, message.getBytes());
|
| | | System.out.println(" [x] Sent '" + message + "'");
|
| | |
|
| | | // DownGlassInfo downGlassInfo = new DownGlassInfo();
|
| | | // downGlassInfo.setId(1);
|
| | | // System.out.println(" id'" + downGlassInfo.getId() + "'");
|
| | | }
|
| | | }
|
| | | }
|