When using WebLogic's JMS system, there's a rather long list of parameters that are specific to this application server and control several aspects of our components, such as caching, security, and thread usage.
Some of these elements can be attached to a bean with annotations, some can only be declared inside a specific descriptor file, and some are available both ways. The following is a list of WebLogic-specific elements that you can apply to a bean only through a descriptor file, weblogic-ejb-jar.xml
:
dispatch-policy
: This element attaches the MDB to a work manager, which is a way to share computational resources among WebLogic components.initial-beans-in-free-pool
: This element tells the bean system how many beans should be created and put in the pool when the application is started. When WebLogic creates a message-driven bean, 16 instances are created. These can be seen in the Consumers Current column on the administration's queue monitoring screen.max-beans-in-free-pool
: This parameter sets the limit of instances that can be held in a bean pool. The default value, 1000, is a pretty high number, if you consider that it applies to only one MDB.security-role-assignment
: When you secure a bean, a role is attached to it, and this element maps the virtual role to the WebLogic's security layer. This topic will be explored in Chapter 8, Adding Security.For a complete list of elements declared by annotations and deployment descriptors, check the product's online documentation at http://docs.oracle.com/middleware/1212/wls/EJBPG/ejb_jar_ref.htm.
As we know beforehand that our ExhibitionConsumer
bean isn't required to deal with heavy loads, we can set a lighter configuration to it by attaching both initial-beans-in-free-pool
and max-beans-in-free-pool
elements to it.
In order to accomplish this, we need to create a weblogic-ejb-jar.xml
descriptor file inside the Theater project:
Weblogic
in the search field, select Oracle Weblogic EJB Module Descriptor, and click on Next.Theater/WebContent/WEB-INF
folder and click on Finish.Now you can edit the file's source and add the following lines of code inside the existing weblogic-ejb-jar
tag—remember to change it to allow the insertion of children:
<wls:weblogic-enterprise-bean> <wls:ejb-name>ExhibitionConsumer</wls:ejb-name> <wls:message-driven-descriptor> <wls:pool> <wls:max-beans-in-free-pool>3</wls:max-beans-in-free-pool> <wls:initial-beans-in-free-pool>1</wls:initial-beans-in-free-pool> </wls:pool> </wls:message-driven-descriptor> </wls:weblogic-enterprise-bean>
Actually, there's a way to attach these two elements as annotations: we could use the weblogic.ejbgen.MessageDriven
decorator, which is WebLogic-specific and explicitly exposes configuration elements, as opposed to javax.ejb.MessageDriven
where we have to declare them as a list of ActivationConfigProperty
annotations.
Our bean definition would look like something similar to the following code:
@weblogic.ejbgen.MessageDriven ( ejbName = "ExhibitionConsumer", destinationJndiName = "jms.tickets.exhibition", destinationType = "javax.jms.Queue", initialBeansInFreePool = "1", maxBeansInFreePool = "3")
Thing is, as it happens with the EJB Module Descriptor wizard, the wizard associated with EJBGen—WebLogic's proprietary extension to EJB—doesn't acknowledge that we can create a bean inside a web project. That's because the EJBGen module is still bounded to EJB Version 2.1, so we can't use this feature in our projects.