Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions kotlin-java-client/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/*
.gradle/*
95 changes: 95 additions & 0 deletions kotlin-java-client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# RabbitMQ Tutorials in Kotlin

This is a minimalistic Kotlin port of the [RabbitMQ tutorials in Java](https://www.rabbitmq.com/getstarted.html).
The port is admittedly quite close to Java in terms of code style.


## Compiling the Code

``` shell
gradle clean compileKotlin
```

## Running the Tutorials

### Tutorial 1

Execute the following command to start a Hello, world consumer

``` shell
gradle run -P main=Recv
```

Execute the following in a separate shell to publish a Hello, world messge:

``` shell
gradle run -P main=Send
```

### Tutorial 2

Send a task message. The task will be completed immediately

``` shell
gradle run -P main=NewTask
```

To start a worker (run in a separate shell):

``` shell
gradle run -P main=Worker
```

Send a task message. It will wait for 1 second for each dot in the payload.

``` shell
gradle run -P main=NewTask -P argv="rabbit1 ...."
```

Add more workers to the same queue, message will be distributed in the
round robin manner.

### Tutorial 3

``` shell
gradle run -P main=ReceiveLogs
```


``` shell
gradle run -P main=EmitLog -P argv="rabbit1, msg1"
```

### Tutorial 4

``` shell
gradle run -P main="ReceiveLogsDirect" -P argv="info,error"
```

``` shell
gradle run -P main=EmitLogDirect"
```

### Tutorial 5

``` shell
gradle run -P main=ReceiveLogsTopic -P argv="anonymous.*"
```

``` shell
gradle run -P main=EmitLogTopic -P argv="anonymous.info"
```

### Tutorial 6

In one shell:

``` shell
gradle run -P main=RPCServer
```

In another shell:

``` shell
gradle run -P main=RPCClient
```
File renamed without changes.
2 changes: 2 additions & 0 deletions kotlin-java-client/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
main =
argv =
File renamed without changes.
1 change: 1 addition & 0 deletions kotlin/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build/*
.gradle/*
.kotlin
94 changes: 1 addition & 93 deletions kotlin/README.md
Original file line number Diff line number Diff line change
@@ -1,95 +1,3 @@
# RabbitMQ Tutorials in Kotlin
# RabbitMQ Tutorials in Kotlin (JVM & Native)

This is a minimalistic Kotlin port of the [RabbitMQ tutorials in Java](https://www.rabbitmq.com/getstarted.html).
The port is admittedly quite close to Java in terms of code style.


## Compiling the Code

``` shell
gradle clean compileKotlin
```

## Running the Tutorials

### Tutorial 1

Execute the following command to start a Hello, world consumer

``` shell
gradle run -P main=Recv
```

Execute the following in a separate shell to publish a Hello, world messge:

``` shell
gradle run -P main=Send
```

### Tutorial 2

Send a task message. The task will be completed immediately

``` shell
gradle run -P main=NewTask
```

To start a worker (run in a separate shell):

``` shell
gradle run -P main=Worker
```

Send a task message. It will wait for 1 second for each dot in the payload.

``` shell
gradle run -P main=NewTask -P argv="rabbit1 ...."
```

Add more workers to the same queue, message will be distributed in the
round robin manner.

### Tutorial 3

``` shell
gradle run -P main=ReceiveLogs
```


``` shell
gradle run -P main=EmitLog -P argv="rabbit1, msg1"
```

### Tutorial 4

``` shell
gradle run -P main="ReceiveLogsDirect" -P argv="info,error"
```

``` shell
gradle run -P main=EmitLogDirect"
```

### Tutorial 5

``` shell
gradle run -P main=ReceiveLogsTopic -P argv="anonymous.*"
```

``` shell
gradle run -P main=EmitLogTopic -P argv="anonymous.info"
```

### Tutorial 6

In one shell:

``` shell
gradle run -P main=RPCServer
```

In another shell:

``` shell
gradle run -P main=RPCClient
```
29 changes: 29 additions & 0 deletions kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
plugins {
kotlin("multiplatform") version "2.1.21"
}

repositories {
mavenCentral()
}

kotlin {
// Examples can be executed with JVM or natively for macOS, Linux, or Windows
jvm()
macosArm64()
linuxX64()
mingwX64()

applyDefaultHierarchyTemplate()
sourceSets {
val commonMain by getting {
dependencies {
api("dev.kourier:amqp-client:0.3.1")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
}
}
Binary file added kotlin/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions kotlin/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading