-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #146 from viartemev/add-main-example
Add main example
- Loading branch information
Showing
5 changed files
with
63 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
<configuration> | ||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>%highlight(%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n)</pattern> | ||
</encoder> | ||
</appender> | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<configuration> | ||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>%msg%n</pattern> | ||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<root level="INFO"> | ||
<appender-ref ref="CONSOLE"/> | ||
<appender-ref ref="STDOUT"/> | ||
</root> | ||
|
||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...e-rabbit-example/src/main/kotlin/com/viartemev/thewhiterabbit/example/PublisherExample.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.viartemev.thewhiterabbit.example | ||
|
||
import com.rabbitmq.client.ConnectionFactory | ||
import com.rabbitmq.client.MessageProperties | ||
import com.viartemev.thewhiterabbit.channel.confirmChannel | ||
import com.viartemev.thewhiterabbit.channel.publish | ||
import com.viartemev.thewhiterabbit.publisher.OutboundMessage | ||
import kotlinx.coroutines.awaitAll | ||
import kotlinx.coroutines.coroutineScope | ||
import kotlinx.coroutines.runBlocking | ||
|
||
val EXCHANGE_NAME = "" | ||
val QUEUE_NAME = "test_queue" | ||
val times = 100_000 | ||
|
||
fun main() { | ||
val connectionFactory = ConnectionFactory().apply { useNio() } | ||
val connection = connectionFactory.newConnection() | ||
runBlocking { | ||
connection.confirmChannel { | ||
publish { | ||
coroutineScope { | ||
val messages = (1..times).map { createMessage("") } | ||
publishWithConfirmAsync(this.coroutineContext, messages).awaitAll() | ||
} | ||
} | ||
} | ||
} | ||
connection.close() | ||
} | ||
|
||
private fun createMessage(body: String) = | ||
OutboundMessage(EXCHANGE_NAME, QUEUE_NAME, MessageProperties.PERSISTENT_BASIC, body) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<configuration> | ||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{5} - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
|
||
<root level="DEBUG"> | ||
<appender-ref ref="STDOUT"/> | ||
</root> | ||
|
||
</configuration> |