Publisher-subscriber patternΒΆ

In order to use the publisher-subscriber paradigm, you need to define at least one event transport

The currently implemented event transports are

  • gemstone.event.transport.RabbitMqEventTransport
  • gemstone.event.transport.RedisEventTransport
class ExampleService(gemstone.MicroService):
    # ...
    event_transports = ["redis://"),"redis://"),
        # ...
    # ...

After that, for publishing an event, you must call the gemstone.MicroService.emit_event() method

def some_method(self):
    self.emit_event("test_event", {"message": "hello there"})
    self.emit_event("method_calls", {"method": "some_method"})
    # ...

In order to subscribe to some kind of events, you need to designate a method as the event handler

def my_event_handler(self, event_body):"Received event: {}".format(event_body))


Event handler methods will be executed on the main thread, so they should not be blocking.