3 Replies Latest reply on Aug 31, 2001 9:02 AM by Peter Antman

    JMS as a resource

    Lars Olsson Newbie

      The JMS chapter in the JBOSS documentaton describes
      two different ways to get the queue connection factory.

      Method 1:
      In the subchapter "JMS" (ch08s06.html) one should
      use the global name "QueueConnectionFactory" for the
      JNDI lookup.

      Method 2:
      In the subchapter "JMS as managed resource"
      (ch08s27.html) one should lookup the the factory
      as a resource specified by resource-ref element in
      the deployment descriptor.

      When I read the second sub-chapter I get the
      impression that this is THE way to do it. But then I
      wonder why the documentation mentions the first method
      at all.

      In what circumstances (if any) would one use the
      first method?

      Lars

        • 1. Re: JMS as a resource
          Peter Antman Expert

          Method one is for vanilla JMS standalone clients.
          Method two is in a J2EE enviroment, when doinf from inside a bean.

          It is possible to do it the first way in beans to, but then you will not be part of the container transaction handling.

          //Peter

          • 2. Re: JMS as a resource
            Lars Olsson Newbie

            OK -thanks for your reply.

            Now on to the next question.

            In your example there are <resource-ref> elements
            for both the topic connection factory AND the topic.

            What would happen if you removed the resource-ref
            entry for the topic (and let the bean get the topic
            name from some other source)?

            I have a setup where a stateless session bean should
            write a message to a queue - but the name of the
            queue is not known at deployment time so it is not
            possible to create a resource-ref entry for it.

            The bean is using container managed transactions.

            At run time a servlet will call business methods on
            the session bean - each business method has an
            argument that identifies the queue to write to.

            So I want to lookup the queue in the business method
            using the jndi queue name from one of the business
            method arguments and and write to it. Can I do this
            and still get all that nice transactional support?

            Thanks,
            Lars

            • 3. Re: JMS as a resource
              Peter Antman Expert

              Should be doable. You have to be shure you get the destination from the same JNDI space as the connection.

              //Peter