Book a Demo

Author Topic: Broadcast an event to all instances of an Addin/Extension  (Read 3999 times)

Ian Mitchell

  • EA User
  • **
  • Posts: 507
  • Karma: +22/-4
  • The eaDocX and Model Expert guy
    • View Profile
Broadcast an event to all instances of an Addin/Extension
« on: December 07, 2019, 01:59:58 am »
I have an addin which is used by both a model manager - for doing important changes to some model rules - and by regular modellers.
For performance reasons, whist the modellers are working they use a cached version of the rules (there are lots) but I need a way for the model manager to force every active instance of the addin to refresh it's copy of the rules. (when a modeller restarts EA it will refresh anyway - but this is for those bad people like me who have EA open 24/7)
A perfect solution would be for model manager's instance of the Addin to create an event, which is then picked-up by all the other instances, but there doesn't look to be such a thing.
Another solution would be to have a place in the model where the manager instance can write data, which could then be constantly examined by the modeller instances for any changes, but that would be building a performance bottleneck. And rubbish.
Has anyone solved this ?
Thanks
Ian Mitchell, Designer, eaDocX


www.eaDocX.com
www.theartfulmodeller.com

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Broadcast an event to all instances of an Addin/Extension
« Reply #1 on: December 07, 2019, 02:57:46 am »
You (more or less) can't solve that. EA uses a DB to query it, but does not receive events. You "might" set up a framework to communcate concurrently from your add-in (via whatever message queue you prefer) and do tricky things you need. I guess that would be possible. But definitely a lot of work.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Broadcast an event to all instances of an Addin/Extension
« Reply #2 on: December 07, 2019, 03:16:49 am »
I did something similar for my EA-Matic scripts.
If someone updates the scripts in EA, I would have liked all the other users of the add-in to get notified, so the scripts could be refreshed.

Since that was not possible (the update of scripts doesn't event trigger any events, so my add-in is not aware of any) I added a check to validate if any of the script had changed. This check is performed on any of the broadcast events, if the previous check was more than 5 minutes ago.

So effectively, a change to an EA-Matic script is being propagated to all users within 5 minutes. (you can still trigger a refresh manually by opening the settings window)

What I did in order to validate if anything had changed, is to store the hash of all scripts together in memory.
Then when I check again, I make a new hash, and compare that to the hash in memory.

I guess you could do something similar. Every 5 minutes or so make a hash of all your rules, and compare that to the previous one. If there is a difference you know you need to refresh the rules.

If you control the changes from within the add-in, you can set a flag somewhere in the database to indicate that you've changed the rules. If you use a new GUID each time you update the rules, the running instances can check that GUID against the one that is loaded. If it's different, they need to refresh.

Geert

Ian Mitchell

  • EA User
  • **
  • Posts: 507
  • Karma: +22/-4
  • The eaDocX and Model Expert guy
    • View Profile
Re: Broadcast an event to all instances of an Addin/Extension
« Reply #3 on: December 09, 2019, 09:28:27 pm »
Thanks Geert/Q - I was just checking I didn't miss something.
I'll pass this along to my customer, and see if they like it. I'm always nervous about solutions like this, where lots of clients are regularly  reading a single part of the model..(I like your 5-minute check - i should reduce the volume a lot)
Thanks guys.
Ian Mitchell, Designer, eaDocX


www.eaDocX.com
www.theartfulmodeller.com