zoukankan      html  css  js  c++  java
  • 删除一个存在的RabbitMQ队列

    import sys
    
    # pip install kafka-python
    sys.path.append("/usr/local/software/ELK")
    from Util.RabbitMqUtil import *
    queue_Name = 'kafka_queue'
    host = RabbitMq_IP
    creds = pika.PlainCredentials(RabbitMq_User, RabbitMq_Password)
    params = pika.ConnectionParameters(host=RabbitMq_IP,
                                                                           port=int(RabbitMq_Port),
                                                                           virtual_host='/',
                                                                           heartbeat_interval=0,
                                                                           socket_timeout=5,
                                                                           credentials=pika.PlainCredentials(
                                                                               RabbitMq_User, RabbitMq_Password))
    
    
    connection = pika.BlockingConnection(params)
    channel = connection.channel()
    channel.queue_delete(queue=queue_Name)
    connection.close()

     创建一个队列

    import sys
    # pip install kafka-python
    sys.path.append("/usr/local/software/ELK")
    from Util.RabbitMqUtil import *
    queue_Name = 'kafka_queue'
    host = RabbitMq_IP
    creds = pika.PlainCredentials(RabbitMq_User, RabbitMq_Password)
    params = pika.ConnectionParameters(host=RabbitMq_IP,
                                                                           port=int(RabbitMq_Port),
                                                                           virtual_host='/',
                                                                           heartbeat_interval=0,
                                                                           socket_timeout=5,
                                                                           credentials=pika.PlainCredentials(
                                                                               RabbitMq_User, RabbitMq_Password))
    
    connection = pika.BlockingConnection(params)
    channel = connection.channel()
    channel.queue_declare(queue=queue_Name)    #声明队列以向其发送消息消息
    #channel.basic_publish(exchange='', routing_key='test', body='Hello World!')  #注意当未定义exchange时,routing_key需和queue的值保持一致
    #print('send success msg to rabbitmq')
    connection.close()   #关闭连接
  • 相关阅读:
    HDU2045_LELE的RPG难题
    HDU2050_折线分割平面数
    HDU1159_最长公共子序列
    ASP.NET 页生命周期概述
    Hadoop编译
    .Hadoop NameNode单点问题解决方案之二 AvatarNode 部署
    Pig调试环境
    HADOOP综合应用架构之一 配置Secondarynamenode在另一台机器运行
    JAVA采用远程连接Hive
    Windows Server 2003 FTP服务器配置详解
  • 原文地址:https://www.cnblogs.com/littlehb/p/9275521.html
Copyright © 2011-2022 走看看