设置JMS 2.0使用者的clientID [英] Setting clientID for JMS 2.0 consumer

查看:163
本文介绍了设置JMS 2.0使用者的clientID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在JMS 1.x中,创建持久订阅时,使用clientId唯一标识客户端.此 answer 解释了JMS 1.x中clientId的用法

With JMS 1.x the clientId is used to uniquely identify clients when creating durable subscriptions. This answer explains clientId usage in JMS 1.x

在JMS 2.x中,clientId是可选的.我想了解在JMS 2.x中提供clientId的利弊.

With JMS 2.x clientId is made optional. I want to understand pros and cons of supplying the clientId in JMS 2.x.

摘自有关JMS 2.x功能的Oracle文章:

共享的持久订阅.这些仅在JMS 2.0中可用,并且是使用createSharedDurableConsumer创建的.他们可以有任意数量的消费者. 设置客户端标识符是可选的.如果已设置,则订阅将通过订阅名称和客户端标识符的组合来标识.

Shared durable subscriptions. These are available in JMS 2.0 only and are created using createSharedDurableConsumer. They can have any number of consumers. Setting the client identifier is optional. The subscription is identified by the combination of the subscription name and the client identifier, if it is set.

听起来订阅名称现在是唯一标识符,但是为什么要有clientID?这些是会话类的新方法,因此不能向后兼容.用JMS 2.x设置clientId有什么好处或弊端?

It sounds like the subscription name is the unique identifier now, but then why have the clientID? These are a new methods on the session class so it can't be backwards compatibility. Any benefits or downsides of setting the clientId with JMS 2.x?

MessageConsumer messageConsumer = session.createSharedDurableConsumer(topic, "myDurableSub");

推荐答案

JMS 2规范指出了为什么在6.1.3节中存在客户端ID:

The JMS 2 specification indicates why the client ID exists in section 6.1.3:

JMS定义的客户端标识符的唯一用途是其在 标识未共享的持久订阅或其在中的可选使用 标识共享的持久或非持久订阅.

The only use of a client identifier defined by JMS is its mandatory use in identifying an unshared durable subscription or its optional use in identifying a shared durable or non-durable subscription.

关于共享的非持久订阅,规范在第8.3.3节中对此进行了说明:

Regarding shared non-durable subscriptions the spec says this in section 8.3.3:

共享的非持久订阅由以下项指定的名称标识: 客户和客户标识符(如果已设置).如果设置客户端标识符的时间是 首先创建共享的非持久订阅,然后创建一个客户端 随后希望在共享的非持久对象上创建消费者 订阅必须使用相同的客户端标识符.

A shared non-durable subscription is identified by a name specified by the client and by the client identifier if set. If the client identifier was set when the shared non-durable subscription was first created then a client which subsequently wishes to create a consumer on that shared non-durable subscription must use the same client identifier.

该规范在第8.3.4节中说明了有关共享持久订阅的基本知识:

The spec says the same basic thing about shared durable subscriptions in section 8.3.4:

共享的持久订阅由客户端指定的名称标识 以及客户标识符(如果已设置).如果在 首先创建共享持久订阅,然后创建一个客户端 随后希望在共享的持久性基础上创建一个消费者 订阅必须使用相同的客户端标识符.

A shared durable subscription is identified by a name specified by the client and by the client identifier if set. If the client identifier was set when the shared durable subscription was first created then a client which subsequently wishes to create a consumer on that shared durable subscription must use the same client identifier.

通过使客户端标识符对于共享的持久和非持久订阅是可选的,这使得共享订阅更加方便,因为每个客户端仅需要提供订阅名称,而不是客户端标识符和订阅名称.这符合JMS 2的通用主题,该主题简化了API,使JMS更加易于使用.

By making the client identifier optional for shared durable and non-durable subscriptions it makes sharing the subscription a bit more convenient since each client only needs to supply the subscription name rather than both the client identifier and the subscription name. This fits with the general theme of JMS 2 which simplifying the API to make JMS more convenient to use.

这篇关于设置JMS 2.0使用者的clientID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆