Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Java Message Driven Beans and Websphere Activation specification without hardcoded JNDI Names?

We have a MDB listening to a Queue reading data and sending data to another Queue

@MessageDriven(
        activationConfig = { @ActivationConfigProperty(
                propertyName = "destinationType", propertyValue = "javax.jms.Queue"
        ) }, 
        mappedName = "jms/dataQ")
public class DataMDB implements MessageListener {

@Resource(name="jms/dataQueueConnectionFactory")
private ConnectionFactory connectionfactory;

@Resource(name="jms/dataDestinationQ")
private Destination destination;

...
}

and an XML (ibm-ejb-jar-bnd.xml) with bean configuration

<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar-bnd xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://websphere.ibm.com/xml/ns/javaee"
    xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee   http://websphere.ibm.com/xml/ns/javaee/ibm-ejb-jar-bnd_1_0.xsd"
    version="1.0">

<message-driven name="DataMDB">
        <jca-adapter activation-spec-binding-name="eis/dataListenerMDB"
            destination-binding-name="jms/dataQ" />
        <resource-ref name="jms/dataQueueConnectionFactory"
            binding-name="jms/dataQueueConnectionFactory" />
        <resource-env-ref name="jms/dataDestinationQ"
            binding-name="jms/dataDestinationQ" />
    </message-driven>

</ejb-jar-bnd>

and Activation specification for this MDB on WebSphere

WAS Activation Specification

As I have seen the examples over Google, this is the typical example of MDB and WAS Activation setup.

We have a problem here as all the JNDI names seen here are hardcoded in Java code anotations as well as in the ibm-ejb-jar-bnd.xml file.

So is there a way that these JNDI names can be brought outside the EJB project, so we could build one project for all customers and customers are free to have their Standard JNDI Names.

Else we have to build different .ear for each customer and which is not ideal.

Thanks in advance people. Any ideas are welcome.

like image 311
naamadheya Avatar asked Aug 06 '14 11:08

naamadheya


People also ask

How can change JNDI name in WebSphere?

Target Resource JNDI name Specifies the Java Naming and Directory Interface (JNDI) name of the enterprise bean. This is a data entry field. To modify the JNDI name bound to this bean, type the new name in this field, then select OK.

Where is JNDI name in WebSphere Admin COnsole?

In the Administration COnsole of WAS 7, on the Applications > Application Types > WebSphere enterprise applications > application > EJB JNDI names section, I have a table with four columns : EJB Module (e.g. ProjectEJB. jar)

What is JMS activation specification?

A JMS activation specification is associated with one or more message-driven beans and provides the configuration necessary for them to receive messages.


1 Answers

All values defined in the ibm-ejb-jar-bnd.xml maps references to the actual JNDI names. This can be overridden for each of your customers during application installation (mapping references to JNDI names steps in the admin console), after application installation, or during installation using scripts.

The binding file (ibm-ejb-jar-bnd.xml) provides only 'default names', in case you dont want to change them during installation.

like image 166
Gas Avatar answered Oct 07 '22 10:10

Gas