forked from rabbitmq/rabbitmq-jms-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sanity-check.groovy
36 lines (32 loc) · 1.59 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
35
36
@GrabResolver(name = 'rabbitmq-bintray', root = 'https://dl.bintray.com/rabbitmq/maven')
@GrabResolver(name = 'rabbitmq-packagecloud-milestones', root = 'https://packagecloud.io/rabbitmq/maven-milestones/maven2')
@Grab(group = 'com.rabbitmq.jms', module = 'rabbitmq-jms', version = "${version}")
@Grab(group = 'org.slf4j', module = 'slf4j-simple', version = '1.7.25')
import com.rabbitmq.jms.admin.RMQConnectionFactory
import org.slf4j.LoggerFactory
import javax.jms.DeliveryMode
import javax.jms.QueueReceiver
import javax.jms.QueueSender
import javax.jms.QueueSession
import javax.jms.Session
def connection = new RMQConnectionFactory().createConnection()
try {
connection.start();
QueueSession queueSession = connection.createQueueSession(false, Session.DUPS_OK_ACKNOWLEDGE);
def queue = queueSession.createTemporaryQueue()
QueueSender queueSender = queueSession.createSender(queue)
queueSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT)
def message = queueSession.createTextMessage("Hello")
queueSender.send(message)
QueueReceiver queueReceiver = queueSession.createReceiver(queue)
message = queueReceiver.receive(5000)
if (message == null)
throw new IllegalStateException("Didn't receive message in 5 seconds")
LoggerFactory.getLogger("rabbitmq").info("Test succeeded with JMS Client {}",
RMQConnectionFactory.package.getImplementationVersion())
System.exit 0
} catch (Exception e) {
LoggerFactory.getLogger("rabbitmq").info("Test failed with JMS Client {}",
RMQConnectionFactory.package.getImplementationVersion(), e)
System.exit 1
}