channel.basicQos(prefetchCount);
@Override public void basicQos(int prefetchSize, int prefetchCount, boolean global) throws IOException { this.delegate.basicQos(prefetchSize, prefetchCount, global); }
/** * Added to the 3.3.x client. * @since 1.3.3 */ @Override public void basicQos(int prefetchCount, boolean global) throws IOException { this.delegate.basicQos(prefetchCount, global); }
/** * Added to the 3.3.x client. * @since 1.3.3 */ @Override public void basicQos(int prefetchCount, boolean global) throws IOException { this.delegate.basicQos(prefetchCount, global); }
@Override public void basicQos(int prefetchSize, int prefetchCount, boolean global) throws IOException { this.delegate.basicQos(prefetchSize, prefetchCount, global); }
@Override public void basicQos(int prefetchCount) throws IOException { this.delegate.basicQos(prefetchCount); }
@Override public void basicQos(int prefetchCount) throws IOException { this.delegate.basicQos(prefetchCount); }
@Override public void basicQos(int prefetchCount) throws IOException { delegate.basicQos(prefetchCount); } }
private boolean setQoS() { try { channel.basicQos(prefetchCount); } catch (IOException ex) { logger.error("Error setting QoS prefetching: {}", ex); return false; } return true; }
@Override public void basicQos(int prefetchSize, int prefetchCount, boolean global, Handler<AsyncResult<Void>> resultHandler) { forChannel(resultHandler, channel -> { channel.basicQos(prefetchSize, prefetchCount, global); return null; }); }
private Channel createChannel(Connection connection, Properties properties) throws IOException { Channel channel = connection.createChannel(); String prefetchProperty = PREFETCH_SIZE.readFrom(properties); int prefetchSize = prefetchProperty == null || prefetchProperty.isEmpty() ? DEFAULT_PREFETCH_SIZE : parseInt(prefetchProperty); LOG.info("Prefetch size of queue is set to {}", prefetchSize); channel.basicQos(prefetchSize); return channel; }
private void reconnect() throws IOException, TimeoutException { Visage.log.info("Connecting to RabbitMQ at "+config.getString("rabbitmq.host")+":"+config.getInt("rabbitmq.port")); conn = factory.newConnection(); channel = conn.createChannel(); if (Visage.debug) Visage.log.finer("Setting up queue '"+queue+"'"); channel.queueDeclare(queue, false, false, true, null); int qos = config.getInt("qos"); if (qos != -1) { channel.basicQos(qos); } }
public MQReceiver(String host, int port, String queue_name, int qos) throws IOException, TimeoutException { super(host, port, queue_name); channel.basicQos(qos); consumer = new QueueingConsumer(channel); channel.basicConsume(queue_name, false, consumer); }
Channel createRabbitChannel(boolean transactional) throws IOException { Channel channel = this.rabbitConnection.createChannel(); if(this.channelsQos != NO_CHANNEL_QOS) { channel.basicQos(channelsQos); } if (transactional) { channel.txSelect(); } return channel; }
public void StartConsumer() { try { channel = connection.createChannel(); channel.basicQos(1); consumer = new ActualConsumer(channel); consumerTag = channel.basicConsume(Constants.queue, false, consumer); } catch (IOException e) { e.printStackTrace(); } }
@RabbitHandler() @RabbitListener(bindings = @QueueBinding( value = @Queue(value = "order-queue", durable = "true"), exchange = @Exchange(name = "order-exchange", durable = "true", type = "topic"), key = "order.*" )) public void onOrderMessage(@Payload TOrder order, @Headers Map<String, Object> headers, Channel channel) throws Exception { //消费者操作 channel.basicQos(1); log.info("收到消息开始消费,订单编号:{}",order.getId()); Long deliveryTag = (Long) headers.get(AmqpHeaders.DELIVERY_TAG); channel.basicAck(deliveryTag, false); }
@Override protected void doResponse(String address, Consumer<String> consumer) { Channel channel = rabbitAdapter.getConnection().createChannel(false); try { channel.queueDeclare(address, true, false, false, null); channel.basicQos(1); channel.basicConsume(address, false, getDefaultConsumer(channel, address, consumer)); } catch (IOException e) { logger.error("[MQ] Rabbit response error.", e); } }
public static void main(String[] args) throws Exception { Channel channel = AMQPCommon.connect(); QueueingConsumer consumer = new QueueingConsumer(channel); channel.basicQos(1); channel.basicConsume("trade.eq.q", false, consumer); while (true) { QueueingConsumer.Delivery msg = consumer.nextDelivery(); Thread.sleep(2000); System.out.println("Trade placed: " + new String(msg.getBody())); channel.basicAck(msg.getEnvelope().getDeliveryTag(), false); } } }
public void subscribeWithTopic(String topic, String routingKey, String queueName, Consumer<String> consumer) { Channel channel = rabbitAdapter.getConnection().createChannel(false); try { channel.queueDeclare(queueName, true, false, false, null); channel.exchangeDeclare(topic, BuiltinExchangeType.TOPIC, true); channel.queueBind(queueName, topic, routingKey); channel.basicQos(1); channel.basicConsume(queueName, false, getDefaultConsumer(channel, topic, consumer)); } catch (IOException e) { logger.error("[MQ] Rabbit subscribeWithTopic error.", e); } }
@Override protected void doSubscribe(String topic, Consumer<String> consumer) { Channel channel = rabbitAdapter.getConnection().createChannel(false); try { channel.exchangeDeclare(topic, "fanout", true); String queueName = channel.queueDeclare().getQueue(); channel.queueBind(queueName, topic, ""); channel.basicQos(1); channel.basicConsume(queueName, false, getDefaultConsumer(channel, topic, consumer)); } catch (IOException e) { logger.error("[MQ] Rabbit response error.", e); } }