如何在JBoss 7中部署资源适配器激活? [英] How can I deploy a resource-adapter activation in JBoss 7?
问题描述
我试图弄清楚如何在JBoss 7中部署资源适配器激活.基本上,我希望能够打包和部署完整的应用程序而不必修改基本服务器配置,部分原因是因为我想使用Arquillian进行引导测试,也是因为我希望能够将程序包部署到可能无法修改基本服务器配置的环境中.
I am trying to figure out how to deploy a resource-adapter activation in JBoss 7. Basically, I want to be able to package and deploy a full application without having to modify the base server configuration, in part because I want to bootstrap testing using Arquillian but also because I want to be able to deploy my packages into an environments where I may not have the option of modifying the base server's configuration.
这就是我现在的位置.我创建了一个包含active-mq rar(也已在application.xml中配置)的EAR.该耳朵本身可以使用maven耳朵插件和jboss-as-maven-plugin完美构建和部署.
Here's where I am right now. I have created an EAR which contains the active-mq rar (which is also configured in the application.xml). This ear by itself builds and deploys perfectly using the maven ear plugin and the jboss-as-maven-plugin.
但是,为了激活rar,我唯一能弄清的方法是破解rar文件本身,并在rar的 META-中添加 ironjacamar.xml INF 目录.但是为了做到这一点,我不得不在我真的不想做的Maven仓库中破解rar.
However, in order to activate the rar, the only way I have been able to figure out is to hack the rar file itself and add an ironjacamar.xml into the rar's META-INF directory. But in order to do this, I had to hack the rar in my maven repo which I don't really want to do.
我试图让maven在我的maven pom的打包阶段添加 ironjacamar.xml ,但这也是一个小技巧,无论如何我还是无法使它工作. (请注意:请部署覆盖)
I tried to get maven to add the ironjacamar.xml during the packaging phase of my maven pom, but that's a bit of hack as well and I couldn't get it work anyways. (Note to self: check on Deployment Overlays)
我还考虑过使用jboss-cli脚本添加 connection-factory 的脚本,但是文档清楚地指出,这是为内置hornet-mq服务器创建工厂,这不是我的目标,并在服务器中交换默认的JMS实现需要对服务器的配置进行一些大的改动.
I also thought about scripting the addition of a connection-factory using jboss-cli, but the docs clearly state that is for creating factories for the built in hornet-mq server which is not my target, and swapping the default JMS implementation in the server requires some major surgery on the server's config.
我查看了所有快速入门项目,并观察到通过软件包中包含的 -jms.xml 和 -ds.xml 文件部署了各种构造,但是它们也分别针对hornet-mq和JDBC. (我希望部署者可以支持 -rar.xml 之类的东西.)
I looked though all the quickstart projects and observed all sorts of constructs being deployed though -jms.xml and -ds.xml files included in the package, but they're also specific to hornet-mq and JDBC respectively. (I was hoping the deployer might support a -rar.xml or the like).
我能想到的唯一不知道是否受支持的方法是在程序包中定义一个 子系统 .有这样的东西吗?
The only other way I can think of, and I don't know if it is supported, is to define a subsystem deployment in my package. Is there such a thing ?
=====更新=====
===== UPDATE =====
我尝试添加cli覆盖更新(就像我将使用maven jboss作为插件一样),但没有效果.
I tried adding a cli overlay update (as I would using the maven jboss as plugin) but it had no effect.
deployment-overlay add --name=rarActivation --content=META-INF/ironjacamar.xml=\..\container\src\main\resources\ironjacamar.xml --deployments=activemq-rar.rar --redeploy-affected
推荐答案
好吧,在没有其他答案的情况下,这就是我想出的解决方案.这有点骇人听闻,但它与Active MQ和WebSphere MQ完美协作.前提是我要连接的每个JMS系统部署2个不同的RAR.其中之一是我从Maven存储库中检索到的原始xxx.rar文件.第二个是我的配置RAR",其中包含原始rar中的 ra.xml 的副本,然后是 ironjacamar.xml 的配置文件.两者都放在配置rar的 META-INF 文件夹中.
Well, in the absence of any other answers, this is the solution I came up with. It's a bit of a hack, but it has worked flawlessly with Active MQ and WebSphere MQ. The premise is that I deploy 2 different RARs per JMS system I want to connect to. One is the untouched xxx.rar file I retrieve from the Maven repository. The second is my "configuration RAR" which contains a copy of the ra.xml from the original rar, and then an ironjacamar.xml configuration file. Both of those are placed in the config rar's META-INF folder.
对于每个给定的卖方RAR,可以使用Iron Jacamar 1.1下载中包含的 rar-info.sh 生成 ironjacamar.xml 文件.标题为 10.1的部分中介绍了该过程.资源适配器信息工具 int 用户指南.
For each given vendor RAR, the ironjacamar.xml file can be generated using rar-info.sh which is included in the Iron Jacamar 1.1 download. The procedure is described in the section titled 10.1. Resource adapter information tool int the user guide.
以ActiveMQ 5.8.0为例:
Using ActiveMQ 5.8.0 as an example:
生成的 ironjacamar.xml 是从 rar-info.sh 输出的完整输出中提取的.在文件中,其标题为:
The generated ironjacamar.xml is extracted from the full output of the rar-info.sh output. Within the file, it is titled:
Deployment Descriptor:
----------------------
提取的文件的一部分,将成为 ironjacamar.xml ,在该标头之后开始,并以</resource-adapters> 结尾.
The extracted part of the file that will become ironjacamar.xml starts after that header and ends with </resource-adapters>.
应应用以下修改:
- 删除开头的
<resource-adapters>
和<resource-adapter>
标签,并替换为<ironjacamar.xml>
开头的标签. - 删除开头的
<archive>
标签. - 删除结束的
</resource-adapter>
和</resource-adapters>
标签,并替换为</ironjacamar.xml>
结束标签.
- Remove the opening
<resource-adapters>
and<resource-adapter>
tags and replace with an<ironjacamar.xml>
opening tag. - Remove the opening
<archive>
tag. - Remove the closing
</resource-adapter>
and</resource-adapters>
tags and replace with an</ironjacamar.xml>
closing tag.
对于每种连接类型(连接,队列和主题),都有连接工厂的示例定义,其中包括JBoss将工厂绑定到的JNDI名称.视需要编辑它们.我只需要Connection工厂,所以我编辑了JNDI名称并删除了其他两个定义.
There are sample definitions for connection factories for each type of connection (Connection, Queue and Topic) which include a JNDI name where JBoss will bind the factories to. Edit these as you see fit. I only needed the Connection factory so I edited the JNDI name and deleted the other two definitions.
有一些目标引用的示例定义(对于ActiveMQ几乎是不必要的,但对其他人有帮助).一个用于队列,一个用于主题.视需要编辑它们.
There are sample definitions for destination references (which are almost un-necessary with ActiveMQ, but it's helpful for others). One for a queue, one for a topic. Edit these as you see fit.
maven依赖项:
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-rar</artifactId>
<version>5.8.0</version>
<type>rar</type>
</dependency>
可部署的EAR看起来像这样:
The deployable EAR looks like this:
sample.ear
META-INF
application.xml
activemq-rar.rar (file)
activemq-config.rar (directory)
ra.xml (extracted from activemq-rar.rar or generated)
ironjacamar.xml (generated, then edited)
实际上,可以从真实" rar中提取ra.xml,但它也是在IronJacamar rar-info.sh 输出文件中生成的,因此请从任一文件中获取.
Actually, the ra.xml can be extracted from the "real" rar, but it is also generated in the IronJacamar rar-info.sh output file, so take it from either.
application.ear 如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/application_6.xsd" version="6">
<display-name>JBoss7Sample Ear</display-name>
<!-- Sample for WebSphereMQ
<module><connector>wmq.jmsra.rar</connector></module>
<module><connector>wmq-config.rar</connector></module>
-->
<module><connector>activemq-rar.rar</connector></module>
<module><connector>amq-config.rar</connector></module>
</application>
要再次强调,这种解决方法(实际上非常简单)对我来说很重要,因为任何以编辑服务器文件..... 或" 在管理控制台中......是我要定位的环境中的入门级软件.我无需假定对原始JBoss 7(EAP 6.1)内部目录的访问权限,也无需对控制台的访问权限,
To re-emphasize, this (actually quite simple) work around is important to me because any deployment procedure that starts with "Edit the server file called..... or "In the management console....." is a non-starter in the environment I am targeting. I need to assume no access to a vanilla JBoss 7 (EAP 6.1) internal directories, nor access to the console, as one might deploy at the end of a Jenkins build or the like.. (Not to mention which, editing files to add a deployment is a non-starter all by itself).
可以在此 github项目中更详细地查看此替代方法和其他方法,以进行共享我发现有些工作配置很难实现.
This workaround and others can be viewed in more detail in this github project which was setup specifically to share some working configurations which I have found are otherwise fairly difficult to come by.
建议.由于这是唯一提供的答案,因此我会向自己授予正确的答案,但我会放弃以获得更好的答案.
P.S. Since this is the only offered answer, I am awarding the correct answer to myself, but I'll give it up for a better answer.
这篇关于如何在JBoss 7中部署资源适配器激活?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!