

Provided that there are correct permission patterns and that relevant topics already exist, each REST or Python (service) endpoint may subscribe to one or more topics.
Note that services can subscribe to two kinds of topics:
Messages can be sent on a notify or pull basis. The former means that Zato itself will be invoking the endpoint with new messages whereas pull means that Zato will queue messages up and the recipient itself will periodically read the contents of its queue.
Each endpoint may subscribe to topics multiple types and each time it is given a new subscription key - this is a secret that must be known only to the participant to whom it was issued.
When Zato pushes a message to a subscribing service, the service's handle method is invoked with the message data available through self.request.input.
A service without a declared input model receives the raw published data as a dictionary:
from zato.server.service import Service
class MySubscriber(Service):
def handle(self):
# .. the published data is available as a dictionary ..
data = self.request.input['data']
customer_name = data['customer_name']
customer_id = data['customer_id']
self.logger.info('Received customer: %s (%s)', customer_name, customer_id)
If the subscribing service declares an IO.input data model, the published data is automatically parsed against the model. The self.request.input attribute becomes an instance of the model class with typed fields:
from dataclasses import dataclass
from zato.server.service import Model, Service
@dataclass(init=False)
class CustomerEvent(Model):
customer_name: str = ''
customer_id: int = 0
class MySubscriber(Service):
class IO:
input = CustomerEvent
def handle(self):
# .. self.request.input is a CustomerEvent instance ..
customer_name = self.request.input.customer_name
customer_id = self.request.input.customer_id
self.logger.info('Received customer: %s (%s)', customer_name, customer_id)