Publishers and subscribers
How endpoints interact with topics and message queues - permissions, delivery types and configuration.

This page assumes familiarity with publish/subscribe concepts.
Overview
Publishers are clients that send messages to topics. Any client with appropriate publish permissions can publish messages to topics using the REST API. The publishers can be either REST-based or they can be in Python, which also includes your Zato services in Python.
Subscribers are clients that receive messages from topics they have subscribed to. Messages are delivered through message queues that are automatically created when a client subscribes to their first topic.
HTTP Basic Authentication is required for all REST API operations. Each client must provide valid credentials with every request to publish, subscribe, or retrieve messages. You can publish messages either to external REST-based systems or you can publish them to your Zato services.
Permissions
Pattern-based permissions control which topics a client can publish to or subscribe from. Permissions use wildcard patterns for flexible access control.
Single wildcard
*in permission patterns matches one topic segment. For example,pub=orders.*allows publishing toorders.processedandorders.cancelled.Multi-level wildcard
**in permission patterns matches multiple topic segments. For example,sub=alerts.**allows subscribing toalerts.critical,alerts.critical.system, and any deeper nested alert topics.Permissions are skipped for services which means that your Zato services can always publish messages to any topic, and they don't use any patterns at all, you can publish to any topic from any service.
Message Delivery
Pull-based delivery is used for REST API subscriptions where clients call the
/messages/getendpoint to retrieve messages on demand with configurable limits on message count and total data size.Push-based delivery can be configured for subscribers to have messages automatically delivered to their REST endpoints as soon as they arrive, without requiring polling. When you publish messages to services, Zato will always push messages to them, that is, your services don't ever pull messages from queues.
Automatic acknowledgment happens when messages are retrieved. Once pulled from the queue, messages are immediately removed and cannot be retrieved again.
How to create topics, subscriptions and permissions?
Use test config for experimentation
- Remember that you can start off by importing the test configuration - it's a set of demo credentials and topics, all configured to work together
- The username/password will be user.1/password.1
- You can import the test config multiple times - don't worry that you'll break anything, it's there specifically to let you play around and learn things in practice. You can delete or modify it at will and if you'd like to start over, simply click import again

Adding credentials and configuring permissions
- Start by going to
Security → HTTP Basic Authand adding new credentials, let's say it will be user.2/password.2 (don't forget to clickChange passwordtoo).

- Now go to
EDA → Topicsand create a new topic, e.g.my.topic.1

Now go to
EDA → Permissionsand assign permissions as in the example below.Each security definition can be a publisher, subscriber, or it can be both, and you can assign permissions to each role independently.

- At this point, you'll have the configuration sufficient to publish messages to topics, but you won't be able to receive them yet. This is because merely adding permissions for subscriptions doesn't create the actual subscriptions, so let's do that now.
Creating subscriptions
- Go to
EDA → subscriptions, select one of the security definitions and then select one of the topics you'd like for the security definition to subscribe to. Note that only the topics that this security definition has permissions for will display in the form.

Next, select how messages will be delivered for that subscription.
If you choose
Pullfor the delivery type - your subscribers will be able to use the REST API to access their messagesIf you choose
Push, this will tell Zato to deliver messages to either one of your services or to one of the REST outgoing endpoints (configured viaConnections → Outgoing → REST). In either case, the security definition that this subscription is for will still always be able to pull the messages on its own.
Getting started with EDA
- What is EDA?
What Event-Driven Architecture is and how it helps in systems integrations
- Topics and message queues
Understanding the concepts of topics that messages are published to and queues that messages are read from
- Publishers and subscribers
How APIs and systems can communicate with the broker to publish and subscribe to their messages
- Security and access control
How to grant and secure access to your topics and message queues