What's the difference between ActivationSpec and ConnectionFactory?

前端 未结 3 559
栀梦
栀梦 2020-12-12 23:33

My understanding is that:

  • MDBs (Message Driven Beans) connect via Activation Specification.
  • MDPs (Message Driven PO
3条回答
  •  青春惊慌失措
    2020-12-13 00:04

    @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:-

    
        javax.jms.Queue
    
    jms/QCF
    
        javax.jms.QueueConnectionFactory
        Container
    
    

    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.

提交回复
热议问题