- 浏览: 853896 次
文章分类
- 全部博客 (365)
- java (124)
- spring mvc (21)
- spring (22)
- struts2 (6)
- jquery (27)
- javascript (24)
- mybatis/ibatis (8)
- hibernate (7)
- compass (11)
- lucene (26)
- flex (0)
- actionscript (0)
- webservice (8)
- rabbitMQ/Socket (15)
- jsp/freemaker (5)
- 数据库 (27)
- 应用服务器 (21)
- Hadoop (1)
- PowerDesigner (3)
- EJB (0)
- JPA (0)
- PHP (2)
- C# (0)
- .NET (0)
- html (2)
- xml (5)
- android (7)
- flume (1)
- zookeeper (0)
- 证书加密 (2)
- maven (1)
- redis (2)
- cas (11)
最新评论
-
zuxianghuang:
通过pom上传报错 Artifact upload faile ...
nexus上传了jar包.通过maven引用当前jar,不能取得jar的依赖 -
流年末年:
百度网盘的挂了吧???
SSO单点登录系列3:cas-server端配置认证方式实践(数据源+自定义java类认证) -
953434367:
UfgovDBUtil 是什么类
Java发HTTP POST请求(内容为xml格式) -
smilease:
帮大忙了,非常感谢
freemaker自动生成源代码 -
syd505:
十分感谢作者无私的分享,仔细阅读后很多地方得以解惑。
Nginx 反向代理、负载均衡、页面缓存、URL重写及读写分离详解
rabbitmq java api 关于消息处理的一个重要的类是channel
channel 主要进行相关定义,发送消息,获取消息,事务处理等。
channel可以在多线程中使用,但是在任何时候保证只有一个线程执行命令是很重要的,这在前面 rabbitmq 学习-6-rabbitmq基础 已经说的很清楚了。
public interface Channel extends ShutdownNotifier {
// 重新得到channel number
int getChannelNumber();
//得到当前channel的connection
Connection getConnection();
//关闭 channel,closeCode=com.rabbitmq.client.AMQP#REPLY_SUCCESS,closeMessage='OK'
void close() throws IOException;
//指定code和message关闭channel
void close(int closeCode, String closeMessage) throws IOException;
//中止 channel,closeCode=com.rabbitmq.client.AMQP#REPLY_SUCCESS,closeMessage='OK'
//此操作中的所有异常将被丢弃
void abort() throws IOException;
//指定code和message中止channel
//此操作中的所有异常将被丢弃
void abort(int closeCode, String closeMessage) throws IOException;
//得到当前channel的ReturnListener
ReturnListener getReturnListener();
//设置当前channel的ReturnListener
void setReturnListener(ReturnListener listener);
/**
* Request specific "quality of service" settings.
*
* These settings impose limits on the amount of data the server
* will deliver to consumers before requiring the receipt of
* acknowledgements.
* Thus they provide a means of consumer-initiated flow control.
* @see com.rabbitmq.client.AMQP.Basic.Qos
* @param prefetchSize maximum amount of content (measured in
* octets) that the server will deliver, 0 if unlimited
* @param prefetchCount maximum number of messages that the server
* will deliver, 0 if unlimited
* @param global true if the settings should be applied to the
* entire connection rather than just the current channel
* @throws java.io.IOException if an error is encountered
*/
void basicQos(int prefetchSize, int prefetchCount, boolean global) throws IOException;
/**
* Request a specific prefetchCount "quality of service" settings
* for this channel.
*
* @see #basicQos(int, int, boolean)
* @param prefetchCount maximum number of messages that the server
* will deliver, 0 if unlimited
* @throws java.io.IOException if an error is encountered
*/
void basicQos(int prefetchCount) throws IOException;
//发送消息,"mandatory" and "immediate" 都是 false
void basicPublish(String exchange, String routingKey, BasicProperties props, byte[] body) throws IOException;
/**
* 发送消息
* @param exchange名称
* @param routingKey名称
* @param mandatory 是否强制发送
* @param immediate 是否立即发送
* @param props other properties for the message - routing headers etc
* @param body 消息
* @throws java.io.IOException if an error is encountered
*/
void basicPublish(String exchange, String routingKey, boolean mandatory, boolean immediate, BasicProperties props, byte[] body)
throws IOException;
/**
* 删除exchange,不管是否在使用
* @param exchange名称
* @return a deletion-confirm method to indicate the exchange was successfully deleted
* @throws java.io.IOException if an error is encountered
*/
Exchange.DeleteOk exchangeDelete(String exchange) throws IOException;
/**
* 删除exchange
* @param exchange名称
* @param ifUnused 设置是否只删除没有使用的
* @return a deletion-confirm method to indicate the exchange was successfully deleted
* @throws java.io.IOException if an error is encountered
*/
Exchange.DeleteOk exchangeDelete(String exchange, boolean ifUnused) throws IOException;
/**
* 定义exchange,non-autodelete, non-durable
* @param exchange名称
* @param exchange类型
* @return a deletion-confirm method to indicate the exchange was successfully deleted
* @throws java.io.IOException if an error is encountered
*/
Exchange.DeclareOk exchangeDeclare(String exchange, String type) throws IOException;
/**
* 定义exchange,non-autodelete
* @param exchange名称
* @param exchange类型
* @param durable 是否持续存在(持续存在,即使server重启也会存在)
* @throws java.io.IOException if an error is encountered
* @return a declaration-confirm method to indicate the exchange was successfully declared
*/
Exchange.DeclareOk exchangeDeclare(String exchange, String type, boolean durable) throws IOException;
/**
* 定义exchange
* @param exchange名称
* @param exchange类型
* @param passive true if we are passively declaring a exchange (asserting the exchange already exists)
* @param durable 是否持续存在(持续存在,即使server重启也会存在)
* @param autoDelete 是否自动删除,自动删除-server会在它不在使用的时候将其删除
* @param arguments other properties (construction arguments) for the exchange
* @return a declaration-confirm method to indicate the exchange was successfully declared
* @throws java.io.IOException if an error is encountered
*/
Exchange.DeclareOk exchangeDeclare(String exchange, String type, boolean passive, boolean durable, boolean autoDelete,
Map<String, Object> arguments) throws IOException;
/**
* 定义一个queue,由server去命名,exclusive, autodelete, non-durable
* @return a declaration-confirm method to indicate the exchange was successfully declared
* @throws java.io.IOException if an error is encountered
*/
Queue.DeclareOk queueDeclare() throws IOException;
/**
* 定义一个queue,non-exclusive, non-autodelete, non-durable
* @param queue 名称
* @return a declaration-confirm method to indicate the queue was successfully declared
* @throws java.io.IOException if an error is encountered
*/
Queue.DeclareOk queueDeclare(String queue) throws IOException;
/**
* 定义一个queue,non-exclusive, non-autodelete
* @param queue 名称
* @param durable 是否持续存在(true:server重启也会存在)
* @return a declaration-confirm method to indicate the exchange was successfully declared
* @throws java.io.IOException if an error is encountered
*/
Queue.DeclareOk queueDeclare(String queue, boolean durable) throws IOException;
/**
* 定义一个queue
* @param queue 名称
* @param passive true if we are passively declaring a queue (asserting the queue already exists)
* @param durable 是否持续存在
* @param exclusive true if we are declaring an exclusive queue
* @param autoDelete 是否自动删除,true:不在使用了server将会自动删除它
* @param arguments other properties (construction arguments) for the queue
* @return a declaration-confirm method to indicate the queue was successfully declared
* @throws java.io.IOException if an error is encountered
*/
Queue.DeclareOk queueDeclare(String queue, boolean passive, boolean durable, boolean exclusive, boolean autoDelete,
Map<String, Object> arguments) throws IOException;
/**
* 删除queue,不管它是否在使用
* @param queue 名称
* @return a deletion-confirm method to indicate the queue was successfully deleted
* @throws java.io.IOException if an error is encountered
*/
Queue.DeleteOk queueDelete(String queue) throws IOException;
/**
* 删除queue
* @param queue 名称
* @param ifUnused 是否只删除没有被使用的queue
* @param ifEmpty 是否只删除消息是空的queue
* @return a deletion-confirm method to indicate the queue was successfully deleted
* @throws java.io.IOException if an error is encountered
*/
Queue.DeleteOk queueDelete(String queue, boolean ifUnused, boolean ifEmpty) throws IOException;
/**
* 使用routingKey将queue绑定到exchange上
* @param queue 名称
* @param exchange the name of the exchange
* @param routingKey the routine key to use for the binding
* @return a binding-confirm method if the binding was successfully created
* @throws java.io.IOException if an error is encountered
*/
Queue.BindOk queueBind(String queue, String exchange, String routingKey) throws IOException;
/**
* 使用routingKey将queue绑定到exchange上,带参数
* @param queue the name of the queue
* @param exchange the name of the exchange
* @param routingKey the routine key to use for the binding
* @param arguments other properties (binding parameters)
* @return a binding-confirm method if the binding was successfully created
* @throws java.io.IOException if an error is encountered
*/
Queue.BindOk queueBind(String queue, String exchange, String routingKey, Map<String, Object> arguments) throws IOException;
/**
* 解除绑定
* @param queue the name of the queue
* @param exchange the name of the exchange
* @param routingKey the routine key to use for the binding
* @return an unbinding-confirm method if the binding was successfully deleted
* @throws java.io.IOException if an error is encountered
*/
Queue.UnbindOk queueUnbind(String queue, String exchange, String routingKey) throws IOException;
/**
* 解除绑定,带参数
* @param queue the name of the queue
* @param exchange the name of the exchange
* @param routingKey the routine key to use for the binding
* @param arguments other properties (binding parameters)
* @return an unbinding-confirm method if the binding was successfully deleted
* @throws java.io.IOException if an error is encountered
*/
Queue.UnbindOk queueUnbind(String queue, String exchange, String routingKey, Map<String, Object> arguments) throws IOException;
/**
* Purges the contents of the given queue and awaits a completion.
* @see com.rabbitmq.client.AMQP.Queue.Purge
* @see com.rabbitmq.client.AMQP.Queue.PurgeOk
* @param queue the name of the queue
* @return a purge-confirm method if the purge was executed succesfully
* @throws java.io.IOException if an error is encountered
*/
Queue.PurgeOk queuePurge(String queue) throws IOException;
/**
* Purges the contents of the given queue.
* @see com.rabbitmq.client.AMQP.Queue.Purge
* @see com.rabbitmq.client.AMQP.Queue.PurgeOk
* @param queue the name of the queue
* @param nowait whether to await completion of the purge
* @return a purge-confirm method if the purge was executed succesfully
* @throws java.io.IOException if an error is encountered
*/
Queue.PurgeOk queuePurge(String queue, boolean nowait) throws IOException;
/**
* 从queue上取消息
* @param queue the name of the queue
* @param noAck true if no handshake is required
* @return a {@link GetResponse} containing the retrieved message data
* @throws java.io.IOException if an error is encountered
*/
GetResponse basicGet(String queue, boolean noAck) throws IOException;
/**
* Acknowledge one or several received
* messages. Supply the deliveryTag from the {@link com.rabbitmq.client.AMQP.Basic.GetOk}
* or {@link com.rabbitmq.client.AMQP.Basic.Deliver} method
* containing the received message being acknowledged.
* @see com.rabbitmq.client.AMQP.Basic.Ack
* @param deliveryTag the tag from the received {@link com.rabbitmq.client.AMQP.Basic.GetOk} or {@link com.rabbitmq.client.AMQP.Basic.Deliver}
* @param multiple true if we are acknowledging multiple messages with the same delivery tag
* @throws java.io.IOException if an error is encountered
*/
void basicAck(long deliveryTag, boolean multiple) throws IOException;
/**
* Start a non-nolocal, non-exclusive consumer, with
* explicit acknowledgements required and a server-generated consumerTag.
* @param queue the name of the queue
* @param callback an interface to the consumer object
* @return the consumerTag generated by the server
* @throws java.io.IOException if an error is encountered
* @see com.rabbitmq.client.AMQP.Basic.Consume
* @see com.rabbitmq.client.AMQP.Basic.ConsumeOk
* @see #basicAck
* @see #basicConsume(String,boolean, String,boolean,boolean, Consumer)
*/
String basicConsume(String queue, Consumer callback) throws IOException;
/**
* Start a non-nolocal, non-exclusive consumer, with
* a server-generated consumerTag.
* @param queue the name of the queue
* @param noAck true if no handshake is required
* @param callback an interface to the consumer object
* @return the consumerTag generated by the server
* @throws java.io.IOException if an error is encountered
* @see com.rabbitmq.client.AMQP.Basic.Consume
* @see com.rabbitmq.client.AMQP.Basic.ConsumeOk
* @see #basicConsume(String,boolean, String,boolean,boolean, Consumer)
*/
String basicConsume(String queue, boolean noAck, Consumer callback) throws IOException;
/**
* Start a non-nolocal, non-exclusive consumer.
* @param queue the name of the queue
* @param noAck true if no handshake is required
* @param consumerTag a client-generated consumer tag to establish context
* @param callback an interface to the consumer object
* @return the consumerTag associated with the new consumer
* @throws java.io.IOException if an error is encountered
* @see com.rabbitmq.client.AMQP.Basic.Consume
* @see com.rabbitmq.client.AMQP.Basic.ConsumeOk
* @see #basicConsume(String,boolean, String,boolean,boolean, Consumer)
*/
String basicConsume(String queue, boolean noAck, String consumerTag, Consumer callback) throws IOException;
/**
* Start a consumer. Calls the consumer's {@link Consumer#handleConsumeOk}
* method before returning.
* @param queue the name of the queue
* @param noAck true if no handshake is required
* @param consumerTag a client-generated consumer tag to establish context
* @param noLocal flag set to true unless server local buffering is required
* @param exclusive true if this is an exclusive consumer
* @param callback an interface to the consumer object
* @return the consumerTag associated with the new consumer
* @throws java.io.IOException if an error is encountered
* @see com.rabbitmq.client.AMQP.Basic.Consume
* @see com.rabbitmq.client.AMQP.Basic.ConsumeOk
*/
String basicConsume(String queue, boolean noAck, String consumerTag, boolean noLocal, boolean exclusive, Consumer callback) throws IOException;
/**
* Cancel a consumer. Calls the consumer's {@link Consumer#handleCancelOk}
* method before returning.
* @param consumerTag a client- or server-generated consumer tag to establish context
* @throws java.io.IOException if an error is encountered
* @see com.rabbitmq.client.AMQP.Basic.Cancel
* @see com.rabbitmq.client.AMQP.Basic.CancelOk
*/
void basicCancel(String consumerTag) throws IOException;
/**
* Ask the broker to resend unacknowledged messages. In 0-8
* basic.recover is asynchronous; in 0-9-1 it is synchronous, and
* the new, deprecated method basic.recover_async is asynchronous.
* To avoid this API changing, this is named for the latter, and
* will be deprecated.
* @param requeue If true, messages will be requeued and possibly
* delivered to a different consumer. If false, messages will be
* redelivered to the same consumer.
*/
void basicRecoverAsync(boolean requeue) throws IOException;
/**
* 启用事务模式
* @return a transaction-selection method to indicate the transaction was successfully initiated
* @throws java.io.IOException if an error is encountered
*/
Tx.SelectOk txSelect() throws IOException;
/**
* 提交事务
* @return a transaction-commit method to indicate the transaction was successfully committed
* @throws java.io.IOException if an error is encountered
*/
Tx.CommitOk txCommit() throws IOException;
/**
* 回流事务
* @return a transaction-rollback method to indicate the transaction was successfully rolled back
* @throws java.io.IOException if an error is encountered
*/
Tx.RollbackOk txRollback() throws IOException;
}
发表评论
-
rabbitmq 学习-14- 官方rabbitmq+spring进行远程接口调用
2012-07-07 09:08 3794到http://github.com/momania/spri ... -
rabbitmq 学习-13- 发送接收消息示例-2
2012-07-06 17:17 1757Basic RPC As a programming con ... -
rabbitmq 学习-12- 发送接收消息示例-1
2012-07-06 17:17 14456这里是同步发送消息,异步接收消息接收有两种方式:http:// ... -
rabbitmq 学习-积累
2012-07-06 17:17 13441,temporary queue(由server自动命名)在 ... -
rabbitmq 学习-11- 几个发送接收消息的重要类
2012-07-06 17:17 16761,ChannelbasicPublish() 用来发送消息, ... -
rabbitmq 学习-9- RpcClient发送消息和同步接收消息原理
2012-06-30 16:44 3059本身使用RpcClient发送消息与同步接收消息的代码是很 ... -
rabbitmq 学习-8- Exchange Queue RoutingKey关系说明
2012-06-30 16:44 3121String queue = channel.queueDec ... -
rabbitmq 学习-7-rabbitmq 支持场景
2012-06-30 16:43 1269What messaging scenarios are su ... -
rabbitmq 学习-6-rabbitmq基础
2012-06-30 16:43 1753rabbitmq的中文资料真少,和同事lucas经过两周的 ... -
rabbitmq 学习-4-初试2
2012-06-29 14:32 1079RpcClient,RpcServer同步发送接收消息Chan ... -
rabbitmq 学习-3-初试1
2012-06-29 14:32 1063本例是一个简单的异步 ... -
rabbitmq 学习-1-AMQP介绍
2012-06-29 14:30 1393Windows 1,下载下载erlang:erlang. ... -
rabbitmq学习1:hello world
2012-06-29 14:27 1372rabbitMQ是一个在AMQP基础上完整的,可服用的企业消息 ... -
rabbitmq操作命令
2012-06-14 13:54 201581.必需掌握的指令 添加用户: ...
相关推荐
3. 通过 `Connection` 创建 `Channel` 通道,这是与 RabbitMQ 进行交互的主要接口。 4. 声明队列,定义其属性,如是否持久化。 5. 发布消息到指定的交换机,指定路由键。 这只是 RabbitMQ 的基本概念和安装过程,...
在这个“rabbitmq学习笔记.zip”压缩包中,我们可以期待找到一系列关于RabbitMQ的核心概念、安装教程、使用方法以及常见问题的详细说明。 首先,RabbitMQ的基本概念包括生产者(Producer)、消费者(Consumer)、...
每个库都有详细的文档说明如何连接到RabbitMQ服务器,创建通道,声明交换机和队列,以及发送和接收消息。 ### 五、RabbitMQ工作模式 1. **Direct模式**:最简单的模式,消息基于精确匹配的路由键路由到队列。 2. *...
为了更深入地学习RabbitMQ,你可以阅读给定的博客链接:[https://blog.csdn.net/u010476739/article/details/115842114](https://blog.csdn.net/u010476739/article/details/115842114),那里可能提供了更多关于...
消息队列如RabbitMQ、Apache Qpid或ActiveMQ等通常使用AMQP协议,它们作为中间件,接收、存储并转发消息。`amqp_connection`库使得Python程序能够轻松地连接到这些消息队列服务,进行生产者(发送消息)和消费者...
- **NIO(New IO)**:解释NIO的基本概念,包括通道(Channel)、缓冲区(Buffer)等,并讨论其适用场景。 - **Java9改进**:比较Java9与Java8的主要差异,重点介绍新特性及优化点。 - **HashMap内部结构**:详解...
10. **分布式系统**:了解分布式服务框架(如Dubbo、Spring Cloud)、消息队列(如RabbitMQ、Kafka)、缓存(如Redis)、分布式一致性(如Zookeeper、Raft、Paxos)等。 11. **微服务架构**:理解微服务的基本理念...
它的并发模型基于CSP(Communicating Sequential Processes)理论,通过goroutine和channel实现轻量级线程和数据同步。 接着,我们要了解beego框架。beego提供了一种快速开发Web应用的方式,其核心设计思想是 MVC...
每个项目文件夹内的说明文件将详细解释如何运行和理解这些示例,从而帮助开发者更好地理解和应用RabbitMQ在C#项目中的功能。通过逐步学习和实践这些示例,你将能够熟练地在你的C#应用程序中使用RabbitMQ进行高效的...
以下是对其中主要知识点的详细说明: 1. **JVM(Java虚拟机)**:JVM是Java程序运行的基础,它负责解析.class文件,执行字节码,并管理内存。理解JVM的工作原理,包括类加载机制、内存模型(堆、栈、方法区、本地...
5. 性能优化:Beego 使用了 Go 语言的并发特性,通过 goroutine 和 channel 实现高效的并发处理,提高了 Web 应用的响应速度。 6. 错误处理和日志系统:Beego 内置了错误处理机制和日志模块,方便开发者追踪和调试...
以下是对这些高新技术的详细说明: 1. **多线程编程**:Java以其强大的多线程支持而闻名。通过实现Runnable接口或继承Thread类,开发者可以创建并运行多个线程来实现并发执行。线程同步机制如synchronized关键字、...