0

I want to emit a user defined Ignite event but haven't found any examples or implementations other than the Ignite sources, which uses non-API methods.

Can someone explain how to do this?

TIA

ttuna
  • 111
  • 1
  • 9

2 Answers2

1

Updated with respect to the latest replies:

There is a set of predefined EventTypes and you can't add a new one or embed a custom logic inside Ignite's internals without recompiling the sources which is too complex and impractical from my point of view.

As an alternative, you can use the Ignite Messaging.

Ignite ignite = Ignition.ignite();

IgniteMessaging rmtMsg = ignite.message(ignite.cluster().forRemotes());

// Add listener for ordered messages on all remote nodes.
rmtMsg.remoteListen("MyOrderedTopic", (nodeId, msg) -> {
    System.out.println("Received ordered message [msg=" + msg + ", from=" + nodeId + ']');

    return true; // Return true to continue listening.
});

// Send ordered messages to remote nodes.
for (int i = 0; i < 10; i++)
    rmtMsg.sendOrdered("MyOrderedTopic", Integer.toString(i), 0);

Check these examples and the documentation.

Alexandr Shapkin
  • 2,350
  • 1
  • 6
  • 10
  • Thank you for your answer. But I'm afraid that's not what I'm looking for. I want to emit a user defined event (-extended from EventAdapter class). – ttuna Sep 17 '21 at 06:16
  • Can you provide an example of a custom message? What you'd like to capture and why messaging or existing events couldn't solve that case? – Alexandr Shapkin Sep 17 '21 at 10:09
  • The reason why I want to generate a user event is because of the situation that a putAll-call results in EVT_CACHE_OBJECT_PUT events for each entry written to a cache. To avoid this I want to emit a single event after a successfull putAll(). – ttuna Sep 17 '21 at 11:06
  • Well, to embed a new PUTALL event you need to update the sources and recompile Ignite somehow. I've updated the answer with respect to the latest replies – Alexandr Shapkin Sep 17 '21 at 11:57
  • Why do you need this PUTALL signal by the way? What's the next logic? Is it just a successful loading indicator or do you need all the updated values? – Alexandr Shapkin Sep 17 '21 at 11:58
  • Thanks for your effort. I have found a solution for my problem. BTW: It's not entirely true that you can't create new EventTypes. It's possible to use your own event ids if you respect the reserved id range (0-1000). – ttuna Sep 17 '21 at 12:03
0

After re-reading the docs i found a useful hint.

The brief description of recordLocal(Event evt): Brief description

After browsing the details i recognised the hint (marked in red) Detailed description

So for local events "record" means "store and publish". It's somehow misleading ... but hey, it works :-)

ttuna
  • 111
  • 1
  • 9