Skip to content

Commit d5d9c9e

Browse files
author
Vyacheslav Artemyev
committed
Add main example
1 parent 6c163d5 commit d5d9c9e

File tree

5 files changed

+63
-8
lines changed

5 files changed

+63
-8
lines changed
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
<configuration>
2-
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
3-
<encoder>
4-
<pattern>%highlight(%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n)</pattern>
5-
</encoder>
6-
</appender>
1+
<?xml version="1.0" encoding="UTF-8"?>
72

3+
<configuration>
84
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
95
<encoder>
10-
<pattern>%msg%n</pattern>
6+
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern>
117
</encoder>
128
</appender>
139

1410
<root level="INFO">
15-
<appender-ref ref="CONSOLE"/>
11+
<appender-ref ref="STDOUT"/>
1612
</root>
13+
1714
</configuration>

build.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,15 @@ project('the-white-rabbit-vertx-example') {
190190
}
191191
}
192192

193+
project('the-white-rabbit-example') {
194+
dependencies {
195+
compile rootProject
196+
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.8.0-beta4'
197+
runtime group: 'ch.qos.logback', name: 'logback-classic', version: '1.3.0-alpha4'
198+
runtime group: 'ch.qos.logback', name: 'logback-core', version: '1.3.0-alpha4'
199+
}
200+
}
201+
193202
project('benchmarks') {
194203
apply plugin: "com.github.johnrengelman.shadow"
195204
apply plugin: "me.champeau.gradle.jmh"
@@ -214,3 +223,4 @@ project('benchmarks') {
214223
}
215224
jmhCompileGeneratedClasses.finalizedBy deleteEmptyBmList
216225
}
226+

settings.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pluginManagement {
1616
rootProject.name = 'the-white-rabbit'
1717

1818
include('benchmarks')
19+
include('the-white-rabbit-example')
1920
include('the-white-rabbit-ktor-example')
2021
include('the-white-rabbit-spring-boot-example')
2122
include('the-white-rabbit-vertx-example')
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.viartemev.thewhiterabbit.example
2+
3+
import com.rabbitmq.client.ConnectionFactory
4+
import com.rabbitmq.client.MessageProperties
5+
import com.viartemev.thewhiterabbit.channel.confirmChannel
6+
import com.viartemev.thewhiterabbit.channel.publish
7+
import com.viartemev.thewhiterabbit.publisher.OutboundMessage
8+
import kotlinx.coroutines.awaitAll
9+
import kotlinx.coroutines.coroutineScope
10+
import kotlinx.coroutines.runBlocking
11+
12+
val EXCHANGE_NAME = ""
13+
val QUEUE_NAME = "test_queue"
14+
val times = 100_000
15+
16+
fun main() {
17+
val connectionFactory = ConnectionFactory().apply { useNio() }
18+
val connection = connectionFactory.newConnection()
19+
runBlocking {
20+
connection.confirmChannel {
21+
publish {
22+
coroutineScope {
23+
val messages = (1..times).map { createMessage("") }
24+
publishWithConfirmAsync(this.coroutineContext, messages).awaitAll()
25+
}
26+
}
27+
}
28+
}
29+
connection.close()
30+
}
31+
32+
private fun createMessage(body: String) =
33+
OutboundMessage(EXCHANGE_NAME, QUEUE_NAME, MessageProperties.PERSISTENT_BASIC, body)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<configuration>
4+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
5+
<encoder>
6+
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern>
7+
</encoder>
8+
</appender>
9+
10+
<root level="DEBUG">
11+
<appender-ref ref="STDOUT"/>
12+
</root>
13+
14+
</configuration>

0 commit comments

Comments
 (0)