Skip to content

Commit 8159742

Browse files
authored
Merge pull request #146 from viartemev/add-main-example
Add main example
2 parents 87d5742 + d5d9c9e commit 8159742

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
@@ -192,6 +192,15 @@ project('the-white-rabbit-vertx-example') {
192192
}
193193
}
194194

195+
project('the-white-rabbit-example') {
196+
dependencies {
197+
compile rootProject
198+
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.8.0-beta4'
199+
runtime group: 'ch.qos.logback', name: 'logback-classic', version: '1.3.0-alpha4'
200+
runtime group: 'ch.qos.logback', name: 'logback-core', version: '1.3.0-alpha4'
201+
}
202+
}
203+
195204
project('benchmarks') {
196205
apply plugin: "com.github.johnrengelman.shadow"
197206
apply plugin: "me.champeau.gradle.jmh"
@@ -216,3 +225,4 @@ project('benchmarks') {
216225
}
217226
jmhCompileGeneratedClasses.finalizedBy deleteEmptyBmList
218227
}
228+

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)