Thank you Łukasz, JB and Erwin. I’ll deep dive on it.
> On 17 May 2020, at 22:16, Erwin Hogeweg <[email protected]> wrote:
>
> Hi Davi,
>
> You can absolutely use the EventAdmin for your ‘own’ events. There are many
> ways to accomplish this. My preference is to use the component annotations.
>
> The class that generates the event needs a reference to the EventAdmin, like
> so:
>
> @Reference
> private EventAdmin eventAdmin;
>
> …
> eventAdmin.postEvent(new Event(YOUR_TOPIC, eventProperties));
>
> And the class(es) that consume the event need to register the event topic
> they are interested in like so:
>
> @Component(
> property = {
> EventConstants.EVENT_TOPIC + "=" + YOUR_TOPIC
> })
> public class YourClass implements EventHandler {
> …
>
> @Override
> public void handleEvent(Event event) {
> // Do your event thing here
> }
>
> Cheers,
>
> Erwin
>
>
>> On May 17, 2020, at 20:53, Davi Baldin Tavares <[email protected]
>> <mailto:[email protected]>> wrote:
>>
>> Hi all,
>>
>> I would like to add an event driven communication to my app. For example if
>> some sort of data (pattern) is going to be saved into database by the DAO
>> service, an event should be raised and broadcasted to other
>> bundle/services/listeners. Instead of writing my own “AMQP” framework, can
>> I reuse current Karaf EventAdmin implementation? Event propagation is only
>> required inside the same instance and the outside Comunication is not
>> necessary right now. It is ok to extend the EventAdmin usage beyond bundle
>> lifecycle and framework stuff?
>>
>> Thanks,
>>
>> Davi
>