@@ -14,6 +14,7 @@ Version 0.8:
|
|||||||
Fixed bug that on connection stolen dropped also the new connection (fix issue #108)
|
Fixed bug that on connection stolen dropped also the new connection (fix issue #108)
|
||||||
Refactored the storage part to be more rational and use ClientSession concept
|
Refactored the storage part to be more rational and use ClientSession concept
|
||||||
Added config property 'autosave_interval' (issue #97)
|
Added config property 'autosave_interval' (issue #97)
|
||||||
|
Removed leaking ref to parent's node (issue #119 and #126)
|
||||||
|
|
||||||
Version 0.7:
|
Version 0.7:
|
||||||
Fix issue #38, added aligned to MQTT 3.1.1
|
Fix issue #38, added aligned to MQTT 3.1.1
|
||||||
|
|||||||
@@ -14,11 +14,13 @@ class PublisherThread extends Thread {
|
|||||||
private final String host = "localhost"
|
private final String host = "localhost"
|
||||||
private final byte[] payload
|
private final byte[] payload
|
||||||
private final int numToSend
|
private final int numToSend
|
||||||
|
private final boolean oneClientPerTopic
|
||||||
|
|
||||||
PublisherThread(int pubId, int numToSend, byte[] payload) {
|
PublisherThread(int pubId, int numToSend, byte[] payload, boolean oneClientPerTopic) {
|
||||||
this.numToSend = numToSend
|
this.numToSend = numToSend
|
||||||
this.payload = payload
|
this.payload = payload
|
||||||
this.pubId = pubId
|
this.pubId = pubId
|
||||||
|
this.oneClientPerTopic = oneClientPerTopic
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -29,26 +31,28 @@ class PublisherThread extends Thread {
|
|||||||
mqtt.setCleanSession(true)
|
mqtt.setCleanSession(true)
|
||||||
mqtt.setHost(host, 1883)
|
mqtt.setHost(host, 1883)
|
||||||
|
|
||||||
|
def postFix = oneClientPerTopic ? subId : ""
|
||||||
|
|
||||||
mqtt.setClientId("PublisherClient${pubId}")
|
mqtt.setClientId("PublisherClient${pubId}")
|
||||||
BlockingConnection connection = mqtt.blockingConnection()
|
BlockingConnection connection = mqtt.blockingConnection()
|
||||||
connection.connect()
|
connection.connect()
|
||||||
(1..numToSend).each {
|
(1..numToSend).each {
|
||||||
connection.publish("/topic${pubId}", this.payload, QoS.AT_MOST_ONCE, false)
|
connection.publish("/topic${postFix}", this.payload, QoS.AT_MOST_ONCE, false)
|
||||||
}
|
}
|
||||||
connection.publish("/exit${pubId}", 'Exit'.bytes, QoS.AT_MOST_ONCE, false)
|
connection.publish("/exit${postFix}", 'Exit'.bytes, QoS.AT_MOST_ONCE, false)
|
||||||
connection.disconnect()
|
connection.disconnect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.size() < 1) {
|
if (args.size() < 2) {
|
||||||
println "Usage: groovy issue79_stress_multipub.groovy num_publishers"
|
println "Usage: groovy issue79_stress_multipub.groovy num_publishers [single_topic]"
|
||||||
}
|
}
|
||||||
|
boolean singleTopic = (args.size() == 2 && args[1] == "single_topic")
|
||||||
final byte[] payload = 'Hello world!!'.bytes
|
final byte[] payload = 'Hello world!!'.bytes
|
||||||
|
|
||||||
int numPublishers = args[0] as Integer
|
int numPublishers = args[0] as Integer
|
||||||
(1..numPublishers).each { numPub ->
|
(1..numPublishers).each { numPub ->
|
||||||
def pubTh = new PublisherThread(numPub, 5, payload)
|
def pubTh = new PublisherThread(numPub, 5, payload, singleTopic)
|
||||||
pubTh.start()
|
pubTh.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,11 @@ class SubscriberThread extends Thread {
|
|||||||
|
|
||||||
private final int subId
|
private final int subId
|
||||||
private final String host = "localhost"
|
private final String host = "localhost"
|
||||||
|
private final boolean oneClientPerTopic
|
||||||
|
|
||||||
SubscriberThread(int subId) {
|
SubscriberThread(int subId, boolean oneClientPerTopic) {
|
||||||
this.subId = subId
|
this.subId = subId
|
||||||
|
this.oneClientPerTopic = oneClientPerTopic
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -28,12 +30,14 @@ class SubscriberThread extends Thread {
|
|||||||
mqtt.setClientId("SubscriberClient${subId}")
|
mqtt.setClientId("SubscriberClient${subId}")
|
||||||
BlockingConnection connection = mqtt.blockingConnection()
|
BlockingConnection connection = mqtt.blockingConnection()
|
||||||
connection.connect()
|
connection.connect()
|
||||||
Topic[] topics = [new Topic("/topic${subId}", QoS.AT_MOST_ONCE), new Topic("/exit${subId}", QoS.AT_MOST_ONCE)]
|
|
||||||
|
def postFix = oneClientPerTopic ? subId : ""
|
||||||
|
Topic[] topics = [new Topic("/topic${postFix}", QoS.AT_MOST_ONCE), new Topic("/exit${postFix}", QoS.AT_MOST_ONCE)]
|
||||||
byte[] qoses = connection.subscribe(topics)
|
byte[] qoses = connection.subscribe(topics)
|
||||||
boolean exit = false
|
boolean exit = false
|
||||||
while (!exit) {
|
while (!exit) {
|
||||||
Message message = connection.receive()
|
Message message = connection.receive()
|
||||||
if (message.topic == "/exit${subId}") {
|
if (message.topic == "/exit${postFix}") {
|
||||||
exit = true
|
exit = true
|
||||||
}
|
}
|
||||||
message.ack()
|
message.ack()
|
||||||
@@ -44,12 +48,13 @@ class SubscriberThread extends Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args.size() < 1) {
|
if (args.size() < 1) {
|
||||||
println "Usage: groovy issue79_stress_multisub.groovy num_subscribers"
|
println "Usage: groovy issue79_stress_multisub.groovy num_subscribers [single_topic]"
|
||||||
}
|
}
|
||||||
|
|
||||||
int numSubscriber = args[0] as Integer
|
int numSubscriber = args[0] as Integer
|
||||||
|
boolean singleTopic = (args.size() == 2 && args[1] == "single_topic")
|
||||||
(1..numSubscriber).each { numSub ->
|
(1..numSubscriber).each { numSub ->
|
||||||
def subTh = new SubscriberThread(numSub)
|
def subTh = new SubscriberThread(numSub, singleTopic)
|
||||||
subTh.start()
|
subTh.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user