Skip to content

Commit

Permalink
Create an example project for vertx-websocket
Browse files Browse the repository at this point in the history
  • Loading branch information
shravani committed Apr 8, 2024
1 parent f03efff commit a2969aa
Show file tree
Hide file tree
Showing 11 changed files with 1,168 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/modules/ROOT/attachments/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,10 @@
"title": "Tokenize a CSV file",
"description": "Shows how to define a Camel route in XML for tokenizing a CSV a file.",
"link": "https://github.com/apache/camel-quarkus-examples/tree/main/file-split-log-xml"
},
{
"title": "Vertx-Websocket Chat",
"description": "Shows how to configure a WebSocket server and interact with connected peers.",
"link": "https://github.com/apache/camel-quarkus-examples/tree/main/vertx-websocket-chat"
}
]
56 changes: 56 additions & 0 deletions vertx-websocket-chat/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
= Vertx-Websocket Chat: A Camel Quarkus example
:cq-example-description: An example that shows how to configure a WebSocket server and interact with connected peers.

{cq-description}

TIP: Check the https://camel.apache.org/camel-quarkus/latest/first-steps.html[Camel Quarkus User guide] for prerequisites
and other general information.

== Start in the Development mode

You can run your application in dev mode that enables live coding using:

[source,shell]
----
$ mvn compile quarkus:dev
----

The above command compiles the project, starts the application and lets the Quarkus tooling watch for changes in your workspace. Any modifications in your project will automatically take effect in the running application.You can find the application running http://localhost:8080

TIP: Please refer to the Development mode section of
https://camel.apache.org/camel-quarkus/latest/first-steps.html#_development_mode[Camel Quarkus User guide] for more details.

As we run the example in Quarkus Dev Mode, you can connect to the websocket by providing a username.Once you connect, you can see a chat room where you can send/receive messages.
You can write your message in the message section and you will be able to send the message either to a specific peer or to all of the users conncected by clicking the dropdown of the send button.You can click on the peer of your choice from the list to send the message only to that speicific peer.On clicking Send All,you can send your message to all of the users connected locally.You'll also be able to see the conversation on your window.

=== Package and run the application

Once you are done with developing you may want to package and run the application.

TIP: Find more details about the JVM mode and Native mode in the Package and run section of
https://camel.apache.org/camel-quarkus/latest/first-steps.html#_package_and_run_the_application[Camel Quarkus User guide]

==== JVM mode

[source,shell]
----
$ mvn clean package
$ java -jar target/quarkus-app/quarkus-run.jar
----

==== Native mode

IMPORTANT: Native mode requires having GraalVM and other tools installed. Please check the Prerequisites section
of https://camel.apache.org/camel-quarkus/latest/first-steps.html#_prerequisites[Camel Quarkus User guide].

To prepare a native executable using GraalVM, run the following command:

[source,shell]
----
$ mvn clean package -Pnative
$ ./target/*-runner
----

== Feedback

Please report bugs and propose improvements via https://github.com/apache/camel-quarkus/issues[GitHub issues of Camel Quarkus] project.
276 changes: 276 additions & 0 deletions vertx-websocket-chat/eclipse-formatter-config.xml

Large diffs are not rendered by default.

287 changes: 287 additions & 0 deletions vertx-websocket-chat/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,287 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>camel-quarkus-examples-vertx-websocket-chat</artifactId>
<groupId>org.apache.camel.quarkus.examples</groupId>
<version>3.10.0-SNAPSHOT</version>

<name>Camel Quarkus :: Examples :: Vertx-Websocket chat</name>
<description>Camel Quarkus Example :: Implementing Websocket</description>

<properties>
<quarkus.platform.version>3.9.0</quarkus.platform.version>
<camel-quarkus.platform.version>3.10.0-SNAPSHOT</camel-quarkus.platform.version>

<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<camel-quarkus.platform.group-id>org.apache.camel.quarkus</camel-quarkus.platform.group-id>
<camel-quarkus.platform.artifact-id>camel-quarkus-bom</camel-quarkus.platform.artifact-id>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.testTarget>${maven.compiler.target}</maven.compiler.testTarget>
<maven.compiler.testSource>${maven.compiler.source}</maven.compiler.testSource>

<formatter-maven-plugin.version>2.23.0</formatter-maven-plugin.version>
<impsort-maven-plugin.version>1.9.0</impsort-maven-plugin.version>
<license-maven-plugin.version>4.2</license-maven-plugin.version>
<maven-compiler-plugin.version>3.11.0</maven-compiler-plugin.version>
<maven-jar-plugin.version>3.3.0</maven-jar-plugin.version>
<maven-resources-plugin.version>3.3.1</maven-resources-plugin.version>
<maven-surefire-plugin.version>3.1.2</maven-surefire-plugin.version>
</properties>

<dependencyManagement>
<dependencies>
<!-- Import BOM -->
<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>${camel-quarkus.platform.group-id}</groupId>
<artifactId>${camel-quarkus.platform.artifact-id}</artifactId>
<version>${camel-quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-bean</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-jackson</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-vertx-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-direct</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-rest</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
</dependency>

<!-- Test -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>

<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>${formatter-maven-plugin.version}</version>
<configuration>
<configFile>${maven.multiModuleProjectDirectory}/eclipse-formatter-config.xml</configFile>
<lineEnding>LF</lineEnding>
</configuration>
</plugin>

<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
<version>${impsort-maven-plugin.version}</version>
<configuration>
<groups>java.,javax.,org.w3c.,org.xml.,junit.</groups>
<removeUnused>true</removeUnused>
<staticAfter>true</staticAfter>
<staticGroups>java.,javax.,org.w3c.,org.xml.,junit.</staticGroups>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<compilerArgs>
<arg>-Xlint:unchecked</arg>
</compilerArgs>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<failIfNoTests>false</failIfNoTests>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
</systemPropertyVariables>
</configuration>
</plugin>

<plugin>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>${quarkus.platform.version}</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
</plugin>

<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>${license-maven-plugin.version}</version>
<configuration>
<failIfUnknown>true</failIfUnknown>
<header>${maven.multiModuleProjectDirectory}/header.txt</header>
<excludes>
<exclude>**/*.adoc</exclude>
<exclude>**/*.txt</exclude>
<exclude>**/LICENSE.txt</exclude>
<exclude>**/LICENSE</exclude>
<exclude>**/NOTICE.txt</exclude>
<exclude>**/NOTICE</exclude>
<exclude>**/README</exclude>
<exclude>**/pom.xml.versionsBackup</exclude>
</excludes>
<mapping>
<java>SLASHSTAR_STYLE</java>
<properties>CAMEL_PROPERTIES_STYLE</properties>
<kt>SLASHSTAR_STYLE</kt>
</mapping>
<headerDefinitions>
<headerDefinition>${maven.multiModuleProjectDirectory}/license-properties-headerdefinition.xml</headerDefinition>
</headerDefinitions>
</configuration>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<executions>
<execution>
<id>build</id>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<executions>
<execution>
<id>format</id>
<goals>
<goal>format</goal>
</goals>
<phase>process-sources</phase>
</execution>
</executions>
</plugin>

<plugin>
<groupId>net.revelc.code</groupId>
<artifactId>impsort-maven-plugin</artifactId>
<executions>
<execution>
<id>sort-imports</id>
<goals>
<goal>sort</goal>
</goals>
<phase>process-sources</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<quarkus.package.type>native</quarkus.package.type>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemPropertyVariables>
<quarkus.package.type>${quarkus.package.type}</quarkus.package.type>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Loading

0 comments on commit a2969aa

Please sign in to comment.