# Modules Dependencies

**URL:** <https://forum.inductiveautomation.com/t/modules-dependencies/100514>\
**Category:** Module Development\
**Tags:** ignition81\
**Created:** [January 7, 2025, 2:12am UTC](https://forum.inductiveautomation.com/t/modules-dependencies/100514 "2025-01-07T02:12:26Z")\
**Posts on this page:** 8\
**Page:** 2

<div class="post-metadata">

**Author:** ![Grace\_Gan](https://avatars.discourse-cdn.com/v4/letter/g/e5b9ba/32.png) [@Grace\_Gan](https://forum.inductiveautomation.com/u/Grace_Gan)\
**Post date:** [January 8, 2025, 8:00pm UTC](https://forum.inductiveautomation.com/t/modules-dependencies/100514/22 "2025-01-08T20:00:15Z")

</div>

So how would you recommend to do if I would like to store a data in the gateway (in my case - select a database connection) in module A, and my module B will work closely with module A such that it'll also be reading the stored data from module A (but it won't be updating the stored value, the stored value will be updated from module A only)

I am currently using persistent record in module A to store such data hence why I am trying to access the persistent record from module B, but is there a better way of doing so? Or should I just redefine the persistent record in module B and access it that way?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 8, 2025, 8:07pm UTC](https://forum.inductiveautomation.com/t/modules-dependencies/100514/23 "2025-01-08T20:07:04Z")

</div>

I'm confused about your use-case. What **kind** of data are you talking about? Persistent records are for your modules' **configuration** data, not any kind of runtime data. Runtime data should be routed through your gateway's datasource interface, not via persistent records.

---

<div class="post-metadata">

**Author:** ![Grace\_Gan](https://avatars.discourse-cdn.com/v4/letter/g/e5b9ba/32.png) [@Grace\_Gan](https://forum.inductiveautomation.com/u/Grace_Gan)\
**Post date:** [January 8, 2025, 8:17pm UTC](https://forum.inductiveautomation.com/t/modules-dependencies/100514/24 "2025-01-08T20:17:29Z")

</div>

My module will be working with a database which the user will have the set a database connection up from the gateway, and from the module the user can select a database that they want to work with from the list of available database connections.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 8, 2025, 8:36pm UTC](https://forum.inductiveautomation.com/t/modules-dependencies/100514/25 "2025-01-08T20:36:00Z")

</div>

I get that part. You don't need any persistent records for that. What are you trying to store in the persistence interface? Why would your module B need to access module A's configuration in record form, instead of including in module A some method of delivering that information as a simple java object? (_ **Configuration data!** _)

---

<div class="post-metadata">

**Author:** ![Grace\_Gan](https://avatars.discourse-cdn.com/v4/letter/g/e5b9ba/32.png) [@Grace\_Gan](https://forum.inductiveautomation.com/u/Grace_Gan)\
**Post date:** [January 8, 2025, 9:35pm UTC](https://forum.inductiveautomation.com/t/modules-dependencies/100514/26 "2025-01-08T21:35:09Z")

</div>

I want to store the database name of the database that the user select to connect to (From the list of database connections). So that in module A and B I can work with the selected database. The nice thing with using persistent record is that the data will still be stored persistently through module upgrades (as I want the user the select the database once and not having to worry about it anymore in most cases). I am also making use of the record change listener to listen to changes to the selected database so other parts of my module can react accordingly when the database selection has been changed.

> [@pturmel](#):
>
> instead of including in module A some method of delivering that information as a simple java object? (_ **Configuration data!** _)

Not too sure what you meant by the configuration data here, could you elaborate a little more please.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 8, 2025, 9:47pm UTC](https://forum.inductiveautomation.com/t/modules-dependencies/100514/27 "2025-01-08T21:47:06Z")

</div>

> [@Grace\_Gan](#):
>
> database that the user select to connect to

Per user? Or for the entire site? If the latter, it is reasonable to be stored in a persistent record. Otherwise it is runtime data that should be stored in a DB connection specified in the designer (probably best to be the default DB of the project).

But either way, your module A gateway hook should simply expose an instance method that delivers the desired information to all callers. The module B boundary class can simply call that method to obtain the current setting any time it needs it. No need to access A's persistent record from module B.

(Is this all related to having a UI component do its own queries? You seems to have the poster child for why that is a bad idea.)

---

<div class="post-metadata">

**Author:** ![Grace\_Gan](https://avatars.discourse-cdn.com/v4/letter/g/e5b9ba/32.png) [@Grace\_Gan](https://forum.inductiveautomation.com/u/Grace_Gan)\
**Post date:** [January 8, 2025, 10:29pm UTC](https://forum.inductiveautomation.com/t/modules-dependencies/100514/28 "2025-01-08T22:29:18Z")

</div>

For the entire site (gateway)

> [@pturmel](#):
>
> But either way, your module A gateway hook should simply expose an instance method that delivers the desired information to all callers. The module B boundary class can simply call that method to obtain the current setting any time it needs it. No need to access A's persistent record from module B.

This make sense, will make sure to try it out.

Is it possible to have module B being notified for the change to the persistent record (like what the listener does) from module A to have a more event-driven approach rather than polling?

(Not for these two modules that I'm querying for)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 8, 2025, 10:37pm UTC](https://forum.inductiveautomation.com/t/modules-dependencies/100514/29 "2025-01-08T22:37:19Z")

</div>

You could define a listener interface in module A, have B implement it, and register itself with module A using an appropriate method. Then module A can relay change notifications to interested modules.

[Previous page](https://forum.inductiveautomation.com/t/modules-dependencies/100514.md?page=1)
