Breadcrumb
- Sabre Red 360 Software Development Kit Help
- Desktop Red Apps
- Communications in Red Apps
- Event Publishing
- Sample Process for Publishing Events
Sample Process for Publishing Events
You need a working Red App project with an Activator class.
-
Add the following required dependencies to your plug-in:
-
com.sabre.edge.cf.core
-
com.sabre.edge.cf.model
-
The bundle with the context request and response implementations from the event publisher
-
-
In your Java code, get the authentication token service. See the relevant step in Authenticating and Requesting Authorization to Use Services.
-
Add the following Java code to publish an event.
Create an Event object.
Event event = new Event();
Set the Event ID.
event.setId(Event id);
Set the Source ID. event.setSource(Red App ID);
Set the authentication token. event.setAuthKey(Activator.getDefault().getToken());
Create a ServiceContext object.
ServiceContext context = new ServiceContext();
Create a request object or a response object that is specific to the event. Set your request, your response, or both to the context. A response is optional.
context.setRequest(request);
context.setResponse(response);
event.setContext(context);
Call the process() method of SRWRuntime. Activator.getDefault().getServiceReference(ISRWRuntime.class).postEvent(event); Register your Event ID in redapp.xml. An example is shown below.
<RedApp id="Red App id">
<Event id="SAMPLE_EVENT_001" />
</RedApp>