1. Simplicity and Speed: Spring Boot simplifies the development process by providing a wide range of pre-configured templates, which significantly speeds up application setup and deployment. This is crucial when implementing adapters for real-time data streaming services like Lightstreamer.
2. Integration Capabilities: Spring Boot offers a powerful and easy-to-use way to integrate with various technologies and protocols. When building remote adapters for Lightstreamer, it's essential to seamlessly connect to different data sources, and Spring Boot excels in this regard.
3. Dependency Management: Spring Boot simplifies dependency management through its built-in dependency injection system. This is valuable when dealing with the complexities of remote data integration, as it streamlines the handling of external libraries and components.
4. Configuration Management: Spring Boot provides a highly flexible configuration system that allows you to externalize configuration properties. This feature is essential when configuring various adapter endpoints and handling dynamic changes in adapter behavior.
5. Auto-Configuration: Spring Boot's auto-configuration feature automatically sets up the application based on its dependencies. When developing Lightstreamer adapters, this functionality simplifies the initialization process, reducing the need for manual configuration.
6. Testing and Debugging: Spring Boot offers excellent support for testing and debugging, helping you ensure the reliability and performance of your Lightstreamer adapters.
7. Scalability: Spring Boot is designed with scalability in mind. As your application grows and the demand for real-time data increases, Spring Boot's architecture allows for easy horizontal scaling, ensuring your Lightstreamer adapters can handle more connections.
8. Community and Ecosystem: Spring Boot boasts a vibrant community and a rich ecosystem of libraries, plugins, and tools. This provides access to a wealth of resources for solving problems and optimizing your Lightstreamer adapters.
In summary, Spring Boot simplifies the development of stand-alone applications that implement remote adapters for Lightstreamer by offering a wealth of features, from simplified configuration and integration capabilities to robust testing and scalability options.
Leveraging the power of Spring Boot can streamline your development process and ensure that your Lightstreamer adapters are efficient, reliable, and easy to maintain.
Moving the in-process chat demo adapter into a Spring Boot stand-alone application
We have revamped one of our most historical and popular demonstrations: the 'Basic Chat' demo. This demo includes an adapter implementation using the Java In-Process interface, running in the same JVM as the Lightstreamer kernel. To expand its accessibility, we've opted to present a remote version by creating a standalone application using Spring Boot.
The Lightstreamer - Basic Chat Demo serves as a straightforward chat application, relying on Lightstreamer for real-time communication. The client part of the demo uses the web application 'Basic Chat Demo - Web Client' and required no substantial changes.
Instead, in this application, adapters are implemented using Java Remote interfaces, and a utility class facilitates connections to the Lightstreamer server for Metadata and Data adapters. Conversely, the server part relies on previously developed Java adapters in in-process mode, specifically 'Basic Chat Demo - Java Adapter'. The Java code from this project, handling metadata and data adapters, has been repurposed for a standalone application context.
- ChatAdapterSpringbootApplication.java: Implements the ApplicationRunner interface of the Spring framework. The @Value annotation interprets input parameters for configuring the adapters.
- ServerStarter.java: A utility class facilitating the instantiation and launch of data and metadata adapters. It also manages TCP connections with the Lightstreamer server.
- ChatDataAdapter.java: Contains the source code for the Chat Data Adapter, which accepts message submissions for a unique chat room. The sender is identified by an IP address and a nickname. Additionally, chat history can be flushed based on an optional parameter.
- ChatMetaDataAdapter.java: Contains the source code for the metadata adapter, inheriting from the reusable LiteralBasedProvider. It adds simple support for message submissions but is not recommended as a reference for client-originated message handling due to the absence of guaranteed delivery and clustering support.
Build and Run the Demo
- Download Lightstreamer Server (Lightstreamer Server comes with a free non-expiring demo license for 20 connected users) from Lightstreamer Download page, and install it, as explained in the GETTING_STARTED.TXT file in the installation home directory.
- Create a folder called RemoteChat in the LS_HOME/adapters folder.
- Create a file named adapters.xml in the RemoteChat folder, with the contents from the section above.
- Launch Lightstreamer Server. The Server startup will complete only after a successful connection between the Proxy Data Adapter and the Remote Data Adapter.
- In a terminal window, with the working directory set to the chat-adapter-springboot folder of the GitHub project, run the following command:
./mvnw spring-boot:run "-Dspring-boot.run.arguments=--server.name=chat-spring
- Wait the connections with the Lightsreamer server, and then test the Adapter, launching the Lightstreamer - Basic Chat Demo - HTML Client
- To make the front-end pages get data from the newly installed Adapter Set, you need to modify the front-end pages and set the required Adapter Set name to PROXY_NODECHAT when creating the LightstreamerClient instance. So edit the lsClient.js file of the Basic Chat Demo front-end deployed under Lightstreamer/pages/ChatDemo and replace:
var lsClient = new LightstreamerClient(protocolToUse+"//localhost:"+portToUse,"CHAT");
with:var lsClient = new LightstreamerClient(protocolToUse+"//localhost:"+portToUse,"CHAT_REMOTE");
(you don't need to reconfigure the Data Adapter name, as it is the same in both Adapter Sets). - Open a browser window and go to: http://localhost:8080/ChatDemo
To Recap:
- The full source code of the demo can be found in this GitHub project: https://github.com/Lightstreamer/Lightstreamer-example-Chat-adapter-SpringBoot/
- The web client application of the Basic Chat Demo is live here: https://demos.lightstreamer.com/ChatDemo/
- An introduction to Spring Boot stand-alone application: https://spring.io/projects/spring-boot#overview
- The complete Lightstreamer Java Remote Adapter API reference: https://www.lightstreamer.com/api/ls-adapter-remote/latest/
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.