-
Notifications
You must be signed in to change notification settings - Fork 55
/
sanity-check.groovy
34 lines (32 loc) · 1.43 KB
/
sanity-check.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import org.slf4j.LoggerFactory
import reactor.core.publisher.Flux
import reactor.rabbitmq.OutboundMessage
import reactor.rabbitmq.QueueSpecification
@GrabResolver(name = 'spring-milestone', root = 'https://repo.spring.io/libs-snapshot')
@GrabResolver(name = 'spring-staging', root = 'https://repo.spring.io/libs-staging-local/')
@Grab(group = 'io.projectreactor.rabbitmq', module = 'reactor-rabbitmq', version = "${version}")
@Grab(group = 'org.slf4j', module = 'slf4j-simple', version = '1.7.25')
import reactor.rabbitmq.RabbitFlux
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
try {
def latch = new CountDownLatch(10)
def sender = RabbitFlux.createSender()
sender.declare(QueueSpecification.queue("").autoDelete(true))
.subscribe({ q ->
RabbitFlux.createReceiver().consumeNoAck(q.getQueue())
.subscribe({ d -> latch.countDown() })
def messages = Flux.range(1, 10)
.map({ i -> new OutboundMessage("", q.getQueue(), "".getBytes()) })
sender.send(messages).subscribe()
})
latch.await(5, TimeUnit.SECONDS)
def received = latch.await(5, TimeUnit.SECONDS)
if (!received)
throw new IllegalStateException("Didn't receive message in 5 seconds")
LoggerFactory.getLogger("rabbitmq").info("Test succeeded")
System.exit 0
} catch(Exception e) {
LoggerFactory.getLogger("rabbitmq").info("Test failed", e)
System.exit 1
}