<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alexandru Muntean</title>
    <description>The latest articles on DEV Community by Alexandru Muntean (@alexandrum).</description>
    <link>https://dev.to/alexandrum</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F208305%2F36d855ee-febd-4f35-891e-43d14c0fd7d0.png</url>
      <title>DEV Community: Alexandru Muntean</title>
      <link>https://dev.to/alexandrum</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alexandrum"/>
    <language>en</language>
    <item>
      <title>Checkstyle</title>
      <dc:creator>Alexandru Muntean</dc:creator>
      <pubDate>Fri, 22 Jan 2021 22:54:16 +0000</pubDate>
      <link>https://dev.to/alexandrum/checkstyle-5e3m</link>
      <guid>https://dev.to/alexandrum/checkstyle-5e3m</guid>
      <description>&lt;p&gt;&lt;em&gt;Hello there!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is the second tool I encountered in my search journey and it looks like we had lots of styling issues.&lt;/p&gt;

&lt;p&gt;It is true that most of them can be easily resolved by having a common &lt;em&gt;formatter&lt;/em&gt; style installed in the IDE, but for custom and more accurate styling, this tool can come in handy for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://checkstyle.sourceforge.io/"&gt;Checkstyle&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;It is an awesome tool from developers to developers, meant to automate a bit the process of checking Java code, sparing humans from it, and letting them focusing on important things.&lt;/p&gt;

&lt;h4&gt;
  
  
  Installation
&lt;/h4&gt;

&lt;p&gt;There are a few ways to install it into your projects, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Direct JAR which can be taken from &lt;a href="https://github.com/checkstyle/checkstyle/releases/"&gt;Github&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Using it through your IDE, check this &lt;a href="https://checkstyle.sourceforge.io/#Related_Tools_Active_Tools"&gt;list&lt;/a&gt; for the suitable one for you&lt;/li&gt;
&lt;li&gt;Maven &lt;a href="https://mvnrepository.com/artifact/com.puppycrawl.tools/checkstyle/8.39"&gt;plugin&lt;/a&gt; set at build step in your project's &lt;em&gt;pom.xml&lt;/em&gt; file&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Usage
&lt;/h4&gt;

&lt;p&gt;Depending on your chosen path, there are different ways to customize your code conventions. For this article, I chose to write more about the last option, which implies a simple addition in your &lt;em&gt;pom.xml&lt;/em&gt; file within the &lt;strong&gt;plugins&lt;/strong&gt; section:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;plugin&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.apache.maven.plugins&lt;span class="nt"&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;maven-checkstyle-plugin&lt;span class="nt"&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;version&amp;gt;&lt;/span&gt;3.1.1&lt;span class="nt"&gt;&amp;lt;/version&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;configuration&amp;gt;&lt;/span&gt;
     &lt;span class="nt"&gt;&amp;lt;consoleOutput&amp;gt;&lt;/span&gt;true&lt;span class="nt"&gt;&amp;lt;/consoleOutput&amp;gt;&lt;/span&gt;
     &lt;span class="nt"&gt;&amp;lt;violationSeverity&amp;gt;&lt;/span&gt;warning&lt;span class="nt"&gt;&amp;lt;/violationSeverity&amp;gt;&lt;/span&gt;  &lt;span class="c"&gt;&amp;lt;!-- now build fails for Warnings --&amp;gt;&lt;/span&gt;
     &lt;span class="nt"&gt;&amp;lt;failOnViolation&amp;gt;&lt;/span&gt;true&lt;span class="nt"&gt;&amp;lt;/failsOnViolation&amp;gt;&lt;/span&gt;
     &lt;span class="nt"&gt;&amp;lt;configLocation&amp;gt;&lt;/span&gt;some-dir/your-checkstyle.xml&lt;span class="nt"&gt;&amp;lt;/configLocation&amp;gt;&lt;/span&gt;
     &lt;span class="nt"&gt;&amp;lt;sourceDirectories&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;sourceDirectory&amp;gt;&lt;/span&gt;src/main/java&lt;span class="nt"&gt;&amp;lt;/sourceDirectory&amp;gt;&lt;/span&gt; &lt;span class="c"&gt;&amp;lt;!-- Root directory from where the checking process starts --&amp;gt;&lt;/span&gt;
     &lt;span class="nt"&gt;&amp;lt;/sourceDirectories&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;/configuration&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;executions&amp;gt;&lt;/span&gt;
     &lt;span class="nt"&gt;&amp;lt;execution&amp;gt;&lt;/span&gt;
       &lt;span class="nt"&gt;&amp;lt;id&amp;gt;&lt;/span&gt;validate&lt;span class="nt"&gt;&amp;lt;/id&amp;gt;&lt;/span&gt;
       &lt;span class="nt"&gt;&amp;lt;phase&amp;gt;&lt;/span&gt;validate&lt;span class="nt"&gt;&amp;lt;/phase&amp;gt;&lt;/span&gt;
       &lt;span class="nt"&gt;&amp;lt;goals&amp;gt;&lt;/span&gt;
         &lt;span class="nt"&gt;&amp;lt;goal&amp;gt;&lt;/span&gt;check&lt;span class="nt"&gt;&amp;lt;/goal&amp;gt;&lt;/span&gt;
       &lt;span class="nt"&gt;&amp;lt;/goals&amp;gt;&lt;/span&gt;
     &lt;span class="nt"&gt;&amp;lt;/execution&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;/executions&amp;gt;&lt;/span&gt;
 &lt;span class="nt"&gt;&amp;lt;/plugin&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, whenever the project is built, this checker will be triggered, and in case there at least one warning, then the build will &lt;strong&gt;Fail&lt;/strong&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Code conventions
&lt;/h4&gt;

&lt;p&gt;The official documentation provides a nice and easy to use &lt;a href="https://checkstyle.sourceforge.io/checks.html"&gt;list&lt;/a&gt; of all standards checks that this tool supports. You should always refer to it when you are looking for some explanations or details for a certain module out there.&lt;/p&gt;

&lt;p&gt;On the other hand, there are a couple of presets files that can be used almost out of the box: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/google_checks.xml"&gt;google_checks.xml&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/checkstyle/checkstyle/blob/master/src/main/resources/sun_checks.xml"&gt;sun_checks.xml&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Or, you can create a custom one that suits your team and your project starting from the list or from the presets.&lt;/p&gt;




&lt;p&gt;That's pretty much it, I hope you enjoy it and that it will come in handy for your current or incoming projects, but don't necessarily believe me, try it yourself.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Stay tuned for the next article in the series!&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;&lt;a href="https://unsplash.com/photos/iHeX3jWkv9s"&gt;Cover photo&lt;/a&gt; by Markus Spiske on &lt;a href="https://unsplash.com/"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>java</category>
      <category>codequality</category>
      <category>productivity</category>
    </item>
    <item>
      <title>ArchUnit</title>
      <dc:creator>Alexandru Muntean</dc:creator>
      <pubDate>Wed, 20 Jan 2021 20:11:57 +0000</pubDate>
      <link>https://dev.to/alexandrum/archunit-alj</link>
      <guid>https://dev.to/alexandrum/archunit-alj</guid>
      <description>&lt;p&gt;&lt;em&gt;Hello there!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is the first tool I encountered in my search journey and it seems that slowly but surely takes effect while we are focusing only on the business logic of the project.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://www.archunit.org/"&gt;ArchUnit&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;Its purpose is to help developers ensure an architecture level quality by writing a suite test case to cover all that matters to the project and the team involved.&lt;/p&gt;

&lt;p&gt;This library offers great support for newcomers and has different ways to include it in your project based on the JUnit version or an alternative in case there is no JUnit used.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/TNG/ArchUnit/tree/master/archunit-example/example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4"&gt;JUnit 4&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/TNG/ArchUnit/tree/master/archunit-example/example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5"&gt;JUnit 5&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/TNG/ArchUnit/tree/master/archunit-example/example-plain/src/test/java/com/tngtech/archunit/exampletest"&gt;Plain&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the above list, you can find, for each option, several Test classes that have specific goals &lt;em&gt;e.g. CyclicDependencyRulesTest.java&lt;/em&gt; (which I warmly recommend you trying at least)&lt;/p&gt;

&lt;p&gt;Also, each of the Test classes has an associated &lt;a href="https://github.com/TNG/ArchUnit/tree/master/archunit-example/example-plain/src/main/java/com/tngtech/archunit/example"&gt;&lt;em&gt;Real&lt;/em&gt; Test class&lt;/a&gt; in which the applied rules are explained.&lt;/p&gt;




&lt;p&gt;I hope it will help you too, and feel free to come up with suggestions or alternatives. Happy coding!&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Stay tuned for the next article in the series!&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;&lt;a href="https://unsplash.com/photos/iHeX3jWkv9s"&gt;Cover photo&lt;/a&gt; by Markus Spiske on &lt;a href="https://unsplash.com/"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>java</category>
      <category>codequality</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Introduction</title>
      <dc:creator>Alexandru Muntean</dc:creator>
      <pubDate>Wed, 20 Jan 2021 20:11:50 +0000</pubDate>
      <link>https://dev.to/alexandrum/introduction-25c2</link>
      <guid>https://dev.to/alexandrum/introduction-25c2</guid>
      <description>&lt;p&gt;&lt;em&gt;Hello there!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I am in a small team of 3 Java developers, including myself, who work hard to finish a complex project which is suitable for 4 or 5 people.&lt;/p&gt;

&lt;p&gt;This project has a critical deadline and we are already 1 month behind because of the team availability, and the only thing we can do is to speed things up by reducing time on code reviews and still keeping the code quality and performance, limiting the technical debt.&lt;/p&gt;

&lt;p&gt;Therefore, I said to myself, there should be some tools, plugins, or frameworks to use in order to boost a bit our daily work.&lt;/p&gt;

&lt;p&gt;Due to this opportunity, I am creating here this series with short but insightful articles to introduce and cover every tool I found and use.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Stay tuned for the next article in the series!&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;&lt;a href="https://unsplash.com/photos/iHeX3jWkv9s"&gt;Cover photo&lt;/a&gt; by Markus Spiske on &lt;a href="https://unsplash.com/"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>java</category>
      <category>codequality</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Conferences in Europe</title>
      <dc:creator>Alexandru Muntean</dc:creator>
      <pubDate>Thu, 13 Feb 2020 07:08:45 +0000</pubDate>
      <link>https://dev.to/alexandrum/conferences-in-europe-4l08</link>
      <guid>https://dev.to/alexandrum/conferences-in-europe-4l08</guid>
      <description>&lt;h2&gt;
  
  
  Hello everyone,
&lt;/h2&gt;

&lt;p&gt;I am a &lt;em&gt;middle level Software Developer&lt;/em&gt; that uses by daily basics the &lt;em&gt;Java-Spring&lt;/em&gt; tech stack and I wanna participate to a conference this year but I don't know which one. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So, I am wondering which are the best or worth going conferences in Europe to attend and why?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Thanks in advance! :)&lt;/p&gt;

</description>
      <category>java</category>
      <category>techtalks</category>
      <category>webdev</category>
    </item>
    <item>
      <title>My first Pull-request to an open-source project</title>
      <dc:creator>Alexandru Muntean</dc:creator>
      <pubDate>Mon, 14 Oct 2019 20:30:54 +0000</pubDate>
      <link>https://dev.to/alexandrum/my-first-pull-request-to-an-open-source-project-18km</link>
      <guid>https://dev.to/alexandrum/my-first-pull-request-to-an-open-source-project-18km</guid>
      <description>&lt;p&gt;I enjoy helping others, but in terms of programming I am just asking around people from different communities about solutions with regards to my issues. I think it is time for me as well to start giving back to the community and help others in need.&lt;/p&gt;

&lt;p&gt;Having this in mind, I decided to start small and make a simple &lt;strong&gt;Pull-request&lt;/strong&gt; to an open-source project on &lt;strong&gt;Github&lt;/strong&gt; like &lt;a href="https://github.com/spring-projects/spring-framework"&gt;Spring-framework&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I read the &lt;em&gt;conduit&lt;/em&gt; and how to &lt;em&gt;contribute&lt;/em&gt; to the project, but I could not find  there where to modify and how to create a &lt;strong&gt;Pull-request&lt;/strong&gt; with my changes. &lt;/p&gt;

&lt;p&gt;Here comes in handy this &lt;a href="https://www.digitalocean.com/community/tutorials/how-to-create-a-pull-request-on-github"&gt;tutorial&lt;/a&gt; which I recommend to any of us that is starting helping out on open-source projects. It contains all the information needed in order to achieve this and it is very explicit.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>java</category>
      <category>spring</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>How to reply to an anonymous user over Websockets</title>
      <dc:creator>Alexandru Muntean</dc:creator>
      <pubDate>Sun, 22 Sep 2019 18:58:59 +0000</pubDate>
      <link>https://dev.to/alexandrum/how-to-reply-to-an-anonymous-user-over-websockets-d4e</link>
      <guid>https://dev.to/alexandrum/how-to-reply-to-an-anonymous-user-over-websockets-d4e</guid>
      <description>&lt;h1&gt;
  
  
  Hello everyone!
&lt;/h1&gt;

&lt;p&gt;This is my first post here on &lt;strong&gt;dev.to&lt;/strong&gt; and I made myself some courage to write it because I always wanted to have a blog or somewhere to share the things I learn.&lt;/p&gt;

&lt;p&gt;So here we go.&lt;/p&gt;

&lt;p&gt;A couple of weeks ago, I started looking a bit more deeply into the &lt;a href="https://docs.spring.io/spring-framework/docs/5.0.0.BUILD-SNAPSHOT/spring-framework-reference/html/websocket.html"&gt;Spring Websocket&lt;/a&gt; and &lt;a href="https://en.wikipedia.org/wiki/Streaming_Text_Oriented_Messaging_Protocol"&gt;STOMP&lt;/a&gt; because I had 2 applications, a Server and a Client, which had to communicate in a way that the Client requests some data and the Server &lt;strong&gt;replies&lt;/strong&gt; to that request.&lt;/p&gt;

&lt;p&gt;I know it sounds very basic, but the challenge I had to face was replying from the Server to a so called &lt;em&gt;anonymous user&lt;/em&gt; because the Client application is not a user &lt;em&gt;per se&lt;/em&gt;. &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PhSmI5Ua--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://media1.tenor.com/images/4a600f6af42eeffaf5f110cfcd1e87fd/tenor.gif%3Fitemid%3D4793905" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PhSmI5Ua--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://media1.tenor.com/images/4a600f6af42eeffaf5f110cfcd1e87fd/tenor.gif%3Fitemid%3D4793905" alt="Anonymous user" width="498" height="229"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So looking here and there on several websites, I found that I can make this particular case to be somehow similar to the one when you are using the users of the main application.&lt;/p&gt;

&lt;p&gt;The idea is to make the &lt;em&gt;anonymous user&lt;/em&gt; to be &lt;strong&gt;visible&lt;/strong&gt; and the key is to create a particular &lt;strong&gt;sessionId&lt;/strong&gt; for him when the &lt;em&gt;handshake&lt;/em&gt; between the 2 applications is made:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CustomHandshakeHandler&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;DefaultHandshakeHandler&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Custom class for storing principal&lt;/span&gt;
  &lt;span class="nd"&gt;@Override&lt;/span&gt;
  &lt;span class="kd"&gt;protected&lt;/span&gt; &lt;span class="nc"&gt;Principal&lt;/span&gt; &lt;span class="nf"&gt;determineUser&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;ServerHttpRequest&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
                                    &lt;span class="nc"&gt;WebSocketHandler&lt;/span&gt; &lt;span class="n"&gt;wsHandler&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
                                    &lt;span class="nc"&gt;Map&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Object&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;attributes&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Generate principal with UUID as name&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;StompPrincipal&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="no"&gt;UUID&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;randomUUID&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;toString&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And I also extended the main &lt;em&gt;java.security.Principal&lt;/em&gt; class into a &lt;strong&gt;StompPrincipal&lt;/strong&gt; in order to have something custom for my case:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;StompPrincipal&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;Principal&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;StompPrincipal&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="nd"&gt;@Override&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="nf"&gt;getName&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And that's pretty much it, now listening on some path like &lt;em&gt;/tutorial-request&lt;/em&gt; and having as parameter an object of &lt;strong&gt;SimpMessageHeaderAccessor&lt;/strong&gt;, I can retrieve the session information and &lt;strong&gt;reply direct&lt;/strong&gt; to &lt;em&gt;user&lt;/em&gt; that made the request:&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;  &lt;span class="nd"&gt;@Autowired&lt;/span&gt;
  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;SimpMessagingTemplate&lt;/span&gt; &lt;span class="n"&gt;messagingTemplate&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

  &lt;span class="nd"&gt;@MessageMapping&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/tutorial-request"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;handleRequest&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;SimpleRequest&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;SimpMessageHeaderAccessor&lt;/span&gt; &lt;span class="n"&gt;headerAccessor&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;sessionId&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;headerAccessor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getSessionId&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;info&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Handling session with id {} receiving message {} from {}"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sessionId&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getText&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getFrom&lt;/span&gt;&lt;span class="o"&gt;());&lt;/span&gt;
    &lt;span class="nc"&gt;SimpleResponse&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;SimpleResponse&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello!"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;messagingTemplate&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;convertAndSendToUser&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;headerAccessor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getUser&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;getName&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt; &lt;span class="s"&gt;"/queue/tutorial-request"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;info&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Replied to {} with message {}"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sessionId&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;I skipped adding the &lt;em&gt;SimpleRequest&lt;/em&gt; and &lt;em&gt;SimpleResponse&lt;/em&gt; because these are just simple objects that can be found on the repository together with the entire code from above:&lt;br&gt;
&lt;/p&gt;
&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/alexandrumm"&gt;
        alexandrumm
      &lt;/a&gt; / &lt;a href="https://github.com/alexandrumm/spring-tutorials"&gt;
        spring-tutorials
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Resources for Spring tutorials
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;



&lt;p&gt;Feel free to tell me your thoughts in the comments, I know I have a lot to learn and to improve in writing posts, I hope this is just the beginning of it and I would appreciate any suggestions, so please do so.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>java</category>
      <category>spring</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
