8 Replies Latest reply on Aug 3, 2009 10:51 AM by frankthetank

    JBM 1.4 and container transactions

    frankthetank

      JBoss 4.2.3 + JBM 1.4
      Cluster support required.

      In my setup I have two destinations:
      One queue for 'internal' messages and one topic for 'external' messages.
      Both configured for clustering.

      All messages are to be sent with container transactions.
      Although the queue need not send to the cluster, the topic must.

      Currently I am using the /ClusteredConnectionFactory, but the messages are not being committed.
      From the connection-factories-service.xml I can see that /ClusteredConnectionFactory binds to the same interface as /ClusteredXAConnectionFactory.
      Am I using the correct factory?

      http://www.jboss.org/index.html?module=bb&op=viewtopic&t=153641 only speaks about the /ConnectionFactory.

      I really need the Messages on the Topic (at least, ideally also the Queue) to be clustered and support container transactions.

      What factories do I really need to use to accomplish my goals?
      Thanks[/url]

        • 1. Re: JBM 1.4 and container transactions
          frankthetank

          Update:
          Doing some tests.

          I have two destinations:
          Queue (configured as non-clustered):
          Destination : "queue/TestQueue"
          Factory : "java:/JmsXA"
          Type : "javax.jms.Queue"
          NeedsTransactions : true

          Topic (configured as clustered):
          Destination : "queue/TestTopic"
          Factory : "/ClusteredConnectionFactory"
          Type : "javax.jms.topic"
          NeedsTransactions : false

          (stored in a lookup map)

          Datasource that persists the jms topics is a xa-datasource.

          I have an MBean that provides a jmx-console interface and a stateless SessionBean that will send the message.
          The SessionBean's send() method is annotated with @TransactionAttribute(TransactionAttributeType.REQUIRED)

          I use the above destination info and get the required components, then send out the message. No problemo.
          Problem is, the transactions do not seem to be 'working' if the send() method fails (due to an exception I can trigger within the call but after 'sending' the message).
          Regardless where I send it, with or without exception, the message will still come out.

          My actual system should work as following:
          The Queue is used on a per-node basis to inform other components if one component changes something.
          f.i. if I change the addess of a user in one component, I want a message to be sent over the queue to a dedicated listener on that node.
          The process must be transactional because if something goes wrong, we do not want the message to be sent.
          This dedicated listener recieves the message and then, among other things, will propagate a stripped version of this event to a 'public' topic.
          The topic should be cluster wide, so that a listener on Node B knows that something changed.
          On this public topic there are multiple listeners that hungrily await these messages.
          The messages on the 'public' topic need not be handled via transaction.

          What am I doing wrong?

          thanks

          • 2. Re: JBM 1.4 and container transactions
            ejb3workshop

            Please have a look at this thread :
            http://www.jboss.org/index.html?module=bb&op=viewtopic&t=137334

            Using java:/JmsXA for both should give you the behaviour you are after.

            • 3. Re: JBM 1.4 and container transactions
              frankthetank

              Detail info:
              I am using JBoss Messaging 1.4.2.GA-SP1
              I would move to 1.4.4 but it (1.4.4 requires jboss-remoting 2.2.3) conflicts with a different issue I resolved with a newer version of jboss-remoting (2.4.0).
              Sees like jbr 2.4.0 is not backwards compatible.

              • 4. Re: JBM 1.4 and container transactions
                ejb3workshop

                I am also using 1.4.2 GA SP1 and have found that using JmsXA works and support XA transactions, at the cost of distribution. It still distributes the messages once all beans in the pool on one node are exhausted.

                • 5. Re: JBM 1.4 and container transactions
                  frankthetank

                  Maybe it is my setup but my tests with the JmsXA are not working... and it is driving me nuts.

                  As mentioned I am trying to force the transaction to rollback by throwing an exception after the 'sending' of a message but the message still gets sent out.

                  May I ask some detailed questions:
                  1) When you send a message with the JmsXA Factory, do you also set the transaction-boolean when creating a session?
                  i.e. connection.createSession( true... ?

                  2) do you lookup the connection at each send?
                  i.e.

                   ic = new InitialContext();
                   System.out.println("do lookup");
                   mConnectionFactory = (ConnectionFactory) ic.lookup(destinationConfig.getFactory());
                  



                  • 6. Re: JBM 1.4 and container transactions
                    gaohoward

                    JBM doesn't use XA datasource. You just need to configure your MDB to be transactional, that's ok.

                    • 7. Re: JBM 1.4 and container transactions
                      ejb3workshop

                      I am injecting my connection factory using

                      @Resource(name = "jms/ConnectionFactory")
                      protected ConnectionFactory m_factory;
                      


                      and then in jboss.xml I am mapping it to the actual connection factory :

                       <resource-ref>
                       <res-ref-name>jms/ConnectionFactory</res-ref-name>
                       <jndi-name>java:/JmsXA</jndi-name>
                       </resource-ref>
                      


                      You can of course also inject the JmsXA connection factory directly.

                      • 8. Re: JBM 1.4 and container transactions
                        frankthetank

                         

                        "gaohoward" wrote:
                        JBM doesn't use XA datasource. You just need to configure your MDB to be transactional, that's ok.

                        You can do that?

                        "ejb3workshop" wrote:
                        I am injecting my connection factory using

                        @Resource(name = "jms/ConnectionFactory")
                        protected ConnectionFactory m_factory;
                        


                        and then in jboss.xml I am mapping it to the actual connection factory :

                         <resource-ref>
                         <res-ref-name>jms/ConnectionFactory</res-ref-name>
                         <jndi-name>java:/JmsXA</jndi-name>
                         </resource-ref>
                        


                        You can of course also inject the JmsXA connection factory directly.


                        That might be my problem. Initially I had my emitter as an MBean everyone could use but over time it was used as a simple lib and thus the ConnectionFactory had to be gained by lookup.

                        I'll try it again as an MBean.
                        Thanks for the Help!