简体   繁体   中英

Hazelcast client streaming API

I'm using Hazelcast multimap. how to create streaming API for Hazelcast multimap listener based on my key. I need to use that API in any frontend applications. if any changes come into the Hazelcast map that needs to be reflected into the API.

import logging

import hazelcast

logging.basicConfig(level=logging.INFO)

client = hazelcast.HazelcastClient()

multi_map = client.get_multi_map("test").blocking()


def on_entry_added(entry_event):
    print(entry_event)
    # Do something with the event.
    # Do not perform blocking operations here.
    # If you need to perform blocking operations
    # offload them to another thread.


multi_map.add_entry_listener(
    include_value=True,
    key="your key",
    added_func=on_entry_added,
)


for i in range(1000):
    multi_map.put("your key", i)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM