如何将数据从应用程序传递到 JCA 资源适配器?

发布于 2024-12-16 20:42:24 字数 1237 浏览 5 评论 0原文

我想配置一个自己编写的JCA 1.6入站资源适配器(RA)。我的大问题是 RA 需要访问使用 RA 的应用程序中的一些(动态)配置数据。 现在我知道这违背了整个 JCA 想法的最初想法,但不幸的是我无法尽快改变这个设计。 我需要到达 RA 的数据是

  • 它应该侦听的端口、
  • 用于整个应用程序的许可证(RA 提供的功能需要额外的许可证)
  • 存储在数据库中的附加配置数据

我提出了四个想法:

  1. 使用 asadmin create-resource-adapter-config。由于 glassfish 似乎不会根据 RA 重新启动应用程序,因此我们需要在此之后重新启动应用程序。虽然此尝试适合该端口,但不适合其他数据。
  2. 使用管理对象为我的应用程序提供将数据传递到 RA 的方法。这个想法被提到在这里。我想这可以做到,但规范在第 13.4.2.3 章中指出

    <块引用>

    注意,管理对象不用于设置异步消息 传送到消息端点。 ActivationSpec JavaBean 用于保存所有 异步消息传递所需的必要激活信息 设置。

    但是我无法将任何动态数据获取到 ActivationSpec 对象(无论是通过 DeploymentDescriptor 还是通过注释)。或者我在这里错过了什么? :-)

  3. 直接使用 JDBC 访问数据(也从 此处)。虽然这可能是最好的想法,但它不适用于提到的许可数据,因为它没有存储在数据库中。

  4. 我的最后一个想法是在 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:

  1. 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.
  2. 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? :-)

  3. 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.

  4. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

黎歌 2024-12-23 20:42:24

在 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.

束缚m 2024-12-23 20:42:24

我最终想出的解决方案是使用@ConfigProperty注释。这意味着我使用上面问题的选项一。

因此,我的 ResourceAdapter 类如下所示:

public class Hl7ResourceAdapter implements ResourceAdapter {
    @ConfigProperty
    private Integer port = null;

    // Rest from ResourceAdapter interface omitted here...

    // Use port here to open socket...
}

符来设置 @ConfigProperty 字段

  • 现在可以通过资源适配器配置
  • ra.xml 部署描述

,现在可以重新配置这些设置我使用 glassfish 的 REST 接口 以编程方式更改这些设置(也可以使用 asadmin create-resource-adapter-config 命令)。我规避了这个问题,即 glassfish 不会通过简单地通过 REST 自行重新启动使用资源适配器的应用程序来重新启动该应用程序。 (准确地说:我禁用该应用程序,然后重新启用它以绕过 glassfish 中的另一个错误

一些附加说明:

  • 我们将资源适配器的 .rar 文件部署到使用它的应用程序的 .ear 中。
  • 我们在 glassfish 之外有一个单独的应用程序(独立),它调用 REST 接口来执行诸如重新启动资源适配器应用程序等操作。很明显,应用程序无法正确重新启动自身。

希望这有帮助。 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:

public class Hl7ResourceAdapter implements ResourceAdapter {
    @ConfigProperty
    private Integer port = null;

    // Rest from ResourceAdapter interface omitted here...

    // Use port here to open socket...
}

The @ConfigProperty fields can now be set through either

  • a resource-adapter-config
  • the ra.xml deployment descriptor

Now 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:

  • We deploy the resource adapter's .rar file into the .ear of the application using it.
  • We have a separate application outside glassfish (standalone) that calls the REST interface to do such things as restart the resource adapter application etc. It is obvious that an application cannot restart itself properly.

Hope this helps. kutuzof, will this get you any further?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文