1 2 3 4 Previous Next 46 Replies Latest reply on Feb 19, 2009 9:49 AM by ataylor Go to original post
      • 30. Re: [JBMESSAGING-1367] Create JCA resource adapter for JBM 2
        timfox

        What's the advantage of pooling the sessions for inbound?

        (I can see the advantage for outbound)

        • 31. Re: [JBMESSAGING-1367] Create JCA resource adapter for JBM 2
          jesper.pedersen

          The idea is to create a pool of worker threads that receive a message and then pass it on to the message endpoint -- typically a message driven bean (MDB).

          The activation itself has the connection to messaging system plus the destination definition.

          * ActivationSpec: Information about the connection setup
          * Activation: Physical connection, reference to destination and hooks to the work manager
          * ???Pool: Keeps track of the workers
          * ???: Single worker

          (Good names welcomed).

          If the worker can't deliver the message to the endpoint the DLQ functionality kicks in and pushes the message back to the messaging system. The DLQ part is last on my plate.

          • 32. Re: [JBMESSAGING-1367] Create JCA resource adapter for JBM 2
            timfox

            You've described a particular implementation but that wasn't my question: What's the point of pooling the sessions for inbound?

            Outbound clearly has a purpose since you don't want to be be creating a new session for each message sent, but inbound is not so clear.

            It might make more sense to have one session per MDB instance?

            • 33. Re: [JBMESSAGING-1367] Create JCA resource adapter for JBM 2
              jesper.pedersen

              Ok - as discussed on the IRC channel the pool is killed.

              But what would the right way to receive messages from the system be ?

              Or should I do a receive() implementation first that we can discuss things from ?

              • 34. Re: [JBMESSAGING-1367] Create JCA resource adapter for JBM 2
                timfox

                 

                "jesper.pedersen" wrote:

                But what would the right way to receive messages from the system be ?



                MessageListener ?

                • 35. Re: [JBMESSAGING-1367] Create JCA resource adapter for JBM 2
                  jesper.pedersen

                  Ok - I'll go in that direction (MessageConsumer -> MessageListener -> onMessage).

                  • 36. Re: [JBMESSAGING-1367] Create JCA resource adapter for JBM 2
                    jesper.pedersen

                    I have committed the code for the inbound part.

                    I did keep the pool which is initialized based on the MaxSession parameter (default 15). Feel free to rip it out.

                    Currently the pool start MaxSession message handlers which registers themself as a MessageListener on the specified activation. Once a message have been progressed; a new message handler is created.

                    JBMActivation -> JBMMessageHandlerPool -> JBMMessageHandler

                    The work is untested - let me know when there is a release I can use ;)

                    Feel free to share feedback.

                    • 37. Re: [JBMESSAGING-1367] Create JCA resource adapter for JBM 2
                      timfox

                      Thanks Jesper.

                      A couple of questions

                      1) Did you make the change to enlist the session in the JTA tx *before* the message was received by the JBM session?

                      2) I'm assuming you have some generic JCA tests for the JMS resource adapter? If so, could you copy them across to JBM? Or point me in the right direction so I can do so...

                      • 38. Re: [JBMESSAGING-1367] Create JCA resource adapter for JBM 2
                        jesper.pedersen

                         


                        1) Did you make the change to enlist the session in the JTA tx *before* the message was received by the JBM session?


                        The enlistment is done in ra.inflow.JBMMessageHandler::setup() right before the handler is registered as a listener.


                        2) I'm assuming you have some generic JCA tests for the JMS resource adapter? If so, could you copy them across to JBM? Or point me in the right direction so I can do so...


                        There are tests in the AS testsuite - but they require a JCA container and also an EJB container (testsuite/src/main/org/jboss/test/jmsra/).

                        In order to do testing in the JBM project we need at least a standalone JCA container - which havn't been released yet - project is JBJCA. Once we have a release of that we can integrate test cases into JBM.

                        For now we have to depend on the AS testsuite...

                        • 39. Re: [JBMESSAGING-1367] Create JCA resource adapter for JBM 2
                          ataylor

                          he's a summary of what i've found so far.

                          JBMResourceAdapter:setup(). I'm not sure we need the constructors that use discoveryaddress, discoverygroupname etc. We should always fall back to a default something like this:

                          else
                           {
                           HashMap<String, Object> params = new HashMap<String, Object>();
                           params.put("jbm.remoting.invm.serverid", 0);
                           factory = new JBossConnectionFactory(new TransportConfiguration("org.jboss.messaging.core.remoting.impl.invm.InVMConnectorFactory", params));
                           }
                          


                          Since we always use the local transport it should always be the invm transport and the default server id is 0.

                          Things like block on acknowledge should also be supported and if not we gfall back to the defaults in ClientSessionFactoryImpl.

                          There was a slight issue at JBMMessageHandler line 387 where getTransactionTimeout() was returning null and throwing a NPE. We should change this to Integer and only set the tx timeout if not null.



                          • 40. Re: [JBMESSAGING-1367] Create JCA resource adapter for JBM 2
                            timfox

                            We don't always use the local server.

                            The ra should support all the params of the client session factory.

                            • 41. Re: [JBMESSAGING-1367] Create JCA resource adapter for JBM 2
                              ataylor

                              I'm also getting the following error:

                              javax.transaction.NotSupportedException: BaseTransaction.checkTransactionState - [com.arjuna.ats.internal.jta.transaction.arjunacore.alreadyassociated] [com.arjuna.ats.internal.jta.transaction.arjunacore.alreadyassociated] thread is already associated with a transaction!
                               at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.begin(BaseTransaction.java:80)
                               at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.begin(BaseTransactionManagerDelegate.java:65)
                               at org.jboss.messaging.ra.inflow.JBMMessageHandler$XATransactionDemarcationStrategy.<init>(JBMMessageHandler.java:397)
                              


                              this becuase every session is trying to associate the same thread with the same tx.

                              • 42. Re: [JBMESSAGING-1367] Create JCA resource adapter for JBM 2
                                jesper.pedersen

                                The NotSupportException comes from the fact that we need to have each JMS session in the inbound part of the adapter in a separate thread.

                                Since we are at this point now I'll do an implementation based on WorkManager that you can take a look at.

                                For now the MaxSession attribute can stay at the default value of 1 in order to help testing.

                                • 43. Re: [JBMESSAGING-1367] Create JCA resource adapter for JBM 2
                                  ataylor

                                  Theres also a problem with the XAResource being started twice. both in JBMMessageHandler at:

                                  line 409

                                  if (!trans.enlistResource(res))


                                  and line 213
                                  endpoint.beforeDelivery(JBMActivation.ONMESSAGE);


                                  I'm guessing the first one doesn't need to happen..

                                  • 44. Re: [JBMESSAGING-1367] Create JCA resource adapter for JBM 2
                                    timfox

                                    The session MUST be enlisted in the tx before delivery has occured - not after!