<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Arisusanto Lie on Medium]]></title>
        <description><![CDATA[Stories by Arisusanto Lie on Medium]]></description>
        <link>https://medium.com/@arisusantolie?source=rss-80ce1ecde4de------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*XDqkSNQ841CzfjlC</url>
            <title>Stories by Arisusanto Lie on Medium</title>
            <link>https://medium.com/@arisusantolie?source=rss-80ce1ecde4de------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 23:30:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@arisusantolie/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Spring Websocket With SockJS Using Database MySql Or MariaDB + Html Javascript]]></title>
            <link>https://medium.com/@arisusantolie/spring-websocket-with-sockjs-using-database-mysql-or-mariadb-html-javascript-21da7d71d936?source=rss-80ce1ecde4de------2</link>
            <guid isPermaLink="false">https://medium.com/p/21da7d71d936</guid>
            <category><![CDATA[websocket]]></category>
            <category><![CDATA[sockjs]]></category>
            <category><![CDATA[spring-boot-websocket]]></category>
            <category><![CDATA[websocket-chat-app]]></category>
            <category><![CDATA[stomp]]></category>
            <dc:creator><![CDATA[Arisusanto Lie]]></dc:creator>
            <pubDate>Tue, 31 Aug 2021 16:30:32 GMT</pubDate>
            <atom:updated>2021-08-31T16:30:32.831Z</atom:updated>
            <content:encoded><![CDATA[<p>Hi, In this section, I will create a real-time chat app using Spring boot Websocket for a backend, and Html + Javascript for a front end.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yAy3dEAnPEmRzXZ2wJ0drw.png" /><figcaption>Real Time Chat App Using Spring boot WebSocket.</figcaption></figure><p>First of all, we create a spring boot project from Shortcut <a href="https://start.spring.io/">start.spring.io</a>. Take a look at the dependency we need to add to our spring project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NoxXdvFgBsoN0mHf2Yi3Tw.png" /><figcaption>Start Spring.io</figcaption></figure><p>After we create the Spring Project WebSocket, <strong>Let’s get started.</strong></p><ol><li>First, we set up application properties for connection into database.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TA-8xdR3glKnQOEwfEIPHQ.png" /><figcaption>Application Properties</figcaption></figure><p>2. Then, we must set up a WebSocket Configuration with implements <strong>WebSocketMessageBrokerConfigurer</strong>, and <strong>@EnableWebSocketMessageBroker</strong>. Then we Override some Methods to configure our configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VzH3oZVyPOj-MUvuiCrJ9A.png" /><figcaption>Websocket Configuration</figcaption></figure><blockquote>Explaination :</blockquote><blockquote>@EnableWebSocketMessageBroker : This Annotation Allow us to enable websocket in our project.</blockquote><blockquote>registerStompEndpoints : This method we will use for setting websocket endpoint connection into WebSocket.</blockquote><blockquote>configureMessageBroker : This Method we will use for setting application destination prexies websocket and enable simple broker for topic to subscribe in our project websocket.</blockquote><p>3. After finished setup a websocket configuration, we must create a DTO (Data Transfer Object) for payload from WebSocket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_ro796ASUI9SHWJCD2ETlQ.png" /><figcaption>MessageDTO</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AL91Vt1iTQ-L2yoxSI1dbA.png" /><figcaption>MessageGroupDTO</figcaption></figure><p>4. Let’s create a <strong>MessageService </strong>for websocket and Rest Api to send and get a list of message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*acuIAmsTdbYkdYyEH9aQBw.png" /><figcaption>MessageService</figcaption></figure><blockquote>Explanation</blockquote><blockquote>SimpMessagingTemplate : This class will be used to send messages to users who have subscribed to a specific topic.</blockquote><blockquote>sendMessage : This method will be used in websocket personal chat to storing a message into database and send back to destination subscribe topic.</blockquote><blockquote>getListMessage :This method will be used in Rest Api to retrieve a list of messages from personal user to another user chat.</blockquote><blockquote>getListMessageGroups: This method will be used in Rest Api to retrieve a list of messages from user in group chat.</blockquote><blockquote>sendMessageGroup : This method will be used in websocket group chat to storing a message into database and send back to destination subscribe topic group.</blockquote><p>5. After we create a <strong>MessageService</strong>, now we create a <strong>UserAndGroupService</strong>. This service will used for get list of contact chat, and group chat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f8G7hQflVDcSeOTtBWz6YA.png" /><figcaption>UserAndGroupService</figcaption></figure><blockquote>Explanation</blockquote><blockquote>fetchAll : This method will retrieve a list of contact chat user.</blockquote><blockquote>fetchAllGroup : This method will retrieve a list of group chat base on user group.</blockquote><p>6. The Final Step, Let’s create a controller class <strong>MessageControllers.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SL-xQmOAuQcgYCsiPOGpWQ.png" /></figure><blockquote>Explanation :</blockquote><blockquote>@MessageMapping : This annotation will be used in websocket communication, where client (Front End) will send a message to a specific destination.</blockquote><blockquote>@GetMapping : This annotaion will be used in Rest API communication for method GET to get a response data.</blockquote><p>For Detail Source Code For Backend &amp; Front End can be seen at the following My Repository on Github. Source Code : <a href="https://github.com/arisusantolie/spring-websocket-realtime-chatapp">spring-websocket-realtime-chatapp</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21da7d71d936" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>