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

瘦欲@ 提交于 2019-12-23 11:13:11

问题


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

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.


回答1:


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.



来源:https://stackoverflow.com/questions/25159765/how-to-configure-java-message-driven-beans-and-websphere-activation-specificatio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!