Contexts are logical divisions that act as markers for the event publishing URL. They allow topics to be reused in different scenarios.
The external authorization server is defined by context. This means that when two different contexts are made available for a topic, it is possible to use two distinct authorization endpoints for the same topic.
The Contexts screen lists all contexts registered in your Events Hub:
To understand how contexts work, it is important to know how the Events Hub coordinates event publishing and subscription:
To publish events, you need to create a path (URL) that serves as a channel for sending events from a publisher to the Events Hub.
This URL is composed of Base URL
+ context
+ handler
+ topic
:
event-receiver
+ a unique hash code.Example
Imagine you want to create a publishing flow for various types of alerts and test it without notifying subscribers. To do this, you can:
Create a handler called "Alerts" with the path
/alerts
.Register topics grouped under the handler. For example:
/latency
for latency alerts andapi-update
for API update alerts.Create a testing context (e.g.,
testing
) and enable it for the topic you want to test so that subscribers do not receive alerts.
To register subscribers in the testing context, you must link them to the topic and enable them only for the
testing
context.If no context is registered, the Events Hub sets "Default" as the standard, and no marker is added to the publishing URL. Thus, requests for the
latency
orapi-update
topics will be sent to<base-url>/alerts/latency
/<base-url>/alerts/api-update
, and all active subscribers will receive the events.
Based on the example above, the publishing URLs for the latency
topic will be:
<base-url>/alerts/latency
<base-url>/testing/alerts/latency
The main advantage of using different contexts is the ability to reuse security policy and delivery attempt configurations defined in the handler without creating new topics. Since authorization endpoints are defined by context, you can use a mock authorization for testing while keeping the default context authorization unchanged.
IMPORTANTContexts are logical divisions that simplify the creation and maintenance of topics, allowing them to be reused in different scenarios. They are not physically separated environments.
This means that if you use the "Default" context for production events and the "Testing" context for test events, you can control publishers, subscribers, and authorization endpoints for each context. However, all events received and distributed in the Events Hub share the same infrastructure.
Tests that overload the infrastructure, even in the testing context, may affect the receipt and distribution of events in other contexts.
The endpoints that validate publishers are defined for each context. This is done on the Authorizations screen, which contains two sections: OAUTH and JWT. Both display all contexts registered in the Events Hub, indicating the authorization URL defined for each.
Using security interceptors is optional. However, if you add policies to your handler, you need to configure the authorization URL linked to the interceptor. Except for "IP Filtering Validation," all depend on this configuration to function.
NOTELearn how to use the Sensedia API Platform for publisher authorization.
Contexts are linked to topics through the Topics tab when creating or editing handlers. To publish events, you associate topics and their contexts with publishers and subscribers as follows:
Publishers: in the Topics step during publisher registration, select the desired topics. You will see the available contexts for each topic.
Subscribers: when registering a subscriber, you must subscribe them to the topics from which they will receive events. By enabling topic contexts for them, they will only receive events from publishers active in the context.
You can create up to 5 contexts in the Events Hub. The "Default" context is standard and cannot be edited or deleted.
TIPWhen the limit of contexts is reached, the + button will be disabled, preventing the registration of new contexts. If you need a new context, you will need to delete one of the existing ones.
To create a new context, click the + button. Fill in the fields:
After registering, the context will appear in the TOPICS step of handler creation/editing and can be enabled for any topic.
Clicking on a context name will display the topics linked to it. On this screen, you can:
NOTEYou can only delete contexts that are not associated with any topic. If they are, you must disable the context in each topic before deleting it.
We use cookies to enhance your experience on our site. By continuing to browse, you agree to our use of cookies.Learn more