<?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: Hong Qiu</title>
    <description>The latest articles on DEV Community by Hong Qiu (@hq190204).</description>
    <link>https://dev.to/hq190204</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%2F185419%2F19e7bacc-3ca1-4a6f-8316-5eb381a81293.JPG</url>
      <title>DEV Community: Hong Qiu</title>
      <link>https://dev.to/hq190204</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hq190204"/>
    <language>en</language>
    <item>
      <title>An Event-ful Internship at Solace</title>
      <dc:creator>Hong Qiu</dc:creator>
      <pubDate>Wed, 11 Dec 2019 00:27:37 +0000</pubDate>
      <link>https://dev.to/solacedevs/an-event-ful-internship-at-solace-eb1</link>
      <guid>https://dev.to/solacedevs/an-event-ful-internship-at-solace-eb1</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;This was originally posted on Solace's blog by Rajiv Abraham Xavier, an intern in our Singapore office. If you're interested in career opportunities at Solace, please visit our &lt;a href="https://solace.com/careers/"&gt;Careers page&lt;/a&gt;.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bMt7Z8K1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/solace-default-blog-thumbnail-600x285.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bMt7Z8K1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/solace-default-blog-thumbnail-600x285.jpg" alt="Further thoughts on FPGA co-processing and performance"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It has been an eventful summer for me at Solace as a pre-sales intern. As an Information Systems undergraduate, majoring in Smart City Management and Technology at Singapore Management University, I heard about some of the ways Solace has been involved in making Singapore smarter and more event driven. I was excited to learn and be part of the team at Solace.&lt;/p&gt;

&lt;p&gt;Coming into Solace, I had very little understanding as to messaging, event brokers, and events as a whole. However, thanks to the Solace &lt;a href="https://www.udemy.com/course/fundamentals-of-solace-development/"&gt;development&lt;/a&gt; and &lt;a href="https://www.udemy.com/course/fundamentals-of-solace-administration/"&gt;administration&lt;/a&gt; courses available on Udemy, I was able to quickly pick up a basic understanding about messaging and the event-driven solutions provided by Solace. Often as an intern, you may feel apprehensive about asking others in the team for help or clarification, as you may feel like you are disturbing their work. In retrospect, this was something I did not encounter at Solace as the team was always willing to help in whatever way they could. They constantly took the time to walk us through our queries and checked in regularly to ensure that we were not lost and were still sufficiently challenged to explore on our own as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a Central Data Exchange
&lt;/h2&gt;

&lt;p&gt;One of the main tasks that was assigned to my fellow intern Giem Teck and I was to understand, scope, design, and build a smart data exchange prototype that can be used to demonstrate the concepts of the event-driven exchange of information. The main challenge in this project was to showcase the abilities of Solace to provide a central data exchange that can be utilised by other users (“agencies”) to share, monitor, and consume data.&lt;/p&gt;

&lt;p&gt;An example use case, in the context of a smart city, is the exchange of data between different government agencies. Those agencies can share the data that they collect via the central exchange in real time (e.g., CCTV footage, sensor data) and can further utilise the data that other agencies shared with them. A machine learning or analytics application can also be subscribed to the events being published by the agencies.&lt;br&gt;&lt;br&gt;
&lt;a href="https://solace.com/wp-content/uploads/2019/11/eventful-internship_1.jpg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ayawtlTz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/11/eventful-internship_1.jpg" alt="An example use case - Solace"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Through brainstorming and whiteboarding sessions with our supervisor – Phil, and further discussions with other members of the team, we came up with a front-facing JavaScript Web application that utilises the &lt;a href="https://solace.com/downloads/"&gt;Solace JavaScript API&lt;/a&gt; and various Solace Element Management Protocol (SEMP) API calls to create bridges between the central exchange broker and the agency broker.&lt;br&gt;&lt;br&gt;
&lt;a href="https://solace.com/wp-content/uploads/2019/11/eventful-internship_2.jpg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---bqQuyUD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/11/eventful-internship_2.jpg" alt="Solace Element Management Protocol (SEMP) API"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This allows agencies to view event streams available to them from other agencies, as well as to publish events that can be accessed by other agencies. The access control of this publishing and subscribing is centrally managed via Access Control Lists on the central exchange broker.&lt;br&gt;&lt;br&gt;
&lt;a href="https://solace.com/wp-content/uploads/2019/11/eventful-internship_3-scaled.jpg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--s2IJ4_oA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/11/eventful-internship_3-scaled.jpg" alt="My Event-ful Internship at Solace"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://solace.com/wp-content/uploads/2019/11/eventful-internship_4-scaled.jpg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eUqoGFRu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/11/eventful-internship_4-scaled.jpg" alt="Access Control Lists"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The administrator of the central exchange broker also has the flexibility to accept or deny requests from the existing agency brokers to publish new events to the central broker. The administrator can also use registration details provided by the agencies, who wish to connect to the central brokers to establish bridges through the user interface. All this creation of new ACL topic allowance and bridge connections are executed on the backend via a SEMP API call.&lt;br&gt;&lt;br&gt;
&lt;a href="https://solace.com/wp-content/uploads/2019/11/eventful-internship_5-scaled.jpg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--l1uoAGO7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/11/eventful-internship_5-scaled.jpg" alt="SEMP API call"&gt;&lt;/a&gt;&lt;br&gt;&lt;br&gt;
&lt;a href="https://solace.com/wp-content/uploads/2019/11/eventful-internship_6-scaled.jpg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qupeU5Lq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/11/eventful-internship_6-scaled.jpg" alt="SEMP API call"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Have Learned
&lt;/h2&gt;

&lt;p&gt;As a student majoring in Smart City Technologies, I feel the idea of a central data exchange is truly eye opening. Through the use of Solace’s advanced event brokers, cities, governments, and even businesses can now share data in real time between different agencies. A central hub helps agencies to easily view the events that are available to them and also offers them the freedom to use these events in their own analytics and visualisation applications to fit their own business needs.&lt;br&gt;&lt;br&gt;
&lt;a href="https://solace.com/wp-content/uploads/2019/11/eventful-internship_7.jpg"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wXMJYj7d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/11/eventful-internship_7.jpg" alt="use of Solace’s advanced event brokers"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For example, as seen in the image above, a machine learning application can take in raw traffic camera footage from the Land Transport agency. The model can then generate description tags about the footage that can be used to trigger events, such as start of fire, which other agencies like fire and rescue departments can subscribed to.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final thoughts
&lt;/h2&gt;

&lt;p&gt;I have learned a lot in my time at Solace. As someone who came in with almost no understanding about messaging and event-driven architecture, to be able to whiteboard and come up with &lt;a href="https://sg.solace.com/eventxchange/login.html"&gt;this prototype&lt;/a&gt; was no easy task. However, with the help of my friendly and talented colleagues and the start-up guides written by the Solace community, the task was made much easier. It truly has been a summer well spent at Solace getting to know the people and the technology.&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://solace.com/blog/event-ful-internship-solace/"&gt;My Event-ful Internship at Solace&lt;/a&gt; appeared first on &lt;a href="https://solace.com"&gt;Solace&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>solace</category>
      <category>eventdrive</category>
      <category>internship</category>
    </item>
    <item>
      <title>How to Build a Simple Chat App with Solace (Part 6)</title>
      <dc:creator>Hong Qiu</dc:creator>
      <pubDate>Wed, 30 Oct 2019 19:08:22 +0000</pubDate>
      <link>https://dev.to/solacedevs/how-to-build-a-simple-chat-app-with-solace-part-6-22ia</link>
      <guid>https://dev.to/solacedevs/how-to-build-a-simple-chat-app-with-solace-part-6-22ia</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bMt7Z8K1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/solace-default-blog-thumbnail-600x285.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bMt7Z8K1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/solace-default-blog-thumbnail-600x285.jpg" alt="Further thoughts on FPGA co-processing and performance"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the sixth post in a series in which I walk through the creation of a simple chat app with Solace PubSub+. In &lt;a href="https://dev.to/hq190204/how-to-build-a-simple-chat-app-with-solace-part-5-12cm-temp-slug-8292081"&gt;the last part&lt;/a&gt;, I explained how to send a REST POST request as a request/reply message. In this final part, you will learn how to create the non-exclusive queue that will receive the login request and load balance them out to the authentication server. Specifically, you will:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create the non-exclusive queue&lt;/li&gt;
&lt;li&gt;Add the topic subscription to the new queue&lt;/li&gt;
&lt;li&gt;Modify the authentication server&lt;/li&gt;
&lt;li&gt;Test the load balancing functionality&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Prerequisites&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://git-scm.com/downloads"&gt;Download Git&lt;/a&gt; to your computer&lt;/li&gt;
&lt;li&gt;&lt;a href="https://maven.apache.org/install.html"&gt;Install Apache Maven&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://console.solace.cloud/login"&gt;Sign up&lt;/a&gt; with Solace PubSub+ Cloud&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/SolaceTraining/fundamentals-of-solace-dev"&gt;Clone a repository&lt;/a&gt; of the samples to your computer&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Level&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Beginner&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Create the Non-Exclusive Queue&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;You need to create a queue for our PubSub+ Cloud instance to receive and save the login request for the authentication server. To create the queue, follow the steps below:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In your code editor, check out the developer-exercise-5 branch or in your command line, enter &lt;code&gt;git checkout remotes/origin/bonus -f&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;In your code editor, open the file LoginMessageReplier.java under auth-server &amp;gt; server.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TLrzKTYM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/10/chat-app-part-6_image-1.png" alt=""&gt;
Line 50 contains the name of the queue “LOGIN_QUEUE”.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://console.solace.cloud/login"&gt;Log in&lt;/a&gt; to Solace PubSub+ Cloud, select your service, and click &lt;strong&gt;Manage Service&lt;/strong&gt;.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--53gmPeov--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/10/chat-app-part-6_image-2-1024x113.png" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Queues&lt;/strong&gt; in the left side.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OyvIUxUf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/10/chat-app-part-6_image-3-1024x301.png" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;+ Create&lt;/strong&gt; button to create a new queue.&lt;/li&gt;
&lt;li&gt;In the  &lt;strong&gt;Create Queue&lt;/strong&gt; dialog box, name the queue LOGIN_QUEUE and click &lt;strong&gt;Create&lt;/strong&gt;.
&lt;strong&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lH-U9jxV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/10/chat-app-part-6_image-4.png" alt=""&gt;&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Edit Queue Settings&lt;/strong&gt; dialog box, change the Access Type to Non-Exclusive and click the &lt;strong&gt;Apply&lt;/strong&gt; button.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Exclusive queues are for fault tolerance while non-exclusive queues are for load balancing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.solace.com/PubSub-Basics/Endpoints.htm"&gt;Learn about queue access types&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YULmAtrj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/10/chat-app-part-6_image-5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YULmAtrj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/10/chat-app-part-6_image-5.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In the &lt;strong&gt;Confirm&lt;/strong&gt; dialog box, click &lt;strong&gt;Apply changes&lt;/strong&gt;.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---xR_itid--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/10/chat-app-part-6_image-6.png" alt=""&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Add the Topic Subscription to the Queue&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Click on the new LOGIN_QUEUE queue and click the &lt;strong&gt;Subscription&lt;/strong&gt; tab.
&lt;strong&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AUnUi6QR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/10/chat-app-part-6_image-7.png" alt=""&gt;&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Click the  &lt;strong&gt;+ Subscription&lt;/strong&gt; button to open the  &lt;strong&gt;Create Subscription&lt;/strong&gt;  dialog box.&lt;/li&gt;
&lt;li&gt;In the  &lt;strong&gt;Create Subscription ** dialog box, add LOGIN/MESSAGE/REQUEST as the topic subscription, press  **Enter&lt;/strong&gt; , and click  &lt;strong&gt;Create&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Modify the Authentication Server&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;You are going to modify the authentication server to consume from the login request instead of receiving messages via a topic subscription.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Under the auth-server directory, open the LoginMessageReplier.java file.&lt;/li&gt;
&lt;li&gt;Enter the following code to set the endpoint properties. (Lines 90-91).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Add the Queue Logic Herefinal EndpointProperties endpointProps = new EndpointProperties();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Enter the following code to set the queue permissions and access type (Lines 92-94).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Set queue permissions to ‘consume’ and access type to ‘non-exclusive’endpointProps.setPermission(EndpointProperties.PERMISSION\_CONSUME);endpointProps.setAccessType(EndpointProperties.ACCESSTYPE\_NONEXCLUSIVE);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Enter the following code to create the queue object (Lines 96- 97).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Create the queue object locallyfinal Queue queue = JCSMPFactory.onlyInstance().createQueue(QUEUE\_NAME);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Enter the following code to provision the queue to ensure that it binds to an existing queue (Lines 98-101).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Actually provision the queue, and do not fail if it already existssession.provision(queue, endpointProps, JCSMPSession.FLAG\_IGNORE\_ALREADY\_EXISTS);System.out.printf(“Attempting to bind to the queue ‘%s’ on the PubSub+ Broker.%n”, QUEUE\_NAME);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Enter the following code to create consumer flow properties and the flow object (Lines 102-104).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Create a Flow be able to bind to and consume messages from the Queuefinal ConsumerFlowProperties flowProps = new ConsumerFlowProperties();flowProps.setEndpoint(queue);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The consumer flow properties define the queue that you would like to connect to.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Enter the following code to set the acknowledgment mode for the flow (Line 105-107).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Set to ‘auto acknowledge’ where the API will ack back to Solace at the end of the//message received callbackflowProps.setAckMode(JCSMPProperties.SUPPORTED\_MESSAGE\_ACK\_AUTO);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are two types of acknowledgment modes: AUTO and CLIENT. Learn more about &lt;a href="https://docs.solace.com/Solace-PubSub-Messaging-APIs/API-Developer-Guide/Acknowledging-Messages.htm"&gt;acknowledgment modes&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Enter the following code to create the flow receiver and receive the messages (Lines 109-118).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;final FlowReceiver cons = session.createFlow(new LoginRequestHandler(), flowProps, endpointProps, new FlowEventHandler() { @Override public void handleEvent(Object o, FlowEventArgs flowEventArgs) { System.out.println(o, toString() + “,” + flowEventArgs); } })//Start the consumercons.start();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code snippet lets you handle events and print out the information to the console.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test the Load Balancing Functionality
&lt;/h2&gt;

&lt;p&gt;With the load balancing consumption pattern, your applications are not blocked when your replying applications cannot keep up with the number of requests.&lt;/p&gt;

&lt;p&gt;To test the load balancing functionality of the login server, follow these steps to start multiple authentication server instances and see how they load balance the login requests. Note that there should be one web-server instance and two auth-server instances running for the final test. Also make sure that you have the right environment variables.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In your code editor, type &lt;code&gt;mvn spring-boot:run&lt;/code&gt; under the auth-server directory to run one instance of the authentication server of the Web application.&lt;/li&gt;
&lt;li&gt;Open a new terminal in your code editor and type &lt;code&gt;mvn spring-boot:run&lt;/code&gt; under the auth-server directory to run the second instance of the authentication server of the Web application.&lt;/li&gt;
&lt;li&gt;Open two Web browsers and enter localhost:8081 for each of them to access the Web application.&lt;/li&gt;
&lt;li&gt;In one of the instances of the Web application, enter the valid username “ValidUser” and password “solace”.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B1ih3-SO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/10/chat-app-part-6_image-8-1024x437.png" alt=""&gt;
The login succeeds because this user is in the HashMapCredentialRepository.java file.&lt;/li&gt;
&lt;li&gt;In the other instances of the Web application, enter the username “user” and password “user”.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8V0JRkTU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/10/chat-app-part-6_image-9.png" alt=""&gt;
This time, the login fails because this user is not in the HashMapCredentialRepository.java file.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Congratulations!
&lt;/h2&gt;

&lt;p&gt;You have successfully added code to bind to the login queue and respond to the request messages.&lt;br&gt;&lt;br&gt;
Not only that, you have reached the end of the series! To learn more about PubSub+ for developers, visit &lt;a href="https://www.solace.dev/"&gt;solace.dev&lt;/a&gt;. To share your developer experience using Solace PubSub+ or ask for help from other developers, visit the &lt;a href="https://solace.community/"&gt;Solace Community&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Related&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/hq190204/how-to-build-a-simple-chat-app-with-solace-part-5-12cm-temp-slug-8292081"&gt;How to Build a Simple Chat Application with Solace (Part 5)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/solacedevs/how-to-build-a-simple-chat-app-with-solace-part-4-35ei"&gt;How to Build a Simple Chat Application with Solace (Part 4)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/solacedevs/how-to-build-a-simple-chat-app-with-solace-part-3-2657"&gt;How to Build a Simple Chat Application with Solace (Part 3)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/solacedevs/how-to-build-a-simple-chat-app-with-solace-part-2-2efh"&gt;How to Build a Simple Chat Application with Solace (Part 2)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/solacedevs/how-to-build-a-simple-chat-app-with-solace-part-1-3c9e"&gt;How to Build a Simple Chat Application with Solace (Part 1)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Udemy Course: &lt;a href="https://www.udemy.com/fundamentals-of-solace-development/"&gt;Fundamentals of Solace Development&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The post &lt;a href="https://solace.com/blog/build-chat-app-solace-6/"&gt;How to Build a Simple Chat App with Solace (Part 6)&lt;/a&gt; appeared first on &lt;a href="https://solace.com"&gt;Solace&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>solace</category>
      <category>chat</category>
    </item>
    <item>
      <title>How to Build a Simple Chat App with Solace (Part 5)</title>
      <dc:creator>Hong Qiu</dc:creator>
      <pubDate>Mon, 07 Oct 2019 10:00:27 +0000</pubDate>
      <link>https://dev.to/solacedevs/how-to-build-a-simple-chat-app-with-solace-part-5-308n</link>
      <guid>https://dev.to/solacedevs/how-to-build-a-simple-chat-app-with-solace-part-5-308n</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bMt7Z8K1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/solace-default-blog-thumbnail-600x285.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bMt7Z8K1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/solace-default-blog-thumbnail-600x285.jpg" alt="Further thoughts on FPGA co-processing and performance"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the fifth of a series of blog posts in which I walk through the creation of a simple chat app with Solace PubSub+. In &lt;a href="https://dev.to/solacedevs/how-to-build-a-simple-chat-app-with-solace-part-4-35ei"&gt;the last part&lt;/a&gt;, I explained how to add a simple authentication server and send a REST POST request as a Publish/Subscribe type of message. In this tutorial, you will learn how to send a REST POST request as a request/reply message. Specifically, you will learn how to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Modify the sample code&lt;/li&gt;
&lt;li&gt;Connect the authentication server&lt;/li&gt;
&lt;li&gt;Change the login response message&lt;/li&gt;
&lt;li&gt;Test the authentication and response message&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Prerequisite&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://git-scm.com/downloads"&gt;Download Git&lt;/a&gt; to your computer&lt;/li&gt;
&lt;li&gt;&lt;a href="https://maven.apache.org/install.html"&gt;Install Apache Maven&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://console.solace.cloud/login"&gt;Sign up&lt;/a&gt; with Solace PubSub+ Cloud&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/SolaceTraining/fundamentals-of-solace-dev"&gt;Clone a repository&lt;/a&gt; of the samples to your computer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Level&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Beginner&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Modify the Sample Code&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;The accompanying sample code for this tutorial is for sending a REST POST request as a Publish/Subscribe message. Since you will send a REST POST request as a Request/Reply message instead this time, you need to modify the sample code.&lt;/p&gt;

&lt;p&gt;To modify the sample code, do the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In your code editor, check out the developer-exercise-5 branch or in your command line, enter &lt;code&gt;git checkout remotes/origin/developer-exercise-5 -f&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;In your code editor, open the file &lt;code&gt;SolaceCloudProxy.java&lt;/code&gt;
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fTdHZiNn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/10/chat-app-part-5_image-1.png" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;Enter the following highlighted code to the section that determines a response to the Http Request to set the Solace reply wait time in milliseconds (Line 56).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//This header determines that the Http Request needs a responseset(“Solace-Reply-Wait-Time-In-ms”,”3000”);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Solace-specific HTTP header “Solace-Reply-Wait-Time-In-ms” specifies that the message exchange pattern is Request/Reply and the Solace message broker application must wait for the specified timeout value (e.g. 3 seconds) for a reply before it stops.&lt;br&gt;&lt;br&gt;
&lt;a href="https://docs.solace.com/RESTMessagingPrtl/Solace-REST-Message-Encoding.htm"&gt;Learn about Solace-Reply-Wait-Time-In-ms&lt;/a&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Modify the REST template POST request in the section that passes through a response code to expect a response of an authenticated object and to retrieve authenticatedObject from the call (Line 68).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Pass through a response code based on the result of the REST-ful requestAuthenticatedObject authenticatedObject = restTemplate.postForObject(solaceRESTHost + “/LOGIN/MESSAGE/REQUEST”, request, AuthenticatedObject.class);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;“AuthenticatedObject” is defined in the &lt;code&gt;AuthenticatedObject.java&lt;/code&gt; file under solace-chat-common. It validates a client and determines whether to allow it to connect or not.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Under the above modified code line, enter the following code to define what message the client will get when their request is allowed or denied (Lines 70-73).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (authenticatedObject.isAuthenticated()) { return new ResponseEntity(HttpStatus.OK);}else { return new ResponseEntity(HttpStatus.FORBIDDEN);}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Connect the Authentication Server
&lt;/h3&gt;

&lt;p&gt;To connect the authentication server to the PubSub+ instance, you need to define the connection details.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In the auth-server directory, copy and paste the &lt;code&gt;application-template.properties&lt;/code&gt; file under src &amp;gt; main &amp;gt; resources.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EKdwfHpL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/10/chat-app-part-5_image-2.png" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;Rename the copied file to &lt;code&gt;application.properties&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://console.solace.cloud/login"&gt;Log in&lt;/a&gt; to Solace PubSub+ Cloud and click the *&lt;em&gt;Connect *&lt;/em&gt; tab.&lt;/li&gt;
&lt;li&gt;Open the Solace Messaging section.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uOEhGSbj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/10/chat-app-part-5_image-3.png" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;From the Connection Details on the right, copy the following:

&lt;ul&gt;
&lt;li&gt;Username&lt;/li&gt;
&lt;li&gt;Password&lt;/li&gt;
&lt;li&gt;Message VPN&lt;/li&gt;
&lt;li&gt;SMF Host&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Paste the connection details to the &lt;code&gt;application.properties&lt;/code&gt; file.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gk62-S6b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/10/chat-app-part-5_image-4.png" alt=""&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Change the Login Response Message
&lt;/h2&gt;

&lt;p&gt;When you receive a request to log in to the chat application, you need to authenticate the user and then send the response back to the application. To change the login response message, follow the steps below:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;

&lt;ol&gt;
&lt;li&gt;In the auth-server directory, open the &lt;code&gt;LoginMessageReplier.java&lt;/code&gt; file.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QqVOViR3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/10/chat-app-part-5_image-5.png" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;Enter the following highlighted code to add the session subscription (Line 92).
//Add the session subscription here
&lt;code&gt;session.addSubscription(JCSMPFactory.onlyInstance().createTopic( REQUEST_TOPIC), true);&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;In the &lt;code&gt;createReplyMessage&lt;/code&gt; method, enter the following highlighted code to create a message object for the reply message and then convert the Json text in the request message to a user object type (Line 110).
&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private XMLMessage createReplyMessage(TextMessage request) throws JCSMPException { TextMessage replyMessage = JCSMPFactory.onlyInstance().createMessage(TextMessage.class); UserObject userObject = gson.fromJson(request.getText(), UserObject.class);}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Under the above code lines, enter the following highlighted code to validate the user and print out the message depending on the result of the validation (Lines 113 to 119).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private XMLMessage createReplyMessage(TextMessage request) throws JCSMPException { TextMessage replyMessage = JCSMPFactory.onlyInstance().createMessage(TextMessage.class); UserObject userObject = gson.fromJson(request.getText(), UserObject.class); //Validate the user boolean validUser = credentialsRepository.isValidUser(userObject.getUsername(), userObject.getPassword());if (validUser) System.out.println(“Successfully validated a user”);else System.out.println(“Authentication failed”);}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Enter the following highlighted code to create an AuthenticatedObject type, set the reply message content type, set the text, and set the delivery mode (Lines 120 to 127).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (validUser) System.out.println(“Successfully validated a user”);else System.out.println(“Authentication failed”);AuthenticatedObject authenticatedObject = new AuthenticatedObject();authenticatedObject.setAuthenticated(validUser);replyMessage.setHTTPContentType(“application/json”);replyMessage.setText(gson.toJson(authenticatedObject));replyMessage.setApplicationMessageId(request.getApplicationMessageId());replyMessage.setDeliverToOne(true);replyMessage.setDeliveryMode(DeliveryMode.DIRECT);return replyMessage;}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Test the Authentication and Response Message
&lt;/h3&gt;

&lt;p&gt;To test the authentication and login request response message, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In your code editor, type &lt;code&gt;mvn spring-boot:run&lt;/code&gt; to run the Web application.&lt;/li&gt;
&lt;li&gt;Open a new terminal window, change the directory to .\auth-server\, and type &lt;code&gt;mvn spring-boot:run&lt;/code&gt; to run the authentication server.&lt;/li&gt;
&lt;li&gt;In your Web browser, type &lt;code&gt;localhost:8081&lt;/code&gt; to view the application.&lt;/li&gt;
&lt;li&gt;Log in with a username and a password that are preset in the &lt;code&gt;HashMapCredentialRepository.java&lt;/code&gt; file under the server directory in auth-server (e.g. ValidUser; solace).
This should bring you to the chat application page.&lt;/li&gt;
&lt;li&gt;Refresh your browser and log in with an invalid username and an invalid password. You should see the “Login Failed” error message.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Congratulations! You now have a chat application that allows you to authenticate your user with a request/reply message pattern.&lt;/p&gt;

&lt;p&gt;In the next part (coming soon), you will learn how to modify the Web application to load balance requests.&lt;/p&gt;

&lt;h3&gt;
  
  
  Related
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/solacedevs/how-to-build-a-simple-chat-app-with-solace-part-4-35ei"&gt;How to Build a Simple Chat Application with Solace (Part 4)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/solacedevs/how-to-build-a-simple-chat-app-with-solace-part-3-2657"&gt;How to Build a Simple Chat Application with Solace (Part 3)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/solacedevs/how-to-build-a-simple-chat-app-with-solace-part-2-2efh"&gt;How to Build a Simple Chat Application with Solace (Part 2)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/solacedevs/how-to-build-a-simple-chat-app-with-solace-part-1-3c9e"&gt;How to Build a Simple Chat Application with Solace (Part 1)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Udemy Course: &lt;a href="https://www.udemy.com/fundamentals-of-solace-development/"&gt;Fundamentals of Solace Development&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The post &lt;a href="https://solace.com/blog/build-chat-app-solace-5/"&gt;How to Build a Simple Chat App with Solace (Part 5)&lt;/a&gt; appeared first on &lt;a href="https://solace.com"&gt;Solace&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>solace</category>
      <category>chat</category>
    </item>
    <item>
      <title>How to Build a Simple Chat App with Solace (Part 4)</title>
      <dc:creator>Hong Qiu</dc:creator>
      <pubDate>Mon, 23 Sep 2019 19:00:05 +0000</pubDate>
      <link>https://dev.to/solacedevs/how-to-build-a-simple-chat-app-with-solace-part-4-35ei</link>
      <guid>https://dev.to/solacedevs/how-to-build-a-simple-chat-app-with-solace-part-4-35ei</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsolace.com%2Fwp-content%2Fuploads%2F2019%2F07%2Fchat-app-blog-featured-image.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsolace.com%2Fwp-content%2Fuploads%2F2019%2F07%2Fchat-app-blog-featured-image.jpg"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;This is part 4 of a series of blog posts in which I walk through the creation of a simple chat app with Solace PubSub+. In &lt;a href="https://dev.to/solacedevs/how-to-build-a-simple-chat-app-with-solace-part-1-3c9e"&gt;the first part&lt;/a&gt;, I explained how to create a simple chat app that can send and receive messages via a direct topic subscription. In &lt;a href="https://dev.to/solacedevs/how-to-build-a-simple-chat-app-with-solace-part-2-2efh"&gt;the second&lt;/a&gt; I explained how to modify the sample code so the application consumes messages from a queue, and in &lt;a href="https://dev.to/solacedevs/how-to-build-a-simple-chat-app-with-solace-part-3-2657"&gt;part 3&lt;/a&gt; I explained how to add login functionalities to send a REST POST request to Solace PubSub+.&lt;/p&gt;

&lt;p&gt;In this tutorial, you will learn how to add a simple authentication server. The server will first receive the client login request from the web application, then authenticate the user, and finally send a REST POST response back to the application to either allow or deny the login request.&lt;/p&gt;

&lt;p&gt;Specifically, you will&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set the connection details&lt;/li&gt;
&lt;li&gt;Create and send the REST POST request&lt;/li&gt;
&lt;li&gt;Test the REST POST request&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Prerequisite&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://git-scm.com/downloads" rel="noopener noreferrer"&gt;Download Git&lt;/a&gt; to your computer&lt;/li&gt;
&lt;li&gt;&lt;a href="https://maven.apache.org/install.html" rel="noopener noreferrer"&gt;Install Apache Maven&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://console.solace.cloud/login" rel="noopener noreferrer"&gt;Sign up&lt;/a&gt; with Solace PubSub+ Cloud&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/SolaceTraining/fundamentals-of-solace-dev" rel="noopener noreferrer"&gt;Clone a repository&lt;/a&gt; of the samples to your computer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Level&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Beginner&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Set the Connection Details&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The setting of the connection details tells the Web application server where to send the REST POST login request to so that the Solace instance can receive it.&lt;/p&gt;

&lt;p&gt;To set the connection details, do the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In your code editor, check out the developer-exercise-4 branch or in your command line, enter &lt;code&gt;git checkout remotes/origin/developer-exercise-4 -f&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;In your code editor, enter &lt;code&gt;mvn install&lt;/code&gt; to run a Maven install in solace-chat-common.&lt;/li&gt;
&lt;li&gt;Under src &amp;gt; main &amp;gt; resources, open the file &lt;code&gt;application.properties&lt;/code&gt;.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsolace.com%2Fwp-content%2Fuploads%2F2019%2F09%2Fchat-app-part-4_image-1.png"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://console.solace.cloud/login" rel="noopener noreferrer"&gt;Log in&lt;/a&gt; to Solace PubSub+ Cloud.&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Connect&lt;/strong&gt; tab.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsolace.com%2Fwp-content%2Fuploads%2F2019%2F09%2Fchat-app-part-4_image-2.png"&gt;
&lt;/li&gt;
&lt;li&gt;Open the REST section.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsolace.com%2Fwp-content%2Fuploads%2F2019%2F09%2Fchat-app-part-4_image-3.png"&gt;
&lt;/li&gt;
&lt;li&gt;Copy the username, password, and REST host information from the Connection Details section and paste them to the application.properties file under src &amp;gt; main &amp;gt; java &amp;gt; resources.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsolace.com%2Fwp-content%2Fuploads%2F2019%2F09%2Fchat-app-part-4_image-4.png"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Create and Send the REST POST Request&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now the connection details are set, you can create and send the REST POST request to the PubSub+ instance as a Publish/Subscribe message:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In your code editor, under src &amp;gt; main &amp;gt; java, open the file SolaceCloudProxy.java.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsolace.com%2Fwp-content%2Fuploads%2F2019%2F09%2Fchat-app-part-4_image-5.png"&gt;
&lt;/li&gt;
&lt;li&gt;Enter the following code to create a REST template object (Line 63).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Rest Request goes hereRestTemplate restTemplate = new RestTemplate();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;RestTemplate&lt;/code&gt; makes HTTP REST calls and simplifies the interaction with HTTP servers.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Enter the following code below the above code to create the HTTP entity with the user object type (Line 64).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HttpEntity&amp;amp;lt;UserObject&amp;amp;gt; request = new HttpEntity&amp;amp;lt;UserObject&amp;amp;gt;(userObject,httpHeaders);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The user authentication type contains just a username and password. solace-chat-common has the reference to it.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Enter the following code to add the POST for the object to the REST template (Line 65).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;restTemplate.postForObject(solaceRESTHost + “/LOGIN/MESSAGE/REQUEST”,request, String.class);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You defined &lt;code&gt;solaceRESTHost&lt;/code&gt; at Step 7 of the “Set the Connection Details” section above.&lt;br&gt;&lt;br&gt;
&lt;code&gt;/LOGIN/MESSAGE/REQUEST&lt;/code&gt; is the specific topic that you are sending the REST POST request to.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Enter the following code to return a response entity (Line 66).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return new ResponseEntity(HttpStatus.OK);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;ResponseEntity&lt;/code&gt; creates an HTTP response.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Test the REST Request&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now you have created and sent the REST POST request, you can test whether the request is actually delivered to the Solace instance.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In your code editor, enter &lt;code&gt;mvn spring-boot:run&lt;/code&gt; to start the web application.&lt;/li&gt;
&lt;li&gt;In Solace PubSub+ Cloud, click the &lt;strong&gt;Try Me!&lt;/strong&gt; tab.
&lt;strong&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsolace.com%2Fwp-content%2Fuploads%2F2019%2F09%2Fchat-app-part-4_image-6.png"&gt;&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;In the Subscriber panel, click the &lt;strong&gt;Connect&lt;/strong&gt; button, enter &lt;strong&gt;LOGIN/MESSAGE/REQUEST&lt;/strong&gt; as the topic, and click the &lt;strong&gt;Subscribe&lt;/strong&gt; button.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsolace.com%2Fwp-content%2Fuploads%2F2019%2F09%2Fchat-app-part-4_image-7.png"&gt;
&lt;/li&gt;
&lt;li&gt;Open a new browser and enter &lt;code&gt;localhost:8081&lt;/code&gt; to bring up the web application.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsolace.com%2Fwp-content%2Fuploads%2F2019%2F09%2Fchat-app-part-4_image-8.png"&gt;
&lt;/li&gt;
&lt;li&gt;Enter “user” as the username and password and click the &lt;strong&gt;Submit&lt;/strong&gt; button.
You should see the Try Me! tab has received the message.
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fsolace.com%2Fwp-content%2Fuploads%2F2019%2F09%2Fchat-app-part-4_image-9.png"&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Congratulations! You have successfully added an authentication server, sent a REST POST request to the server as a Publish/Subscribe message, and received a response from it. In the next part (coming soon), you will learn how to send the REST POST request as a Request/Reply message.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Related&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://solace.com/blog/build-chat-app-solace-3" rel="noopener noreferrer"&gt;How to Build a Simple Chat App with Solace (Part 3)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://solace.com/blog/build-chat-app-solace-2" rel="noopener noreferrer"&gt;How to Build a Simple Chat App with Solace (Part 2)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://solace.com/blog/build-chat-app-solace-1" rel="noopener noreferrer"&gt;How to Build a Simple Chat App with Solace (Part 1)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Udemy Course: &lt;a href="https://www.udemy.com/fundamentals-of-solace-development/" rel="noopener noreferrer"&gt;Fundamentals of Solace Development&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The post &lt;a href="https://solace.com/blog/build-chat-app-solace-4/" rel="noopener noreferrer"&gt;How to Build a Simple Chat App with Solace (Part 4)&lt;/a&gt; appeared first on &lt;a href="https://solace.com" rel="noopener noreferrer"&gt;Solace&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>solace</category>
      <category>chat</category>
    </item>
    <item>
      <title>How to Build a Simple Chat App with Solace (Part 3)</title>
      <dc:creator>Hong Qiu</dc:creator>
      <pubDate>Tue, 03 Sep 2019 20:40:04 +0000</pubDate>
      <link>https://dev.to/solacedevs/how-to-build-a-simple-chat-app-with-solace-part-3-2657</link>
      <guid>https://dev.to/solacedevs/how-to-build-a-simple-chat-app-with-solace-part-3-2657</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bMt7Z8K1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/solace-default-blog-thumbnail-600x285.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bMt7Z8K1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/solace-default-blog-thumbnail-600x285.jpg" alt="Further thoughts on FPGA co-processing and performance"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is part 3 of a series of blog posts in which I walk through the creation of a simple chat app with Solace PubSub+. In &lt;a href="https://dev.to/hq190204/how-to-build-a-simple-chat-app-with-solace-part-1-4hg1-temp-slug-6948697"&gt;the first part&lt;/a&gt;, I explained how to create a simple chat app that can send and receive messages via a direct topic subscription. In &lt;a href="https://dev.to/hq190204/how-to-build-a-simple-chat-app-with-solace-part-2-8k5-temp-slug-9259292"&gt;the second&lt;/a&gt; I explained how to modify the sample code so the application consumes messages from a queue. In this part, I’ll explain how to send a REST POST request from a login page to a dummy authentication service fronted by Solace PubSub+.&lt;/p&gt;

&lt;p&gt;Specifically, you will:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add a server URL&lt;/li&gt;
&lt;li&gt;Complete fetch parameters&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://git-scm.com/downloads"&gt;Download Git&lt;/a&gt; to your computer&lt;/li&gt;
&lt;li&gt;&lt;a href="https://maven.apache.org/install.html"&gt;Install Apache Maven&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://console.solace.cloud/login"&gt;Sign up&lt;/a&gt; with Solace PubSub+ Cloud&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/SolaceTraining/fundamentals-of-solace-dev"&gt;Clone a repository&lt;/a&gt; of the samples to your computer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Level&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Beginner&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Add a Server URL&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;By adding a server URL, you define where the REST POST request is sent to. To add a server URL, do the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In your code editor, check out the developer-exercise-3 branch or in your command line, enter &lt;code&gt;git checkout remotes/origin/developer-exercise-3 -f&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Open the solaceauth.js file under &lt;code&gt;src &amp;gt; main &amp;gt; resources &amp;gt; static &amp;gt; scripts&lt;/code&gt; &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GvpGMwfx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/chat-app-part-3_image-1.png" alt="Open the solaceauth.js"&gt;
&lt;/li&gt;
&lt;li&gt;Enter the highlighted code to add the server URL (Line 15).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Enter serverUrl var serverUrl = ‘http://localhost:8081/solace/cloud/proxy’,
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This URL sends the request through our web application server, which sends it to our Solace instance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Complete Fetch Parameters
&lt;/h2&gt;

&lt;p&gt;The fetch method defines how information is obtained from the server. Do the following to add the method and headers parameters:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Enter the highlighted code to add POST as the method (Lines 22-23).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Complete fetch parameters; method and headers fetch(serverUrl, { method: “POST”,
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Under the above code, enter the highlighted code to set the content-type of the request header (Lines 24-25).
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;headers: { “Content-Type”: “application/json; charset=utf-8”,
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This tells the receiving server to deal with the REST message content in JSON format with the UTF-8 character encoding.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In your code editor, type &lt;code&gt;mvn spring-boot:run&lt;/code&gt; to run the application.&lt;/li&gt;
&lt;li&gt;In your Web browser, enter localhost:8081 to see the login page.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cOBWCVBL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/chat-app-part-3_image-2.png" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;Type any username and password. You should get a “Login Failed” message.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6qhsTqg7--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/chat-app-part-3_image-3-1024x374.png" alt=""&gt;
This is because we have just sent the REST POST request to the Solace instance and have not yet set up the login server. We will do that in the next tutorial.&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  Congratulations!
&lt;/h1&gt;

&lt;p&gt;You have added login functionalities to the Web application to send a REST POST request to Solace PubSub+.&lt;/p&gt;

&lt;p&gt;In Part 4 of the series (coming soon), you will learn how to add a simple authentication server.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Related Resources&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/hq190204/how-to-build-a-simple-chat-app-with-solace-part-1-4hg1-temp-slug-6948697"&gt;&lt;strong&gt;How to Build a Simple Chat Application with Solace (Part 1)&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/hq190204/how-to-build-a-simple-chat-app-with-solace-part-2-8k5-temp-slug-9259292"&gt;&lt;strong&gt;How to Build a Simple Chat Application with Solace (Part 2)&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Udemy Course: &lt;a href="https://www.udemy.com/fundamentals-of-solace-development/"&gt;Fundamentals of Solace Development&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The post &lt;a href="https://solace.com/blog/build-chat-app-solace-3/"&gt;How to Build a Simple Chat App with Solace (Part 3)&lt;/a&gt; appeared first on &lt;a href="https://solace.com"&gt;Solace&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>solace</category>
      <category>chat</category>
    </item>
    <item>
      <title>New Resources for Spring Developers</title>
      <dc:creator>Hong Qiu</dc:creator>
      <pubDate>Tue, 20 Aug 2019 23:37:24 +0000</pubDate>
      <link>https://dev.to/solacedevs/new-resources-for-spring-developers-36i</link>
      <guid>https://dev.to/solacedevs/new-resources-for-spring-developers-36i</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--U_V0GPaC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/spring-cloud-featured-image.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U_V0GPaC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/spring-cloud-featured-image.png" alt=""&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Over the years, Solace has been working hard to help developers using the Spring Framework create Spring-based applications and event-driven microservices with Solace event brokers. We kicked off the effort by publishing a comprehensive &lt;a href="https://docs.solace.com/Developer-Tools/Integration-Guides/Spring-Framework.htm"&gt;integration guide&lt;/a&gt; that demonstrates how to integrate JMS with the Spring Java Framework for production and consumption of JMS messages. We’ve also released open source projects like a &lt;a href="https://github.com/SolaceProducts/solace-jms-spring-boot"&gt;Spring Boot auto-config&lt;/a&gt; complete with a Spring Boot Starter for the Solace JMS API and an &lt;a href="https://github.com/SolaceProducts/spring-cloud-stream-binder-solace"&gt;implementation of Spring’s Cloud Stream Binder&lt;/a&gt; for integrating with Solace PubSub+.&lt;/p&gt;

&lt;p&gt;I’m proud to announce a few new resources we’re making available, along with a new landing page that will house all of these assets and help Spring developers understand:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What&lt;/strong&gt; Spring Projects can be used with PubSub+&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why&lt;/strong&gt; Spring ecosystems can benefit from Solace PubSub+&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;How&lt;/strong&gt; they can can use PubSub+ with supported Spring projects&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://dev.to/spring/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8sVbvsbI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/spring-landing-page.png" alt="Solace tutorials for Spring Developers"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The page is at &lt;a href="https://dev.to/spring/"&gt;solace.com/spring&lt;/a&gt; — go check it out while it’s hot!&lt;/p&gt;

&lt;p&gt;As for the new resources I mentioned above…&lt;/p&gt;

&lt;h2&gt;
  
  
  Spring Cloud Streams with Solace Tutorial
&lt;/h2&gt;

&lt;p&gt;In addition to introducing you the fundamentals of using Spring Cloud Streams with the Solace PubSub+ Binder, this hands-on &lt;a href="https://solace.com/samples/solace-samples-spring/spring-cloud-streams/"&gt;tutorial&lt;/a&gt; outlines a simple way to create a messaging service in Solace to quickly access Solace messaging. It shows you how to create 3 apps: a Spring Cloud Streams Source (sending app), a Spring Cloud Streams Sink (receiving app), and a Spring Cloud Streams Processor (sending &amp;amp; receiving app).&lt;/p&gt;

&lt;p&gt;Check out the &lt;a href="https://solace.com/samples/solace-samples-spring/spring-cloud-streams/"&gt;tutorial&lt;/a&gt; and the &lt;a href="https://github.com/SolaceSamples/solace-samples-spring"&gt;sample code&lt;/a&gt; in GitHub.&lt;/p&gt;

&lt;h2&gt;
  
  
  Spring Boot Autoconfig (JMS) Tutorial
&lt;/h2&gt;

&lt;p&gt;This tutorial is all about using Spring Boot with Autoconfigure to connect an JMS client to Solace Messaging for the exchange of JMS events. It walks you through the steps to create respectively an app for receiving JMS messages and an app for sending JMS messages.&lt;/p&gt;

&lt;p&gt;Check out the &lt;a href="https://solace.com/samples/solace-samples-spring/spring-boot-autoconfigure/"&gt;tutorial&lt;/a&gt; and the &lt;a href="https://github.com/SolaceSamples/solace-samples-spring"&gt;sample code&lt;/a&gt; in GitHub.&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://solace.com/blog/spring-developers-new-resources/"&gt;New Resources for Spring Developers&lt;/a&gt; appeared first on &lt;a href="https://solace.com"&gt;Solace&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>solace</category>
      <category>jms</category>
      <category>spring</category>
      <category>pivotal</category>
    </item>
    <item>
      <title>How to Build a Simple Chat App with Solace (Part 2)</title>
      <dc:creator>Hong Qiu</dc:creator>
      <pubDate>Fri, 02 Aug 2019 18:57:15 +0000</pubDate>
      <link>https://dev.to/solacedevs/how-to-build-a-simple-chat-app-with-solace-part-2-2efh</link>
      <guid>https://dev.to/solacedevs/how-to-build-a-simple-chat-app-with-solace-part-2-2efh</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NqbU5CDv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/07/chat-app-blog-featured-image.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NqbU5CDv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/07/chat-app-blog-featured-image.jpg" alt=""&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;In an earlier blog post, I explained &lt;a href="https://dev.to/hq190204/how-to-build-a-simple-chat-app-with-solace-part-1-4hg1-temp-slug-6948697"&gt;how to build a simple chat browser application&lt;/a&gt; that consumes messages via a direct topic subscription. In this follow-up to that tutorial, I’ll explain how to modify the sample code to get that application consuming messages from a queue.&lt;/p&gt;

&lt;p&gt;Specifically, you will create a queue, add a subscription to the queue and create the queue consumer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://git-scm.com/downloads"&gt;Download Git&lt;/a&gt; to your computer&lt;/li&gt;
&lt;li&gt;&lt;a href="https://maven.apache.org/install.html"&gt;Install Apache Maven&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://console.solace.cloud/login"&gt;Sign up&lt;/a&gt; with Solace PubSub+ Cloud&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.udemy.com/fundamentals-of-solace-administration/"&gt;Understand Solace topics and queues&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Level:&lt;/strong&gt; Beginner&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Create a Queue&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;In your code editor, check out the developer-exercise-2 branch or in your command line, enter &lt;code&gt;git checkout remotes/origin/developer-exercise-2 -f&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Open the scripts directory under src &amp;gt; main &amp;gt; resources &amp;gt; static.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--X6KM-hOp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/chat-app-blog-post-part-2_01.png" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;Open the pubsubplusbroker.js file, comment out the direct topic subscription that was added in Part 1 and save the file.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--u4KUED6w--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/chat-app-blog-post-part-2_02.png" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://console.solace.cloud/login"&gt;Log in&lt;/a&gt; to Solace PubSub+ Cloud, open your service, and click &lt;strong&gt;Manage Service&lt;/strong&gt;.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FuQu1mdQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/chat-app-blog-post-part-2_03-1024x161.png" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Queues&lt;/strong&gt; tab on the left.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wZduAe5o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/chat-app-blog-post-part-2_04.png" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;+&lt;/strong&gt;  &lt;strong&gt;Create&lt;/strong&gt; button to create a queue.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Create Queue&lt;/strong&gt; dialog box, give the queue a name and click the &lt;strong&gt;Create&lt;/strong&gt; button.
&lt;strong&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rZHW-V4E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/chat-app-blog-post-part-2_05.png" alt=""&gt;&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Apply&lt;/strong&gt; to use the default settings.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Add a Subscription to the Queue&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Click on the queue you just created and click the &lt;strong&gt;Subscriptions&lt;/strong&gt; tab.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dej1QX-5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/chat-app-blog-post-part-2_06.png" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;+ Subscription&lt;/strong&gt; button to open the &lt;strong&gt;Create Subscription&lt;/strong&gt; dialog box.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Create Subscription&lt;/strong&gt; dialog box, add the topic subscription, press &lt;strong&gt;Enter&lt;/strong&gt; , and click &lt;strong&gt;Create&lt;/strong&gt;.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LywDUOrn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/chat-app-blog-post-part-2_07.png" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;In your code editor, type &lt;strong&gt;mvn spring-boot:run&lt;/strong&gt; to run the application. Make sure you are in the web-app-server directory.&lt;/li&gt;
&lt;li&gt;In your Web browser, type localhost:8081 to open the application if it is not already open.&lt;/li&gt;
&lt;li&gt;Send a few messages in the application.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zhBwtYa4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/chat-app-blog-post-part-2_08-1024x433.png" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;In the queue you created at Step 3, click &lt;strong&gt;Summary&lt;/strong&gt; to see the queued messages.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hXjhJbV0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/chat-app-blog-post-part-2_09.png" alt=""&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Create the Queue Consumer&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Now that the messages are in the queue, you need to create the consumer that consumes the messages in the queue. To create the consumer, follow the steps below:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the application-properties.js file under static &amp;gt; resources and add ‘SOLACE_CHAT’ to sReceiveQueue.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--a6KAQXys--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/chat-app-blog-post-part-2_10.png" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;Open the pubsubplusbroker.js file, specify the queue descriptor, including the name and type of the queue, and set the acknowledge mode.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZCLmkhLV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/chat-app-blog-post-part-2_11.png" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;Add the following code to connect the message consumer.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uZchkqmS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/chat-app-blog-post-part-2_12.png" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;In your code editor, type &lt;strong&gt;mvn spring-boot:run&lt;/strong&gt; to run the application.&lt;/li&gt;
&lt;li&gt;Refresh the chat application in your browser.
You should be able to see the received messages from the broker.&lt;/li&gt;
&lt;li&gt;In the queue that you created earlier, click &lt;strong&gt;Summary&lt;/strong&gt; and then &lt;strong&gt;Refresh Data&lt;/strong&gt; in the bottom right corner. You should see that the messages are no longer in the queue because of auto acknowledgement.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hIs0f_GW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/08/chat-app-blog-post-part-2_13-1024x586.png" alt=""&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Congratulations! You have just created a queue, added a subscription to the queue, and created the queue consumer. In Part 3 of the series (coming soon), you will learn how to send a REST POST request from a login page to a dummy authentication service.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Related Resources&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://dev.to/hq190204/how-to-build-a-simple-chat-app-with-solace-part-1-4hg1-temp-slug-6948697"&gt;How to Build a Simple Chat Application with Solace (Part 1)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Udemy Course: &lt;a href="https://www.udemy.com/fundamentals-of-solace-development/"&gt;Fundamentals of Solace Development&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The post &lt;a href="https://solace.com/blog/build-chat-app-solace-2/"&gt;How to Build a Simple Chat App with Solace (Part 2)&lt;/a&gt; appeared first on &lt;a href="https://solace.com"&gt;Solace&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>solace</category>
      <category>chat</category>
    </item>
    <item>
      <title>How to Build a Simple Chat App with Solace (Part 1)</title>
      <dc:creator>Hong Qiu</dc:creator>
      <pubDate>Fri, 26 Jul 2019 19:58:37 +0000</pubDate>
      <link>https://dev.to/solacedevs/how-to-build-a-simple-chat-app-with-solace-part-1-3c9e</link>
      <guid>https://dev.to/solacedevs/how-to-build-a-simple-chat-app-with-solace-part-1-3c9e</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NqbU5CDv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/07/chat-app-blog-featured-image.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NqbU5CDv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/07/chat-app-blog-featured-image.jpg" alt=""&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;In this tutorial, you will learn how to build a simple chat browser application. At the end of the tutorial, the application will be able to send and receive messages via a direct topic subscription. Specifically, you will learn how to build the application, connect it to Solace PubSub+ Cloud, and start publishing/receiving messages.&lt;/p&gt;

&lt;h4&gt;
  
  
  Prerequisites
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://git-scm.com/downloads"&gt;Download Git&lt;/a&gt; to your computer&lt;/li&gt;
&lt;li&gt;&lt;a href="https://maven.apache.org/install.html%20"&gt;Install Apache Maven&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://console.solace.cloud/login"&gt;Sign up with Solace PubSub+ Cloud&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Level
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Beginner&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Build the Application
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;On the &lt;a href="https://github.com/SolaceTraining/fundamentals-of-solace-dev/tree/developer-exercise-1"&gt;Solace Training page&lt;/a&gt;, select master from the Branch drop-down menu, open the Clone or download tab, and copy the URL.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MpX5W9RA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/07/chat-app-pic_01.png" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;In your command line, type the following code line to clone a repository to your computer.
&lt;code&gt;git clone https://github.com/SolaceTraining/fundamentals-of-solace-dev.git&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;In your code editor, check out the developer-exercise-1 branch or in your command line, enter &lt;code&gt;git checkout remotes/origin/developer-exercise-1&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Under src &amp;gt; main &amp;gt; resources, duplicate the file application-template.properties and rename it to application.properties.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mgdD4sv4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/07/chat-app-pic_02.png" alt="Build the Application"&gt;
&lt;/li&gt;
&lt;li&gt;Download the Solace JavaScript messaging API.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--E-hKEhna--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/07/chat-app-pic_03.jpg" alt="Build the Application"&gt;
&lt;/li&gt;
&lt;li&gt;Copy the lib directory of your downloaded JavaScript API to the static directory of your cloned repository under src &amp;gt; main &amp;gt; resources.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Eq6qkjwK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/07/chat-app-pic_04.png" alt="Build the Application"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://maven.apache.org/download.cgi"&gt;Download Maven&lt;/a&gt; if you have not already done so.&lt;/li&gt;
&lt;li&gt;In your command line, enter &lt;code&gt;mvn clean install&lt;/code&gt; to compile the application.&lt;/li&gt;
&lt;li&gt;Type &lt;code&gt;mvn spring-boot:run&lt;/code&gt; to run the Web server. Make sure you are in the \web-app-server directory.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dZ1IebWw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/07/chat-app-pic_05-1024x347.png" alt=""&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Connect to the PubSub+ Cloud Service
&lt;/h2&gt;

&lt;p&gt;You have created your application. However, it needs to connect to the PubSub+ Cloud service for it to work.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Under static &amp;gt; resources, duplicate the application-properties-template.js file and rename it to application-properties.js.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MrKbK0MO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/07/chat-app-pic_06.png" alt="Connect to the PubSub+ Cloud Service 1"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://console.solace.cloud/login"&gt;Log in to Solace PubSub+ Cloud&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Create Service&lt;/strong&gt; button to create a service.&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Connect&lt;/strong&gt; tab.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---fEoc3Tq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/07/chat-app-pic_07.png" alt="Connect to the PubSub+ Cloud Service"&gt;
&lt;/li&gt;
&lt;li&gt;Open the Solace Web Messaging section.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3vp8ONsT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/07/chat-app-pic_08-1024x402.png" alt="Connect to the PubSub+ Cloud Service"&gt;
&lt;/li&gt;
&lt;li&gt;Copy the connection details to the application-properties.js file, add ‘solace/chat’ as the Publish and Subscribe topics, and save the file.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--X7OoyDHg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/07/chat-app-pic_09.png" alt="Connect to the PubSub+ Cloud Service"&gt;
&lt;em&gt;Note: Since we need the secure WebSocket connection, make sure that you use Secured Web Messaging Host as the sBROKERURL, not Web Messaging Host.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Type &lt;code&gt;mvn spring-boot:run&lt;/code&gt; to run the application. &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IdC4KbmS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/07/chat-app-pic_10.png" alt="Connect to the PubSub+ Cloud Service"&gt;
&lt;/li&gt;
&lt;li&gt;In your Web browser, type &lt;code&gt;localhost:8081&lt;/code&gt; to view the application.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WHZCh4WV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/07/chat-app-pic_11.png" alt=""&gt;
You should see a message that says you are connected to your PubSub+ Cloud service.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Publish and Receive Messages
&lt;/h2&gt;

&lt;p&gt;Though the application is connected to your PubSub+ Cloud service, it cannot yet publish and subscribe. In this section, you will modify the sample code to publish the messages to the Solace broker so that people who connect to it can receive them.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Under the script directory, open the pubsubplusbroker.js file.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fEkLqKvE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/07/chat-app-pic_12.png" alt="open the pubsubplusbroker.js file"&gt;
&lt;/li&gt;
&lt;li&gt;Type the code lines as shown below to create the message, define the topic destination, and set the delivery mode and the message body.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D9bQg6Em--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/07/chat-app-pic_13.png" alt=""&gt;
&lt;a href="https://docs.solace.com/Messaging-Basics/Core-Concepts-Message-Delivery-Modes.htm"&gt;Learn about message delivery modes.&lt;/a&gt;
&lt;a href="https://docs.solace.com/Messaging-Basics/Topic-Support-and-Syntax.htm"&gt;Learn about topics and topic support.&lt;/a&gt;
&lt;a href="https://docs.solace.com/API-Developer-Online-Ref-Documentation/js/solace.Message.html"&gt;Learn what each of the above code lines does.&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Type the code line shown below to call the broker session and send the message.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_MwGyt0S--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/07/chat-app-pic_14.png" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;Uncomment the oResultCallback and console.debug command lines so that you can see if the message is actually published.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ebBDrq-2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/07/chat-app-pic_15.png" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;Run the application.&lt;/li&gt;
&lt;li&gt;Log in to your Solace PubSub+ Cloud and click the &lt;strong&gt;Try Me!&lt;/strong&gt; tab.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--geQXb9Vd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/07/chat-app-pic_16.png" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;In the Subscriber section, click the &lt;strong&gt;Connect&lt;/strong&gt; button, add the topic “solace/chat”, and click the &lt;strong&gt;Subscribe&lt;/strong&gt; button.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PsFds-sX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/07/chat-app-pic_17.png" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;In your Web browser, type localhost:8081 or refresh the browser if you are already there.&lt;/li&gt;
&lt;li&gt;In the application, type “Hello World” and click the arrow.
You should see that the subscriber has received the message.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--78Tx3Cbz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/07/chat-app-pic_18.png" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;In the establishing the subscription section of the pubsubplusbroker.js file, type the following code lines to create a topic, generate an event, pass in a correlation key for the event, and define the number of milliseconds it will wait before stopping to add the subscription to the connection.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jSiTI9_---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/07/chat-app-pic_19.png" alt=""&gt;
&lt;/li&gt;
&lt;li&gt;Run the application.&lt;/li&gt;
&lt;li&gt;In the application in the browser, type a message and send it out.&lt;/li&gt;
&lt;li&gt;Open another browser at localhost:8081.
You should see that the message has been received.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CtBXWrzu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://solace.com/wp-content/uploads/2019/07/chat-app-pic_20.png" alt=""&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Congratulations!
&lt;/h2&gt;

&lt;p&gt;You have just created a chat application with Solace and sent and received messages via it. In the next part (coming soon), you will learn how to modify the sample code so that the application consumes messages from a queue instead of via a direct topic subscription.&lt;/p&gt;

&lt;p&gt;To learn more about coding for Solace PubSub+, check out the Udemy course &lt;em&gt;&lt;a href="https://www.udemy.com/fundamentals-of-solace-development/"&gt;Fundamentals of Solace Development&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The post &lt;a href="https://solace.com/blog/build-chat-app-solace-1/"&gt;How to Build a Simple Chat App with Solace (Part 1)&lt;/a&gt; appeared first on &lt;a href="https://solace.com"&gt;Solace&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>solace</category>
      <category>chat</category>
    </item>
  </channel>
</rss>
