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

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

问题描述

我的理解是:




  • MD B s(消息驱动Bean)通过激活规范连接。

  • MD P s(消息驱动POJO)通过Connection Factory连接。



此图并没有说明差异:




  • 连接工厂 - 由应用程序用于连接到消息传递总线。

  • 队列 - 应用程序用于发送和接收消息。

  • 激活规范 - 由应用程序的消息驱动Bean用于连接到队列并接收消息。



一个真正的差异我发现是


会话bean和实体bean [又名MDP]允许你发送JMS消息和
同步接收它们,但不是异步接收。为避免占用
服务器资源,您可能不希望在服务器端组件中使用阻塞同步
receive。 要异步接收消息
,请使用消息驱动的bean
[MDB]。


所以到目前为止我不满意的列表是:




  • 将ActivationSpec与MDB一起使用,将ConnectionFactory与POJO一起使用(但等待,POJOs 还使用ActivationSpec ?)

  • MDB以异步方式运行。 MBP同步运作。



我的问题是:还有其他差异吗?你能否澄清区别?



参考文献:




解决方案

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



我们理解MDB是消耗传入消息的bean。现在需要指定哪种消息,特定MDB想要从哪个目标消费。



MDB基本上是一个消息终点。



在符合JCA标准的MDB之前:



websphere中的流量为: -


传入消息 - >由消息侦听器监听 - >侦听器
端口 - >传递给MDB


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

 <消息驱动目的地> 
< 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>

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



发布符合JCA的MDB:



发布JCA,MDB被视为JCA资源。 JCA规范也包含了消息传递框架API。 JCA情况下的流程为: -

 收到的消息 - >由消息监听器监听 - >资源适配器 - >提供给MDB 

现在,因为创建了JCA以使用任何类型的资源无论是JDBC,JMS,EIS等,它都有一种通用的激活规范方式来为任何适配器创建配置。在ra.xml文件中,提到了特定适配器需要哪种激活规范才能工作。激活规范不是运行时实体,它只是资源适配器使用的配置细节。在上述情况下,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天全站免登陆