Skip to content

Commit 1905432

Browse files
committed
Merge branch '1.x.x-stable'
2 parents 53c608e + caaa980 commit 1905432

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/main/java/com/rabbitmq/perf/Consumer.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
import com.rabbitmq.client.Envelope;
2222
import com.rabbitmq.client.ShutdownSignalException;
2323

24-
import java.io.ByteArrayInputStream;
25-
import java.io.DataInputStream;
2624
import java.io.IOException;
2725
import java.util.Collections;
2826
import java.util.HashMap;
@@ -114,9 +112,14 @@ public void handleDelivery(String consumerTag, Envelope envelope, BasicPropertie
114112
msgCount++;
115113

116114
if (msgLimit == 0 || msgCount <= msgLimit) {
117-
DataInputStream d = new DataInputStream(new ByteArrayInputStream(body));
118-
d.readInt();
119-
long msgNano = d.readLong();
115+
long msgNano;
116+
Object timestamp = properties.getHeaders().get("timestamp");
117+
if (timestamp == null) {
118+
msgNano = Long.MAX_VALUE;
119+
} else {
120+
msgNano = (Long) timestamp;
121+
}
122+
120123
long nano = System.nanoTime();
121124

122125
if (!autoAck) {

src/main/java/com/rabbitmq/perf/Producer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ private void publish(MessageBodySource.MessageBodyAndContentType messageBodyAndC
161161
propertiesBuilder.contentType(messageBodyAndContentType.getContentType());
162162
}
163163

164+
propertiesBuilder.headers(Collections.<String, Object>singletonMap("timestamp", System.nanoTime()));
165+
164166
unconfirmedSet.add(channel.getNextPublishSeqNo());
165167
channel.basicPublish(exchangeName, randomRoutingKey ? UUID.randomUUID().toString() : id,
166168
mandatory, false,

0 commit comments

Comments
 (0)