Esempio n. 1
0
def async_streamer(channel_name):
    for counter in range(1):
        yield Event(
            metadata="some-metadata",
            body=("hello kubemq - sending event wildcards :{}".format(counter)).encode('UTF-8'),
            store=False,
            channel=channel_name+'.A',
            client_id="python-sdk-cookbook-pubsub-events-wildcards-sender",
        )
        yield Event(
            metadata="some-metadata",
            body=("hello kubemq - sending event wildcards :{}".format(counter)).encode('UTF-8'),
            store=False,
            channel=channel_name+'.B',
            client_id="python-sdk-cookbook-pubsub-events-wildcards-sender",
        )
Esempio n. 2
0
def async_streamer(channel_name):
    for counter in range(2):
        yield Event(
            metadata="some-metadata",
            body=("hello kubemq - sending event :{}".format(counter)
                  ).encode('UTF-8'),
            store=True,
            channel=channel_name,
            client_id="python-sdk-cookbook-pubsub-events-store-stream-sender",
        )
Esempio n. 3
0
            SubscribeType.EventsStore,
            'python-sdk-cookbook-pubsub-events-store-load-balance-v',
            EventsStoreType.StartFromFirst, 0, channel, group_name)
        subscriber_c.subscribe_to_events(subscribe_request_c,
                                         handle_incoming_events_receiver_c,
                                         handle_incoming_error, cancel_token)
    except Exception as err:
        print('error, error:%s' % (err))
    sleep(3)
    limit = 5
    sender = Sender("localhost:50000")
    for i in range(limit):
        event = Event(
            metadata="some-metadata",
            body=(
                "hello kubemq - sending event :{}".format(i)).encode('UTF-8'),
            store=True,
            channel=channel,
            client_id=
            "python-sdk-cookbook-pubsub-events-store-load-balance-sender")
        event.tags = [
            ('key', 'value'),
            ('key2', 'value2'),
        ]
        try:
            sender.send_event(event)
        except Exception as err:
            print('error:%s' % (err))
    sleep(1)
    cancel_token.cancel()