Creating multiple rooms for chat.

Hello, i`m doing a project based on Spring Boot and i integrated Vaadin in my project for purpose of writing chat. And i managed to write a chat, where multiple users can talk with each other. But how can i create a multiple rooms , for instance: one is Henry - Lara and second is Henry - John , and save this all rooms at one page, to let Henry switch between them. How can i do that? Here is my 2 classes of group chat. I would appreciate any help, if i even would need to change the whole code.

message.txt (4.06 KB)

import com.vaadin.flow.component.ComponentEvent;
import com.vaadin.flow.component.ComponentEventBus;
import com.vaadin.flow.component.ComponentEventListener;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.shared.Registration;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.stereotype.Component;

import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;

public class Storage {
    private Queue<ChatMessage> messages = new ConcurrentLinkedQueue<>();
    private ComponentEventBus eventBus = new ComponentEventBus(new Div());

    public static class ChatMessage {
        private String name;
        private String message;

    public static class ChatEvent extends ComponentEvent<Div> {
        public ChatEvent() {
            super(new Div(), false);

    public void addRecord(String user, String message) {
        messages.add(new ChatMessage(user, message));
        eventBus.fireEvent(new ChatEvent());

    public void addRecordJoined(String user) {
        messages.add(new ChatMessage("", user));
        eventBus.fireEvent(new ChatEvent());

    public Registration attachListener(ComponentEventListener<ChatEvent> messageListener) {
        return eventBus.addListener(ChatEvent.class, messageListener);

    public int size() {
        return messages.size();

How “real” does the solution need to be? Is it just a demo project, or something that will have real users? Does message history need to be persisted?