ActivationSpec 和 ConnectionFactory 有什么区别? [英] What's the difference between ActivationSpec and ConnectionFactory?

查看:9
本文介绍了ActivationSpec 和 ConnectionFactory 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的理解是:

  • MDBs(消息驱动 Bean)通过激活规范连接.
  • MDPs(消息驱动的 POJO)通过连接工厂连接.

此图表 没有说明差异:

  • 连接工厂 -- 由应用程序用于获取与消息总线的连接.
  • 队列 -- 由应用程序用于发送和接收消息.
  • 激活规范 -- 由应用程序的消息驱动 bean 用于连接到队列并接收消息.

我发现的一个真正的不同之处在于:

<块引用>

会话 bean 和实体 bean [aka MDP] 允许您发送 JMS 消息并接收它们同步,但不是异步.为了避免束缚服务器资源,您可能不喜欢使用阻塞同步在服务器端组件中接收.接收消息异步,使用消息驱动的 bean [MDB].

所以我目前不满意的清单是:

  • 将 ActivationSpec 与 MDB 和 ConnectionFactory 与 POJO 一起使用(但是等等,POJO 可以 也使用 ActivationSpec ?)
  • MDB 以异步方式运行.MBP 同步运行.

我的问题是:还有其他区别吗?你能澄清一下区别吗?

参考文献:

解决方案

@Jeffrey Knight:让我试着根据我的经验来澄清一下.

我们知道 MDB 是用来消费传入消息的 bean.现在需要指定特定 MDB 想要消费的消息类型和目的地.

MDB 基本上是一个消息端点.

在符合 JCA 的 MDB 之前:

websphere 中的流量是 :-

<块引用>

传入消息 --> 被消息监听器监听 --> 监听器端口-->交付给MDB

因此,开发人员通常会创建一个 MDB 并在 ejb-jar.xml 中指定消息目标详细信息,如下所示:-

<destination-type>javax.jms.Queue</destination-type></message-driven-destination><res-ref-name>jms/QCF</res-ref-name><资源参考><res-type>javax.jms.QueueConnectionFactory</res-type><res-auth>容器</res-auth></resource-ref>

并且部署者需要创建侦听器端口并将部署的 MDB 关联到侦听器端口.上面指定的 QueueConnectionFactory 用于创建与队列的连接.

发布符合 JCA 的 MDB:

在 JCA 之后,MDB 被视为 JCA 资源.JCA 规范也包含消息传递框架 API.JCA 情况下的流程是:-

传入消息 -->被消息监听器监听 -->资源适配器--> 交付给 MDB

现在,由于 JCA 被创建用于处理任何类型的资源,无论是 JDBC、JMS、EIS 等,因此它具有为任何适配器创建配置的通用激活规范"方式.在 ra.xml 文件中,提到了该特定适配器需要什么样的激活规范才能工作.Activation spec 不是运行时实体,它只是资源适配器使用的配置细节.在上述情况下,JCA 适配器将使用来自激活规范中提到的队列连接工厂的连接.所以基本上上面两种情况下的队列连接工厂都是一样的.

对于 websphere,您可以使用 SIB(服务集成总线)目标进行消息传递,也可以使用 websphere MQ 等外部软件进行消息传递.

如果是用于消息传递的 SIB 目的地:-SIB 已经实现了一个 JCA 资源适配器.因此,在 SIB 上使用目标的 MDB 可以使用激活规范来指定目标详细信息.和资源适配器模块可以与消息引擎交互并将消息传递给MDB.

对于像 websphere MQ 这样的外部消息框架:-由于 websphere MQ 尚未实现任何 JCA 适配器,因此我们需要配置侦听器端口以连接到驻留在 websphere MQ 上的目的地.将消息传递到 MDB 的是侦听器端口.

简而言之,两种情况都使用队列连接工厂来获取队列连接.在一种情况下,它是用于传递消息的资源适配器(具有激活规范形式的配置信息),而在另一种情况下,它是用于传递消息的侦听器端口(绑定到队列和工厂).

我希望现在澄清.

My understanding is that:

  • MDBs (Message Driven Beans) connect via Activation Specification.
  • MDPs (Message Driven POJO) connect via Connection Factory.

This diagram from IBM is helpful:

To me, this explanation from IBM does not shed much light on the difference:

  • Connection factory -- used by the application to get connections to the messaging bus.
  • Queue -- used by the application to send and receive messages.
  • Activation specification -- used by the application's message-driven bean to connect to the queue and receive messages.

One real difference I have found is that:

Session beans and entity beans [aka MDPs] allow you to send JMS messages and to receive them synchronously, but not asynchronously. To avoid tying up server resources, you may prefer not to use blocking synchronous receives in a server-side component. To receive messages asynchronously, use a message-driven bean [MDB].

So the unsatisfying list I have so far is:

  • Use ActivationSpec with an MDB and ConnectionFactory with a POJO (but wait, can POJOs use ActivationSpec too ?)
  • MDB's operate asynchronously. MBP's operate synchronously.

My question is: Are there other differences? Can you clarify the difference ?

References:

解决方案

@Jeffrey Knight: Let me try to clarify based on my experience.

We understand MDB are beans to consume incoming messages. Now there is need to specify what kind of messages, from which destination a particular MDB wants to consume to.

MDB is basically a message end point.

Prior to JCA compliant MDBs:

flow in websphere was :-

incoming message --> listened by Message listener --> listener ports-->deliver to MDB

So typically a developer would create a MDB and specify message destination details in ejb-jar.xml as follows:-

<message-driven-destination>
    <destination-type>javax.jms.Queue</destination-type>
</message-driven-destination>
<res-ref-name>jms/QCF</res-ref-name>
<resource-ref>
    <res-type>javax.jms.QueueConnectionFactory</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

and a deployer would need to create listener port and associate deployed MDB to the listener port. QueueConnectionFactory specified above is made to create connections to queue.

Post JCA compliant MDBs:

Post JCA, MDB is treated as a JCA resource. JCA specification incorporated messaging framework APIs as well. Flow in case of JCA is:-

incoming message --> listened by Message listener --> Resource Adapter-->deliver to MDB

Now since JCA was created to work with any type of resouce be it JDBC, JMS, EIS etc, so it has a generic "Activation Spec" way of creating configurations for any adapter. In ra.xml file, it is mentioned what kind of activation spec is needed by that particular adapter to work. Activation spec is not a runtime entity, it is just a configuration details used by resource adapter. In above case JCA adapter will use connection from queue connection factory mentioned in activation spec. So basically queue connection factory in above both cases are same.

In case of websphere, you can use either SIB (Service Integration Bus) destinations for messaging OR external software like websphere MQ for messaging.

In case of SIB destinations for messaging :- SIB has implemented a JCA resource adapter. So MDB using destination on SIB can use activation spec to specify destination details. and resource adapter module can interact with messaging engine and can deliver the messages to MDB.

In case of external messaging framework like websphere MQ:- Since websphere MQ has not implemented any JCA adapter, so we will need to configure listener port to connect to destinations residing on websphere MQ. It is listener port who will deliver the messages to MDB.

In short, both cases use queue connection factory to get queue connection. In one case, it is resource adapter (with configuration information in form of activation spec) used to deliver messages where as in other case it is listener port (bound to queue & factory) used to deliver messages.

I hope this clarifies now.

这篇关于ActivationSpec 和 ConnectionFactory 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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