RabbitMQ-技术调研
来源:互联网 发布:java dos 运行命令 编辑:程序博客网 时间:2024/06/06 05:41
- CMD:
/opt/apps/rabbitmq/sbin/rabbitmq-server –detached
/opt/apps/rabbitmq/sbin/rabbitmqctl stop
- web:
http://10.11.156.226:15672/
- FAQ:
( java, rabbitmq-client-3.3.5.jar )
import java.io.IOException;
import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.DefaultConsumer;
import com.rabbitmq.client.Envelope;
public class JmsRecvMain {
public void receive(String[] argv) throws java.io.IOException, java.lang.InterruptedException {
ConnectionFactory factory = new ConnectionFactory();
factory.setHost(JmsUtils.AMMQ_HOST);
factory.setAutomaticRecoveryEnabled(true);
factory.setNetworkRecoveryInterval(10000);
Connection connection = factory.newConnection();
final Channel channel = connection.createChannel();
channel.queueDeclare(JmsUtils.QUEUE_NAME, false, false, false, null);
System.out.println(" [*] Waiting for messages. To exit press CTRL+C");
boolean autoAck = false;
channel.basicConsume(JmsUtils.QUEUE_NAME, autoAck, "myConsumerTag",
new DefaultConsumer(channel) {
@Override
public void handleDelivery(String consumerTag,
Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
// delivery:Body
String message = new String(body);
System.out.println(" [x] Received '" + message + "'");
// delivery:Envelope
System.out.println(" [x] Received Envelope_DeliveryTag'" + envelope.getDeliveryTag() + "'");
System.out.println(" [x] Received Envelope_Exchange'" + envelope.getExchange() + "'");
System.out.println(" [x] Received Envelope_RoutingKey'"+ envelope.getRoutingKey() + "'");
System.out.println(" [x] Received Envelope_Redeliver'"+ envelope.isRedeliver() + "'");
channel.basicAck(envelope.getDeliveryTag(), false);
}});}
public static void main(String[] args) {
try {
new JmsRecvMain().receive(null);
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}}}
- RabbitMQ-技术调研
- 技术调研
- 文本摘要技术调研
- 服务器相关技术调研
- MQTT技术调研
- 豆瓣技术架构调研
- ios8技术调研
- kafka技术调研
- IOS技术调研
- WebRTC技术调研
- 视频有关“技术调研”
- Akamai CDN技术调研
- SLAM技术调研研究
- NAT技术调研
- 地图js技术调研
- NAT&代理服务器技术调研
- 直播技术调研
- 语音唤醒技术调研
- ajax+JS 实现分页
- Android 四大组件之一:Service后台服务之IntentService
- 通知栏声音的开启与关闭
- 时钟频率、波特率、波特因子关系详解
- 机器学习实战11:使用Apriori算法进行关联分析学习笔记(python)
- RabbitMQ-技术调研
- Session的生命周期
- 单线程与多核
- JAVA检验密码复杂度+随机生成6位密码
- 通过一个命令返回上级多层目录的方法
- JS 获取浏览器窗口大小
- 使用接口的好处
- qq主界面实现(二)-tabHost与fragment配合使用
- Codeforces 350B Resort