Last active
April 28, 2016 17:43
-
-
Save dangnhdev/a6be384682fc19722e511373a2c89b4d to your computer and use it in GitHub Desktop.
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.*; | |
public class Publisher { | |
private static final String EXCHANGE_NAME = "topic_test"; | |
public static void main(String[] argv) throws Exception { | |
ConnectionFactory factory = new ConnectionFactory(); | |
factory.setHost("localhost"); | |
Connection connection = factory.newConnection(); | |
Channel channel = connection.createChannel(); | |
channel.exchangeDeclare(EXCHANGE_NAME, "topic"); | |
String routingKey = "foo.bar"; | |
String message = "TestMsg"; | |
for (int i = 0; i < 1_000; i++) { | |
/*Persistent message*/ | |
channel.basicPublish(EXCHANGE_NAME, routingKey, MessageProperties.PERSISTENT_TEXT_PLAIN, message.getBytes()); | |
System.out.println(" [x] Sent " + i); | |
} | |
connection.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment