要了解 connection 和 session 的概念,可以先从 ConnectionState 和 SessionState 入手:

// 省略部分代码
public class ConnectionState {
ConnectionInfo info;
private final ConcurrentHashMap<TransactionId, TransactionState> transactions = new ConcurrentHashMap<TransactionId, TransactionState>();
private final ConcurrentHashMap<SessionId, SessionState> sessions = new ConcurrentHashMap<SessionId, SessionState>();
private final List<DestinationInfo> tempDestinations = Collections.synchronizedList(new ArrayList<DestinationInfo>());
private final AtomicBoolean shutdown = new AtomicBoolean(false);
private boolean connectionInterruptProcessingComplete = true;
private HashMap<ConsumerId, ConsumerInfo> recoveringPullConsumers; public ConnectionState(ConnectionInfo info) {
this.info = info;
// Add the default session id.
addSession(new SessionInfo(info, -1));
}
}

从代码可以看出,连接里有事务集合、会话集合、临时队列集合等,这说明:
1. 事务属于一个连接; 2. 会话属于一个连接; 3. 临时队列的生存期是连接的有效期

// 省略部分代码
public class SessionState {
final SessionInfo info; private final Map<ProducerId, ProducerState> producers = new ConcurrentHashMap<ProducerId, ProducerState>();
private final Map<ConsumerId, ConsumerState> consumers = new ConcurrentHashMap<ConsumerId, ConsumerState>();
private final AtomicBoolean shutdown = new AtomicBoolean(false); public SessionState(SessionInfo info) {
this.info = info;
}
}

从上面能看出,producer 和 consumer 是属于某个会话的,producer 和 consumer 都有唯一的 ID 。

// 省略部分代码
public class ProducerState {
final ProducerInfo info;
private TransactionState transactionState;
} public class ConsumerState {
final ConsumerInfo info;
}

ProducerState 和 ConsumerState 只是做了简单的封装。

其中 ConnectionInfo, SessionInfo, ProducerInfo, ConsumerInfo 都是消息类型,均继承自 BaseCommand 接口。

ActiveMQ 的连接和会话的更多相关文章

  1. memcache和activemq使用连接,然后close

    memcache和activemq使用连接,然后close

  2. 理解oracle中连接和会话

    详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcytp44 理解oracle中连接和会话 1.  概念不同:概念不同: 连接是指物 ...

  3. 数据库的连接、会话与SQLite

    通俗来讲,会话(Session) 是通信双方从开始通信到通信结束期间的一个上下文(Context).这个上下文是一段位于服务器端的内存:记录了本次连接的所有相关状态和运行数据. 连接(Connecti ...

  4. ActiveMQ学习笔记(9)----ActiveMQ静态网络连接

    1. 启动多个Broker 在win10下同一台服务器启动多个Broker, 步骤如下: 1. 复制安装目录下的conf文件夹命名为conf2 2. 修改activemq.xml中的brokerNam ...

  5. [转帖]postgresql查看用户连接以及杀死连接的会话

    postgresql查看用户连接以及杀死连接的会话 2017年10月11日 15:21:18 DB_su 阅读数 8908更多 分类专栏: postgresql   版权声明:本文为博主原创文章,遵循 ...

  6. Oracle连接与会话

    连接(connection):连接是从客户端到oracle数据库实例的一条物理路径. 会话(session):会话是数据库实例中存在的一个逻辑实体. case1:一个连接可以有多个会话 SQL> ...

  7. Oracle 连接、会话数的查看,修改

    http://blog.csdn.net/xiaoyao6650/article/details/4027041 查看processes #当前的连接数 select count(*) from v$ ...

  8. LVS的持久连接、会话保持和高可用介绍

    持续连接 1)持久连接(lvs persistence)模板: 实现无论使用任何调度算法,在一段时间内(默认360s),能够实现将来自同一个地址的请求始终发往同一个RS ipvsadm -A|E -t ...

  9. 【HICP Gauss】数据库 数据库管理(连接方式 会话模式 存储表空间)-6

    数据库连接方式:驱动连接和客户端连接 驱动连接 : JDBC GSC ODBC 客户端连接 zsql工具 zsql / as sysdba -q #管理员身份登陆 zsql omm/ - #普通身份登 ...

随机推荐

  1. 最受欢迎的前端框架 —— Bootstrap学习

    Bootstrap是Twitter的Mark Otto和Jacob Thornton开发的,是目前最受欢迎的前端框架,它简单灵活,使得Web前端开发更加快捷方便. 首先,要基本掌握Bootstrap框 ...

  2. PL/SQL Developer登录出现——Using a filter for all users can lead to poor performance!

    用PL/SQL  Developer登录Oracle时提示:Using a filter for all users can lead to poor performance! 分析:与Oracle的 ...

  3. SQLServer2008 远程过程调用失败

    今天在连接数据库的时候,发现无法获取到服务器名称,打开SQLServer Configuration Manager,发现SQLServer服务中远程过程调用失败 我装的是VS2017,在网上百度了一 ...

  4. StringBuilderWriter 这个类需要commons.io.2.6这个包才可以使用, 在maven仓库中搜

  5. Eclipse+maven 构建第一个简单的springmvc项目

    先给出项目的目录: 在eclipse下使用maven构建第一个springmvc项目步骤如下: 1.创建maven project(此处默认你已了解maven),此处需要注意以下两点 2.创建完毕后会 ...

  6. node+ts的心得与坑

    首先先明确,用node+ts的目的,为什么不ng+ts.这一点后面还会反复提醒自己 node毕竟不是ng. 用node的理由: 处理js,在后端操纵dom,读写类html格式的东西,比直接用py的后端 ...

  7. Vim 8.0

    安装Vim 8.0yum install ncurses-devel wget https://github.com/vim/vim/archive/master.zip unzip master.z ...

  8. 在cmd中登录MySQL数据库

    mysql -uroot -p 输入密码,即可

  9. 牛客OI周赛4-提高组 B 最后的晚餐(dinner)

    最后的晚餐(dinner) 思路: 容斥 求 ∑(-1)^i * C(n, i) * 2^i * (2n-i-1)! 这道题卡常数 #pragma GCC optimize(2) #pragma GC ...

  10. CPU、OpenGL/DirectorX、显卡驱动和GPU之间的关系