4 Replies Latest reply on Jan 5, 2009 11:06 AM by babernat

    JBoss MDB Beginner Question

      Hi all, I have a simple question. I'm using JBoss 4.2.3GA and am implementing a message driven bean. Is there a way to pass a MDB runtime configuration via the ejb-jar.xml descriptor?

      My MDB requires some additional information to preform its job and I was hoping there was a way to do this via configuration instead of hard-coding values much in the same way you can assign attributes to a MBean via an attribute tag.

      Is this possible? If I'm way off base, then where is the best place to do this?

      Thanks in advance.

        • 1. Re: JBoss MDB Beginner Question
          dvh75

          Don't know if you found your answer or not, but check this out:
          http://docs.jboss.org/ejb3/app-server/tutorial/

          As described in the injection section, you can do the following:

          The @javax.annotation.Resource annotation allows you to inject resources.

          @Resource(mappedName="DefaultDS")
          private javax.sql.DataSource ds;


          If you just need String data, it would look like so:

          @Resource(mappedName="MyConfigValue")
          private String somevalue;


          If you're not using the annotations, just declare a resource in the ejb-jar.xml for you mdb, then do a jndi lookup on it in your bean.

          Hope this helps...

          • 2. Re: JBoss MDB Beginner Question

            Thanks dvh75. Let's talk about the String data for a minute because that is exactly what I need to do. The "MyConfigValue" would have to be exposed in JNDI, correct? If so, how do I configure JBoss to place that value in the JNDI directory?

            • 3. Re: JBoss MDB Beginner Question
              jaikiran

              You can use the env-entry element in the ejb-jar.xml and corresponding jboss.xml. Those values get bound to java:comp/env namespace of the component in the JNDI. Look for the dtds of ejb-jar.xml and jboss.xml for more details. Let us know, if you are having trouble in configuring them.

              • 4. Re: JBoss MDB Beginner Question

                jaikiran,

                Thanks for the reply. This is exactly what I needed. Thank you very much for the pointer.