如何将数据从应用程序传递到 JCA 资源适配器?
我想配置一个自己编写的JCA 1.6入站资源适配器(RA)。我的大问题是 RA 需要访问使用 RA 的应用程序中的一些(动态)配置数据。 现在我知道这违背了整个 JCA 想法的最初想法,但不幸的是我无法尽快改变这个设计。 我需要到达 RA 的数据是
- 它应该侦听的端口、
- 用于整个应用程序的许可证(RA 提供的功能需要额外的许可证)
- 存储在数据库中的附加配置数据
我提出了四个想法:
- 使用 asadmin create-resource-adapter-config。由于 glassfish 似乎不会根据 RA 重新启动应用程序,因此我们需要在此之后重新启动应用程序。虽然此尝试适合该端口,但不适合其他数据。
使用管理对象为我的应用程序提供将数据传递到 RA 的方法。这个想法被提到在这里。我想这可以做到,但规范在第 13.4.2.3 章中指出
<块引用>注意,管理对象不用于设置异步消息 传送到消息端点。 ActivationSpec JavaBean 用于保存所有 异步消息传递所需的必要激活信息 设置。
但是我无法将任何动态数据获取到 ActivationSpec 对象(无论是通过 DeploymentDescriptor 还是通过注释)。或者我在这里错过了什么? :-)
直接使用 JDBC 访问数据(也从 此处)。虽然这可能是最好的想法,但它不适用于提到的许可数据,因为它没有存储在数据库中。
我的最后一个想法是在 MessageDrivenBean 中放置一个方法(通过我的接口),用于从 RA 中获取数据。该方法可以从 RA 调用并提供数据。但是:我只是认为这是相当滥用的,因为它将 RA 耦合到应用程序。
亲爱的社区,您对此有何看法?恐怕要找到这些问题的答案并不容易,所以我很乐意听取意见!
谢谢和欢呼, 朱利叶斯
I want to configure a self-written JCA 1.6 inbound resource adapter (RA). My big problem is that the RA needs to get access to some (dynamic) configuration data living in the application that uses the RA.
Now I know that this is against the original idea of the whole JCA idea but unfortunately I cannot change this design as quickly as I'd like/have to.
The data I need to get to the RA is
- the port it's supposed to listen on,
- the license used for the whole application (the feature the RA supplies requires extra licensing)
- additional configuration data stored in a db
I've come up with four ideas:
- Use the asadmin create-resource-adapter-config. Due to the fact that glassfish doesn't seem to restart apps depending on the RA, we need to restart the application after this. While this attempt is suitable for the port, it won't fit for the other data.
Use administered objects to give my application a means to pass data in to the RA. This idea is mentioned here. I guess this does it, but the spec states in chapter 13.4.2.3 that
Note, administered objects are not used for setting up asynchronous message
deliveries to message endpoints. The ActivationSpec JavaBean is used to hold all
the necessary activation information needed for asynchronous message delivery
setup.But I cannot get any dynamic data to the ActivationSpec object (neither through a DeploymentDescriptor nor through annotations). Or did I miss something here? :-)
Use JDBC directly to access the data (also grabbed the idea from here). While this is presumably the best idea, it does not work for the mentioned licensing data as it is not stored in the db.
The last idea I had was to put a method in the MessageDrivenBean (through my interface) that is used to fetch data from within the RA. That method could be called from the RA and would supply the data. But: I just think that is quite abusive as it couples the RA to the app.
Dear community, what are your thoughts on this one? I'm afraid it's not so easy to find answers to these questions, so I'd be quite happy about opinions!
Thanks and cheers,
Julius
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 ra.xml 中可以定义配置属性。在 Websphere 中,这些内容将在所选资源适配器的自定义属性表中显示为可编辑字段。我正在解决类似的问题,我还需要将主机名/端口信息传递给 RA。不幸的是,我还没有弄清楚如何从 RA 中读取这些字段的内容。
In the ra.xml there is the possibility to define config-properties. In Websphere these then show up as editable fields in a table of custom properties for the selected resource adapter. I'm working on a similar problem, I also need to pass hostname / port info to an RA. Unfortunately I haven't figured out how to read the contents of these fields from within the RA however.
我最终想出的解决方案是使用@ConfigProperty注释。这意味着我使用上面问题的选项一。
因此,我的
ResourceAdapter
类如下所示:符来设置
@ConfigProperty
字段,现在可以重新配置这些设置我使用 glassfish 的 REST 接口 以编程方式更改这些设置(也可以使用
asadmin create-resource-adapter-config
命令)。我规避了这个问题,即 glassfish 不会通过简单地通过 REST 自行重新启动使用资源适配器的应用程序来重新启动该应用程序。 (准确地说:我禁用该应用程序,然后重新启用它以绕过 glassfish 中的另一个错误)一些附加说明:
希望这有帮助。 kutuzof,这会让你更进一步吗?
The solution I finally came up with is to use the
@ConfigProperty
annotation. This means I use option one of my question above.So my
ResourceAdapter
class looks like this:The
@ConfigProperty
fields can now be set through eitherNow in order to reconfigure these settings I use glassfish's REST interface to change these settings programmatically (one could also use the
asadmin create-resource-adapter-config
command). I circumvent the problem, that glassfish does not restart the application that uses the resource adapter by simply restarting it myself through REST. (To be precise: I disable the application and then reenable it to get around another bug in glassfish)A few additional notes:
Hope this helps. kutuzof, will this get you any further?