How to subscribe Global Events Add-on at UI and Core

Hi CUBA,

Need your guidance on how to subscribe Global Event at core and web module.

Not sure if I miss or overlook. I couldn’t find the sample coding.
Could you provide me some sample coding, Please? :slight_smile:

Regards,
CK

In addition to the example, you can have a look at this PoC. Hope this will help.

Thank You Andrey.

Some minor questions on the Global Events.

  1. Can we subscribe the Global Events at Core Module?
  2. Can we subscribe @Components at Web module subscribe Global Events?
  3. In Cluster, do I need to publish the events differently ? E.g. use ClusterManagerAPI

Regards,
CK

In the PoC that I mentioned in my previous post, you can find com.company.globaleventspoc.service.GlobalEventsServiceBean class in the core module. So, yes.

In the example provided in the add-on’s readme file there is a special bean in the web module. So, yes.

I don’t think so, the add-on should take care about its environment when dealing with global events. In addition to this, the CoreBroadcaster class uses ClusterManagerAPI to handle events.

1 Like

Hi Andrey,

Thank You for your guidance.

Regards,
CK

Hi Andrey,

Another question before close the thread.

In cluster environment,

web1 -> core1
web3 -> core1

web2 -> core2

Trigger GlobalUIEvent at core 1, I’m sure web 1 and web 3 will receive based on the documentation.

Will core 2 receive the GlobalUIEvent then forward it to web 2 ?

Regards,
CK

Hi, I guess it should work like this. And what are you trying to do, what is the task? Global events is a pretty basic feature providing simple functionality. For more advanced tasks it would be better to use a message queue system like RabbitMQ or Kafka I guess.

Hi Andrey,

I want to have something trigger at core then web to pick up (e.g. subscribe). E.g. some notification msg.

I plan to subscribe the event at MainScreen.
To do this, I could reduce the coding. I don’t need to implement the msg/ notification checking per screen or using polling method.

Previously, I was using polling with timer at MainScreen. It causing me a lot of additional call from web -> core

Regards
CK

I see, in this case, Global events should do. Hope they work well.

1 Like