Creating a Messaging App Using Spring for Apache Kafka, Part 4
Photo by Daniel Tran on Unsplash
This article is part of a series. The GitHub repository with code examples can be found here.
After a long break from this series let’s keep moving further.
Let’s configure and prepare the WebSocket session pool. As we go through some custom operations like authentication and storing messages on the time of socket messages and sessions received, we need to create a WebSocketHandler for WebSocket configuration. When a WebSocket session message is received we’re going to send the message to a Kafka topic. In order to achieve this we need to define our WebSocket message handler MessageHandler
and Kafka message producer MessageSender
. We also need a session pool WebSocketPool
so we can manage the client sessions.
WebSocketPool
package com.endpoint.SpringKafkaMessaging.websocket;
import org.springframework.web.socket.WebSocketSession;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class WebSocketPool {
public static Map<Long, Set<WebSocketSession>> websockets = new HashMap<>();
}
WebSocketPool
holds client sessions in a map of <user_id, <set of WebSocketSession>>
. This map allows multiple …
java spring kafka spring-kafka-series
Cesium KML-CZML Editor
End Point’s immersive technology team is happy to present a great new tool for the rapidly growing Cesium community: Cesium KML-CZML Editor. The editor gives users the ability to visually and dynamically edit KML and CZML in its Cesium browser window. Updates made with it can be exported at any time to CZML, the native markup language for Cesium.
The Cesium KML-CZML Editor addresses an important but hitherto unaddressed need of the Cesium community: It provides an intuitive interface for making adjustments to fix the many inconsistencies with how KML created for (and often by) Google Earth appears on 3D maps rendered with Cesium. It is a powerful tool for converting and adapting KML for Google Earth into CZML that displays nicely in Cesium. The editor also works as a visual editor for creating and editing CZML, regardless of whether you’re converting from KML.
The inconsistencies with how Cesium displays KML created for Google Earth are due to occasional differences between how Cesium and Google Earth render KML when various attributes aren’t specifically set within a given instance of code. The situation is similar to how web browsers sometimes interpret given instances of HTML …
cesium google-earth gis open-source visionport
Media erasure in the time of SSD
How valuable is your data? Losing it to a third party is usually a business’s worst nightmare—and can cause legal or even criminal repercussions, depending on the drive’s contents and the business’s jurisdiction.
Every system adminstrator worth their salt knows that running “rm” (or equivalent delete operations) doesn’t actually remove data, it simply removes the file name from the filesystem and leaves the data in place on the disk.
When dealing with traditional storage, destroying (intentionally or otherwise) your data used to be relatively easy. A wise system admin could simply run:
shred /dev/sda
And be fairly certain of the result. A cautious one might run a demagnetizing wand over the drive. Only the most paranoid might destroy it physically.
The Age of SSDs
Nowadays, most servers have switched away from storing data on rotating metal or glass platters. Solid state drives, or SSDs, are faster, less prone to errors from physical impact, and generally more sought after.
SSDs have issues with speed if the drives are too full, and have a limited lifespan—only a certain number of write operations can be achieved. This is less of an issue with modern …
security storage
Vue 3 is out with exciting new features
Photo courtesy of NASA
Vue 3 was officially released on September 18, 2020 with improved performance and some exciting new features.
Composition API
The Composition API is one of the most significant changes. It helps with logically grouping related fragments of components. In Vue 2, we used the Options API to pass various options during component configuration:
// src/components/ProductList.vue
<template>
<div class="child">
<h3>Vue2</h3>
<div>
<div class="add-product">
<h2>Add Product</h2>
<div>Name: <input name="name" v-model="newProduct.name" /></div>
<div>Price: <input name="name" v-model="newProduct.price" /></div>
<button @click="addProduct">Add</button>
</div>
<div class="search-product">
<h2>Search Product</h2>
<input name="name" v-model="filterText" placeholder="Start typing to search" />
</div>
</div>
<div class="list-product">
<h1 …
vue frameworks javascript
3D Audio Fundamentals
Photo by PT Russell on Unsplash
It’s easy to prove to yourself that you need two eyes to perceive how far away things are in the world around you. Shut one eye and the world appears flat. This ability is called stereoscopic vision. A lesser-known exercise is proving that you also need two ears to perceive which direction a sound is coming from. Shut one ear and the world outside your vision is harder to track. This ability is called binaural hearing.
As VR technology continues to push the boundaries of sight immersion with increasing accessibility, sound reproduction has not lagged behind. In fact, the consumer hardware needed for sound immersion has been accessible for decades. By leveraging 3D audio techniques, a pair of headphones can be turned into the aural equivalent of a VR headset.
The magic of stereophonic audio reproduction was first demonstrated in 1881 when French inventor Clément Ader connected microphones on the stage of the Paris Opera to listening rooms in the Palais de l’Industrie through telephone lines, where visitors experienced remote live performances on pairs of receivers. The exhibit was extremely popular and got a glowing review in Scientific American.
The …
audio
Demonstrating the QuickBooks Desktop SDK
Is your client or company thinking about switching to QuickBooks? If so, you might be discovering that migrating your existing financial and sales data out of your old system and into QuickBooks is both time consuming and tedious. You might even have an existing ecommerce site or database with tons of data and no clear way of getting the orders into QuickBooks without manual entry.
Recently I was tasked with solving this problem. Our client needed to migrate data from an existing MySQL database into QuickBooks, and automatically add orders from our ecommerce site directly into QuickBooks going forward.
In this article I’ll go over how to use the QuickBooks Desktop SDK (also referred to as QBFC for “QuickBooks Foundation Classes” in the API documentation) to send and receive data from QuickBooks.
QuickBooks primer for developers
For the uninitiated, QuickBooks is an accounting software made by Intuit. It can be used to manage lots of data, including lists of customers, inventory items, sales orders, and invoices. All of this data is stored in a “company file”, which is a file with a .qbw extension that uses a proprietary data format. This file gets created …
csharp dotnet
A great gift for the holidays: No ads!
Many people will bring home a pie during the holiday season, but perhaps you’ll find a place in your home network for a Raspberry Pi instead?
With more people than ever working from home, many more people are using their personal infrastructure to conduct business, and aren’t able to rely on a crack team of network engineers to make sure their system is secure. While there are many things one can do to improve network security, from using a VPN to ensuring you update your system, a Pi-hole is one quick, inexpensive way to help keep your network a little safer not just on your phone or laptop, but on every device that connects to your router.
It’s great not only for technical types, but for everyone who connects to your network. You can even set it up with remote access and gift it to a relative, as long as you’re willing to fix it if it breaks. With the holiday season coming up, it’s surely something to consider.
Shut the door with Pi-hole
Pi-hole is an open source DNS server for your local network which blocks advertising and, after adding some extra block lists, some malicious websites.
This is done before the data even gets downloaded, by redirecting requests for ads and …
linux security networking
Svelte: A compiled JavaScript front-end framework
It seems like JavaScript frameworks are a dime a dozen these days. In the JavaScript world, there are frameworks and libraries for almost every task that you can imagine, and there is much overlap. In the front-end web development area though, there are three who reign supreme: Angular, React, and Vue.js. Whether you’re building single-page apps or traditional web apps with some front-end zest, you can’t go wrong with any of these three.
Recently though, I discovered a new player in this field that promises to offer a similar developer experience to existing frameworks with great performance gains. Its name is Svelte, and it achieves this promise in a very interesting way: it’s a compiler.
This is a novel approach to the front-end web development problem. While traditional front-end frameworks are libraries with runtime components that get loaded and executed in the browser, Svelte itself only runs at development/build time, on your development machine. Svelte takes the JavaScript components that we write, compiles them into pure, lean JavaScript and emits only that to the browser. No big library, or runtime, or interpretation of components ever happens in the browser. It doesn’t …
javascript development frameworks