rabbitmq.channel方法介绍

RabbitMQ架构篇 - Channel 本文解析RabbitMQ的Channel接口的exchangeDeclare、queueDeclare、queueBind方法以及AMQChannel的伪rpc方法。 阅读详情

rabbitmq.channel参数详解

channel.exchangeDeclare():使用fanout类型创建的交换机

1、type:有direct、fanout、topic三种
2、durable:true、false true:服务器重启会保留下来Exchange。警告:仅设置此选项,不代表消息持久化。即不保证重启后消息还在
3、autoDelete:true、false.true:当已经没有消费者时,服务器是否可以删除该Exchange

Exchange.DeclareOk exchangeDeclare(String exchange, String type, boolean durable, boolean autoDelete,
                                       Map<String, Object> arguments) throws IOException;

chanel.basicQos(): 同一时刻服务器发多少条消息给消费者

1、prefetchSize:0 
2、prefetchCount:会告诉RabbitMQ不要同时给一个消费者推送多于N个消息,即一旦有N个消息还没有ack,则该consumer将block掉,直到有消息ack
3、global:true\false 是否将上面设置应用于channel,简单点说,就是上面限制是channel级别的还是consumer级别

void basicQos(int prefetchSize, int prefetchCount, boolean global) throws IOException;

channel.basicPublish(): 向server发布一条消息

1、routingKey:路由键,#匹配0个或多个单词,*匹配一个单词,在topic exchange做消息转发用
2、mandatory:true:如果exchange根据自身类型和消息routeKey无法找到一个符合条件的queue,那么会调用basic.return方法将消息返还给生产者。false:出现上述情形broker会直接将消息扔掉
3、mmediate:true:如果exchange在将消息route到queue(s)时发现对应的queue上没有消费者,那么这条消息不会放入队列中。当与消息routeKey关联的所有queue(一个或多个)都没有消费者时,该消息会通过basic.return方法返还给生产者。
4、BasicProperties :需要注意的是BasicProperties.deliveryMode,0:不持久化 1:持久化 这里指的是消息的持久化,配合channel(durable=true),queue(durable)可以实现,即使服务器宕机,消息仍然保留
简单来说:mandatory标志告诉服务器至少将该消息route到一个队列中,否则将消息返还给生产者;immediate标志告诉服务器如果该消息关联的queue上有消费者,则马上将消息投递给它,如果所有queue都没有消费者,直接把消息返还给生产者,不用将消息入队列等待消费者了。

void basicPublish(String exchange, String routingKey, boolean mandatory, boolean immediate, BasicProperties props, byte[] body)
            throws IOException;

channel.basicAck(): 消息处理完成,手动确认提交

1、deliveryTag:该消息的index
2、multiple:是否批量.true:将一次性ack所有小于deliveryTag的消息。

void basicAck(long deliveryTag, boolean multiple) throws IOException;

channel.basicConsume(): 消息消费完成确认

1、autoAck:是否自动ack,如果不自动ack,需要使用channel.ack、channel.nack、2、channel.basicReject 进行消息应答

String basicConsume(String queue, boolean autoAck, Consumer callback) throws IOException;

channel.queueDeclare(): 声明一个队列

1、durable:true、false true:在服务器重启时,能够存活
2、exclusive :是否为当前连接的专用队列,在连接断开后,会自动删除该队列,生产环境中应该很少用到吧。
3、autodelete:当没有任何消费者使用时,自动删除该队列。

Queue.DeclareOk queueDeclare(String queue, boolean durable, boolean exclusive, boolean autoDelete,
                                 Map<String, Object> arguments) throws IOException;

channel.queueBind(): 将队列跟交换器进行绑定

1、queue:队列名称
2、exchange:交换机名称
3、routingKey:队列跟交换机绑定的键值
channel.queueBind(queueName, EXCHANGE_NAME, "black");
RabbitMQ 通道(Channel)详解:方法使用、消息确认与拒绝 阅读详情

相关推荐

rabbitmq channel接口常用方法详解

Queue.DeclareOk queueDeclare(String queue, boolean durable, boolean exclusive, boolean autoDelete, Map<String, Object> arguments) throws IOException;解释: 方法作用: 声明一个队列

浪丶荡 9804

[RabbitMQ]基础概念——信道channel

前言: 最近跟着公司一起做项目重构,也有项目用到了MQ。其中用到了死信队列和延迟队列。 先整理一下路由的基础知识,不能只跟着实战,堆代码。 1.channel信道 信道是生产消费者与rabbit通信的渠道,生产者publish或者消费者消费一个队列都是需要通过信道来通信的。 信道是建立在TCP上面的虚拟链接,也就是rabbitMQ在一个TCP上面建立成百上千的信道来达到多个线程处理。 ...

新一的技术笔记 1万+

第14篇 rabbitmq Channel接口源码

上节第13篇写了 ConsumerDispatcher, 查询到使用地方是ChannelN类,如下所示,由于Channel内容比较多就先看一下Channel源码 1、Channel 接口 channel实例不在线程间共享,应用应该一个channel一个线程,如果不是一个channel一个线程,虽然通道上的某些操作可以安全调用,但是同时导致不正确的帧交错,线程间共享通道也会干扰发布者确认 1.1、接口方法 方法名 方法描述 int getChannelNumber 获取通道号 .

往前的娘娘 421

RabbitMq基础篇-09-channel接口常用几种参数详解

为了保证消息从队列可靠地达到消费者, RabbitMQ 提供了消息确认机制( message acknowledgement), 消费者在订阅队列时,可以指定autoAck参数,当autoAck 等于false时,RabbitMQ会等待消费者显式地回复确认信号后才从内存(或者磁盘)中移去消息(实质上是先打上删除标记,之后再删除)。当autoAck 等于true时,RabbitMQ 会自动把发送出去的消息置为确认, 然后从内存(或者磁盘)中删除,而不管消费者是否真正地消费到了这些消息。

Alan0517 1万+

RabbitMQ Channel方法参数详解

这些是RabbitMQ Channel方法的一些常用参数和示例代码。通过使用这些参数,您可以在RabbitMQ中创建队列、交换器,绑定队列到交换器,发送和接收消息。根据您的具体需求,可以调整参数的值以实现所需的功能。RabbitMQ是一个功能强大的消息中间件,用于在应用程序之间传递消息。在RabbitMQ中,Channel是与消息代理进行通信的主要接口。通过Channel,应用程序可以创建、发送和接收消息。本文将详细介绍RabbitMQ Channel方法的各种参数,并提供相应的源代码示例。

VksgShapes的博客 863

Channel shutdown: channel error; protocol method: #method channel.close (rep

文章目录Channel shutdown: channel error; protocol method: #methodChannel shutdown: channel error; protocol method: #method<channel.close>(rep 1、启动springboot 应用报错 Channel shutdown: channel error; pr...

简简单单Onlinezuozuo 5万+

rabbitmq之channel类方法说明

// Copyright (c) 2007-Present Pivotal Software, Inc. All rights reserved. // // This software, the RabbitMQ Java client library, is triple-licensed under the // Mozilla Public License 1.1 ("MPL"), t...

Eflyings的博客 1092

PX4自定义uORB消息与MAVLink消息映射实战:从飞控到QGC地面站完整流程解析

本文详细解析PX4飞控中自定义uORB消息与MAVLink消息映射的完整流程,涵盖从飞控内部消息定义、MAVLink消息创建到QGC地面站接收显示的全链路实践。重点介绍如何使用mavlink inspector工具进行调试,解决版本兼容性和多实例消息处理等常见问题,为无人机开发者提供可靠的实时数据监控方案。

ll5678的博客 1071

RabbitMQ中方法channel.basicAck的使用说明

通过设置multiple参数,可以实现批量确认消息的功能。如果消费者处理消息的速度很快,可以将其设置为true,一次性确认多条消息,提高处理效率。但如果消费者处理消息的速度比较慢,可能会导致消息堆积,造成内存占用过高。因此,在实际使用中需要根据实际情况来确定是否需要批量确认消息。在RabbitMQ中,channel.basicAck方法用于确认已经接收并处理了消息。

liqinglonguo的博客 4835

winget安装提示:执行此命令时发生意外错误: InternetOpenUrl() failed. 0x80072efd

当我们使用Winget包管理器安装应用,提示错误:执行此命令时发生意外错误: InternetOpenUrl() failed. 0x80072efd 该怎么处理呢?请听我娓娓道来。

Linux I Tell U 8154

从末流211到东南软院:一个普通CS学生的保研逆袭全记录(含GPA、竞赛、面试避坑点)

本文详细记录了一位来自末流211院校的CS学生如何通过合理规划和持续努力,成功保研东南大学软件学院的完整历程。文章分享了GPA提升、竞赛策略、夏令营申请和预推免准备等关键环节的实战经验,特别强调了竞赛在弥补科研短板中的重要作用,为普通背景学生提供了可复制的保研逆袭方案。

weixin_33417488的博客 397

rabbitmq-channel方法介绍

// 声明一个队列 -// queue 队列名称 // durable 为true时server重启队列不会消失 (是否持久化) // exclusive 队列是否是独占的,如果为true只能被一个connection使用,其他连接建立时会抛出异常 // autoDelete 当没有任何消费者使用时,自动删除该队列 channel...

不怂,不弱,不退缩,厚积薄发 1215

grpc安装与简单demo测试

grpc安装: 由于工作需要,最近在学google的rpc开源框架;由于本人菜鸟一枚,而且是从Windows开发转到Linux;由于之前版本控制使用的是svn,没有使用过git,所以从GitHub上下载代码是通过浏览器下载zip格式的压缩文件,折腾了好几天了,发现了各种坑,各种缺少库,各种不知道怎么把这个库给装机器上。对于一个不熟悉Linux的人来说,这个体验简直糟糕透了。没办法了又在机器上装了...

old__captain的博客 4837

rabbitmq channel对象的方法

channel.exchangeDeclare() channel.ExchangeDeclare(string exchange: "cjlTest",string type: "direct/topic/header/fanout",bool durable: true); 参数解析: exchange:名称 type:有fanout、direct、topic、header;选择合...

诚的博客 1492

工行聚合支付二维码全流程开发指南:从生成到退款实战解析

本文提供了一份详尽的工行聚合支付二维码开发实战指南。内容涵盖从环境准备、SDK集成到核心功能实现的完整对接流程,包括生成收款二维码(主扫支付)、扫码收款(被扫支付)、订单状态查询以及退款处理,并附有代码实现示例和关键的避坑经验,帮助开发者高效完成支付模块集成。

work3的博客 450

YOLOv11改进 | 上采样篇 | YOLOv11引入DySample轻量级动态上采样器

虽然最近的基于内核的动态上采样器(如CARAFE、FADE和SAPA)的性能提升令人印象深刻,但它们引入了大量工作负载,主要是由于耗时的动态卷积和用于生成动态内核的额外子网。DySample模块的设计旨在解决现有动态上采样器的高计算开销和复杂性问题,同时提供更好的性能和效率。到此本文的正式分享内容就结束了,在这里给大家推荐我的YOLOv11改进有效涨点专栏,本专栏目前为新开的,后期我会根据各种前沿顶会进行论文复现,也会对一些老的改进机制进行补充,如果大家觉得本文帮助到你了,订阅本专栏,关注后续更多的更新~

tsg6698的博客 3134

RabbitMQ - Channel 类主要方法参数详解

Channel 类的方法,如 exchangeDeclare(...)、queueDeclare(...)等方法,均采用了重载的方式。 channel.exchangeDeclare(…) /** * Declare an exchange, via an interface that allows the complete set of * arguments. * @see com.rabbitmq.client.AMQP.Exchange.Declare

virgil 827

动力学约束下的运动规划算法——Kinodynamic RRT*算法

动力学约束下的运动规划算法——Kinodynamic RRT*算法

慕羽★的博客 6761

channel rabbitmq 配置_rabbitmq channel方法参数详解

1 Queue.Declareok queueDeclare(String queue, boolean durable, boolean exclusive, boolean autoDelete, Map arguments)queue:routingKey,即队列的名称durable:true/false,是否支持持久化exclusive:true/false,排他队列,表示是否只能被一个消...

weixin_30531679的博客 1592

001、NPU是什么?为什么嵌入式设备需要它?

本文通过作者调试工业相机板卡的经历,引出嵌入式设备为何需要NPU(神经网络处理器)的探讨。文章对比了CPU和NPU的设计哲学差异,指出NPU通过专用乘加器阵列和优化的数据流,能高效处理神经网络运算。作者分析了嵌入式设备使用NPU的三大优势:算力提升、功耗降低和实时性保障,并介绍了三类常见NPU形态。通过一个YOLOv5模型调试案例,揭示了NPU使用中的常见陷阱,最后给出五条实用建议,强调理解NPU原理和局限的重要性。文章生动展现了NPU在嵌入式AI应用中的关键作用。

m0_50546716的博客 130

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

rabbitmq channel方法参数详解

1 Queue.Declareok queueDeclare(String queue, boolean durable, boolean exclusive, boolean autoDelete, Map<String, Object> arguments)   queue:routingKey,即队列的名称   durable:true/false,是否支持持久化   e...

weixin_30660027的博客 424

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

RabbitMQ从零开始学(二)通信模型之HelloWorld型—channel方法参数详解

导包,编写工具类,编写生产者,编写消费者, 测试。 channel参数详解 channel.basicPublish() channel.queueDeclare() channel.basicAck() channel.basicConsume() 含义:生产者将消息发送到队列,然后队列将这个消息发送给消费者 代码实现

孔明的博客 910

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

RabbitMQ中客户端的Channel类里各方法释义

// The contents of this file are subject to the Mozilla Public License // Version 1.1 (the "License"); you may not use this file except in // compliance with the License. You may obtain a ...

dayou7738的博客 1279

Springboot集合RabbitMQ运行过程中报错:Channel shutdown: channel error; protocol method解决方法

产生问题背景: 在消息的消费处理逻辑中有手动确认消息的操作: 问题分析: 1、默认情况下 spring-boot-data-amqp 是自动ACK机制,就意味着 MQ 会在消息发送完毕后,自动帮我们去ACK,然后删除消息的信息。 2、消息确认的类型: ...

d20062056的博客 7231
上一篇: java 自定义注解方式 + spring AOP + ExpiringMap 实现限制接口请求次数
下一篇: MySQL以逗号隔开的字符串查询方式整理
Java_ESS
博客等级 码龄7年 97粉丝 25原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址