前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >解决java RabbitMQ初次启动发送端basicPublish阻塞问题

解决java RabbitMQ初次启动发送端basicPublish阻塞问题

作者头像
算法与编程之美
发布2019-07-17 18:04:59
1.9K0
发布2019-07-17 18:04:59
举报

欢迎点击「算法与编程之美」↑关注我们!

本文首发于微信公众号:"算法与编程之美",欢迎关注,及时了解更多此系列文章

作者|olive

来源|

https://blog.csdn.net/asd1098626303/article/details/77849562

发送端代码如下

public class SendClient { private final static String QUEUE_NAME = "hello"; public static void main(String[] args) throws IOException, TimeoutException { ConnectionFactory factory = new ConnectionFactory(); factory.setHost("localhost"); Connection connection = factory.newConnection(); Channel channel = connection.createChannel(); channel.queueDeclare(QUEUE_NAME,false,false,false,null); String message = "Hello World"; System.out.println("发送前"); channel.basicPublish("",QUEUE_NAME,null,message.getBytes()); System.out.println("send Message: "+message); channel.close(); connection.close(); } }

最开始的时候一直会在channel.queueDeclare 这地方阻塞,官网上给了个解决办法:

http://www.rabbitmq.com/tutorials/tutorial-one-java.html

Sending doesn't work!

If this is your first time using RabbitMQ and you don't see the "Sent" message then you may be left scratching your head wondering what could be wrong. Maybe the broker was started without enough free disk space (by default it needs at least 200 MB free) and is therefore refusing to accept messages. Check the broker logfile to confirm and reduce the limit if necessary. The configuration file documentation will show you how to set disk_free_limit.

只需要修改下RabbitMQ的配置文件即可,默认位置在AppDate%\RabbitMQ 下的rabbitmq.config。

[{rabbit, [{disk_free_limit, "500MB"}]}].

disk_free_limit增加到500M即可,然后重启服务即可。

拓展阅读:

深入理解遗传算法(一)

深入理解遗传算法(二)

从1到100求和学算法思维(一)

从1到100求和学算法思维(二)

从1到100求和学算法思维(三)

从1到100求和学算法思维(四)

从1到100求和学算法思维(五)

从1到100求和学算法思维(六)

where2go 团队


微信号:算法与编程之美

温馨提示:点击页面右下角“写留言”发表评论,期待您的参与!期待您的转发!

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2019-05-15,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 算法与编程之美 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档