Created
March 9, 2011 14:59
-
-
Save dahernan/862333 to your computer and use it in GitHub Desktop.
rabbitmqinject.groovy
This file contains hidden or 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
import com.rabbitmq.client.* | |
import java.util.Random | |
@Grab(group='com.rabbitmq', module='amqp-client', version='1.7.2') | |
params = new ConnectionParameters( | |
username: 'guest', | |
password: 'guest', | |
virtualHost: '/', | |
requestedHeartbeat: 0 | |
) | |
factory = new ConnectionFactory(params) | |
conn = factory.newConnection('127.0.0.1', 5672) | |
channel = conn.createChannel() | |
exchangeName = 'stockExchange' | |
key = 'key.a' | |
Random rand = new Random() | |
int max = 10 | |
while(true){ | |
int next = rand.nextInt(max+1) | |
String msg = "${next}" | |
channel.basicPublish(exchangeName, key , MessageProperties.TEXT_PLAIN , msg.bytes) | |
Thread.sleep(300) | |
} | |
channel.close() | |
conn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment