类 MQPool

java.lang.Object
cn.myafx.rabbitmq.MQPool
所有已实现的接口:
IMQPool, AutoCloseable

public class MQPool extends Object implements IMQPool
  • 构造器详细资料

    • MQPool

      public MQPool(String hostName, Integer port, String userName, String password, String virtualHost, Integer maxPushPool, Integer networkRecoveryInterval, String clientName, IJsonMapper mapper) throws Exception
      mq 应用池
      参数:
      hostName - mq服务器
      port - mq端口 5672
      userName - 登录账号
      password - 密码
      virtualHost - virtualHost, 默认 /
      maxPushPool - push池大小, 默认 3
      networkRecoveryInterval - networkRecoveryInterval, 默认 15
      clientName - clientName
      mapper - mapper
      抛出:
      Exception - Exception
  • 方法详细资料

    • setExceptionHander

      public void setExceptionHander(ISubException hander)
      异常回调
      指定者:
      setExceptionHander 在接口中 IMQPool
      参数:
      hander - hander
    • isOpen

      public boolean isOpen()
      Returns true if the connection is still in a state where it can be used. Identical to checking if RabbitMQ.Client.IConnection.CloseReason equal null.
      指定者:
      isOpen 在接口中 IMQPool
      返回:
      boolean
    • getHeartbeat

      public int getHeartbeat()
      The current heartbeat setting for this connection (0 for disabled). second
      指定者:
      getHeartbeat 在接口中 IMQPool
      返回:
      int
    • exchangeDeclare

      public void exchangeDeclare(String exchange, String type, Boolean durable, Boolean autoDelete, Map<String,Object> arguments) throws Exception
      定义交换器
      指定者:
      exchangeDeclare 在接口中 IMQPool
      参数:
      exchange - 交换器, 默认 "amq.direct"
      type - 交换器类型, 默认 "direct"
      durable - 是否持久化, 默认true
      autoDelete - 当已经没有消费者时,服务器是否可以删除该Exchange, 默认 false
      arguments - arguments
      抛出:
      Exception - Exception
    • exchangeDeclare

      public void exchangeDeclare(ExchangeConfig config) throws Exception
      定义交换器
      指定者:
      exchangeDeclare 在接口中 IMQPool
      参数:
      config - ExchangeConfig
      抛出:
      Exception - Exception
    • exchangeDeclare

      public void exchangeDeclare(List<ExchangeConfig> configs) throws Exception
      批量定义交换器
      指定者:
      exchangeDeclare 在接口中 IMQPool
      参数:
      configs - ExchangeConfig
      抛出:
      Exception - Exception
    • queueDeclare

      public void queueDeclare(QueueConfig config) throws Exception
      定义队列
      指定者:
      queueDeclare 在接口中 IMQPool
      参数:
      config - QueueConfig
      抛出:
      Exception - Exception
    • queueDeclare

      public void queueDeclare(List<QueueConfig> queues) throws Exception
      批量定义队列
      指定者:
      queueDeclare 在接口中 IMQPool
      参数:
      queues - QueueConfig
      抛出:
      Exception - Exception
    • pub

      public <T> boolean pub(T msg, String routingKey, Integer expire, String exchange, Boolean persistent, Map<String,Object> headers) throws Exception
      发布消息
      指定者:
      pub 在接口中 IMQPool
      类型参数:
      T - T
      参数:
      msg - 消息
      routingKey - routingKey
      expire - 消息过期时间, 秒
      exchange - exchange, 默认 "amq.direct"
      persistent - 消息是否持久化, 默认 false
      headers - headers
      返回:
      boolean
      抛出:
      Exception - QueueConfig
    • pub

      public <T> boolean pub(T msg, PubConfig config, Integer expire, Boolean persistent, Map<String,Object> headers) throws Exception
      发布消息
      指定者:
      pub 在接口中 IMQPool
      类型参数:
      T - T
      参数:
      msg - 消息
      config - 路由配置
      expire - 消息过期时间, 秒
      persistent - 消息是否持久化, 默认 false
      headers - headers
      返回:
      boolean
      抛出:
      Exception - Exception
    • pub

      public <T> boolean pub(List<T> msgList, String routingKey, Integer expire, String exchange, Boolean persistent, Map<String,Object> headers) throws Exception
      发布消息
      指定者:
      pub 在接口中 IMQPool
      类型参数:
      T - T
      参数:
      msgList - 消息
      routingKey - routingKey
      expire - 消息过期时间, 秒
      exchange - exchange, 默认 "amq.direct"
      persistent - 消息是否持久化, 默认 false
      headers - headers
      返回:
      boolean
      抛出:
      Exception - Exception
    • pub

      public <T> boolean pub(List<T> msgList, PubConfig config, Integer expire, Boolean persistent, Map<String,Object> headers) throws Exception
      发布消息
      指定者:
      pub 在接口中 IMQPool
      类型参数:
      T - T
      参数:
      msgList - 消息
      config - 路由配置
      expire - 消息过期时间, 秒
      persistent - 消息是否持久化, 默认 false
      headers - headers
      返回:
      boolean
      抛出:
      Exception - Exception
    • pubDelay

      public <T> boolean pubDelay(T msg, String delayRoutingKey, Integer delay, String exchange, Boolean persistent, Map<String,Object> headers) throws Exception
      发布延迟消息
      指定者:
      pubDelay 在接口中 IMQPool
      类型参数:
      T - T
      参数:
      msg - 消息
      delayRoutingKey - delayRoutingKey
      delay - 延迟时间, 秒
      exchange - exchange, 默认 "amq.direct"
      persistent - 消息是否持久化, 默认 false
      headers - headers
      返回:
      boolean
      抛出:
      Exception - Exception
    • pubDelay

      public <T> boolean pubDelay(T msg, PubConfig config, Integer delay, Boolean persistent, Map<String,Object> headers) throws Exception
      发布延迟消息
      指定者:
      pubDelay 在接口中 IMQPool
      类型参数:
      T - T
      参数:
      msg - 消息
      config - 路由配置
      delay - 延迟时间, 秒
      persistent - 消息是否持久化, 默认 false
      headers - headers
      返回:
      boolean
      抛出:
      Exception - Exception
    • pubDelay

      public <T> boolean pubDelay(List<T> msgList, String delayRoutingKey, Integer delay, String exchange, Boolean persistent, Map<String,Object> headers) throws Exception
      发布延迟消息
      指定者:
      pubDelay 在接口中 IMQPool
      类型参数:
      T - T
      参数:
      msgList - 消息
      delayRoutingKey - delayRoutingKey
      delay - 延迟时间, 秒
      exchange - exchange, 默认 "amq.direct"
      persistent - 消息是否持久化, 默认 false
      headers - headers
      返回:
      boolean
      抛出:
      Exception - Exception
    • pubDelay

      public <T> boolean pubDelay(List<T> msgList, PubConfig config, Integer delay, Boolean persistent, Map<String,Object> headers) throws Exception
      发布延迟消息
      指定者:
      pubDelay 在接口中 IMQPool
      类型参数:
      T - T
      参数:
      msgList - 消息
      config - 路由配置
      delay - 延迟时间, 秒
      persistent - 消息是否持久化, 默认 false
      headers - headers
      返回:
      boolean
      抛出:
      Exception - Exception
    • sub

      public <T> void sub(ISubHander<T> hander, String queue, Boolean autoAck) throws Exception
      消费消息
      指定者:
      sub 在接口中 IMQPool
      类型参数:
      T - T
      参数:
      hander - hander
      queue - queue
      autoAck - 是否自动确认, 默认 false
      抛出:
      Exception - Exception
    • close

      public void close() throws Exception
      close
      指定者:
      close 在接口中 AutoCloseable
      抛出:
      Exception