Skip to content

Commit 0d0a9eb

Browse files
author
Matthias Radestock
committed
use standard resources and an exclusive queue
for simplicity and in order to not to leave garbage behind
1 parent 853c3e2 commit 0d0a9eb

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

test/src/com/rabbitmq/examples/BufferPerformanceMetrics.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.rabbitmq.client.MessageProperties;
77
import com.rabbitmq.client.Consumer;
88
import com.rabbitmq.client.QueueingConsumer;
9+
import com.rabbitmq.client.AMQP.Queue;
910

1011
import java.net.Socket;
1112
import java.io.IOException;
@@ -19,9 +20,6 @@
1920
*/
2021
public class BufferPerformanceMetrics {
2122

22-
public static final String QUEUE = "performance-test-queue";
23-
public static final String EXCHANGE = "performance-test-exchange";
24-
public static final String ROUTING_KEY = "performance-test-rk";
2523
public static final int MESSAGE_COUNT = 100000;
2624
public static final byte[] MESSAGE = "Hello world".getBytes();
2725
public static final int REPEATS = 1000000;
@@ -61,21 +59,20 @@ public void configureSocket(Socket socket)
6159

6260
Connection connection = factory.newConnection(hostName);
6361
Channel channel = connection.createChannel();
64-
channel.exchangeDeclare(EXCHANGE, "direct");
65-
channel.queueDeclare(QUEUE);
66-
channel.queueBind(QUEUE, EXCHANGE, ROUTING_KEY);
62+
Queue.DeclareOk res = channel.queueDeclare();
63+
String queueName = res.getQueue();
6764

6865
long start;
6966

7067
start = System.nanoTime();
7168

7269
for(int i = 0; i < MESSAGE_COUNT; i++) {
73-
channel.basicPublish(EXCHANGE, ROUTING_KEY,
70+
channel.basicPublish("", queueName,
7471
MessageProperties.BASIC, MESSAGE);
7572
}
7673

7774
QueueingConsumer consumer = new QueueingConsumer(channel);
78-
channel.basicConsume(QUEUE, true, consumer);
75+
channel.basicConsume(queueName, true, consumer);
7976

8077
long publishTime = System.nanoTime() - start;
8178

0 commit comments

Comments
 (0)