Starting Gateway Application

After implementing GatewayApplication and ServiceHandlers, the application must declare itself to the framework using the DiffusionGatewayFramework.start method. In this method, the application and the framework will be initialized and started. During the application initialization, the framework will call back on the application via its getApplicationDetails method to obtain basic details about the application and the ServiceType and SharedConfig types that it supports. Subsequently, the initialize method of the GatewayApplication will also be called with an instance of ApplicationContext that contains application configuration details and other resources, which the application can use to initialize any resources as required.

After the initialization of the application, a connection to the Diffusion server, using configured Diffusion connection details, will be established, and the application will be registered with the server. See Bootstrap configuration and configuring Diffusion connection details via a configuration file to understand how to supply Diffusion connection details when starting the application.

Once the framework has successfully connected to Diffusion and retrieved the configuration, it calls the GatewayApplication.start method of the application. If services are included in the application’s configuration, the framework adds these services. Subsequently, the framework calls upon the application’s add methods to obtain a service handler corresponding to the defined services in the configuration.

The Diffusion Gateway framework can be started in method main of the application.

Example 1. Example: Initialization of the Framework by passing instance of GatewayApplication implementation and starting the framework
    public static void main(String[] args) {
        DiffusionGatewayFramework.start(new CsvFileSinkApplication());

Now the application can be started by running the main method. See here to understand how to configure and run a Gateway application.

The interactions between the framework and application are presented in the sequence diagram below:

Figure 1. application-framework interactions

The diagram below provides a detailed sequence of events that take place in the Gateway application after it is initiated by a user and services are added to the application.

application lifecycle
Figure 2. Sequence diagram for Gateway application