如何配置Java消息驱动Bean和没有硬编码的JNDI名称的Websphere激活规范? [英] How to configure Java Message Driven Beans and Websphere Activation specification without hardcoded JNDI Names?

查看:281
本文介绍了如何配置Java消息驱动Bean和没有硬编码的JNDI名称的Websphere激活规范?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个MDB监听队列读取数据并将数据发送到另一个队列

  @MessageDriven(
()
public class DataMDB实现MessageListener {

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

@Resource(name =jms / dataDestinationQ)
private目的地目的地;

...
}

和一个XML(ibm -ejb-jar-bnd.xml)与bean配置

 <?xml version =1.0encoding =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>

和WebSphere上此MDB的激活规范





正如我所看到的这是Google上的示例,这是MDB和WAS激活设置的典型示例。



我们有一个问题,因为在这里看到的所有JNDI名称都是用Java代码的anotations以及ibm-ejb-jar-bnd.xml文件中。



所以有一种方法可以将这些JNDI名称带到EJB项目之外,所以我们可以为所有客户构建一个项目,客户可以自由使用其标准JNDI



否则我们必须为每个客户建立不同的.ear,而不理想。



谢谢提前人。
欢迎任何想法。

解决方案

ibm-ejb-jar中定义的所有值-bnd.xml 映射对实际JNDI名称的引用。在应用程序安装期间(在管理控制台中对JNDI名称步骤的映射引用),应用程序安装后或使用脚本进行安装时,可以为每个客户覆盖这些内容。



绑定文件(ibm-ejb-jar-bnd.xml)仅提供默认名称,以防在安装过程中不要更改它们。 >

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.

解决方案

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.

这篇关于如何配置Java消息驱动Bean和没有硬编码的JNDI名称的Websphere激活规范?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆