This repository has been archived by the owner on Dec 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
136 additions
and
142 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,47 @@ | ||
import { sleep } from "k6"; | ||
import Amqp from 'k6/x/amqp'; | ||
import Queue from 'k6/x/amqp/queue'; | ||
|
||
export default function () { | ||
console.log("K6 amqp extension enabled, version: " + Amqp.version) | ||
const url = "amqp://guest:guest@localhost:5672/" | ||
Amqp.start({ | ||
connection_url: url | ||
}) | ||
console.log("Connection opened: " + url) | ||
|
||
const queueName = 'K6 general' | ||
|
||
Queue.declare({ | ||
name: queueName, | ||
// durable: false, | ||
// delete_when_unused: false, | ||
// exclusive: false, | ||
// no_wait: false, | ||
// args: null | ||
}) | ||
console.log("K6 amqp extension enabled, version: " + Amqp.version) | ||
const url = "amqp://guest:guest@localhost:5672/" | ||
Amqp.start({ | ||
connection_url: url | ||
}) | ||
console.log("Connection opened: " + url) | ||
|
||
console.log(queueName + " queue is ready") | ||
const queueName = 'K6 general' | ||
|
||
Amqp.publish({ | ||
queue_name: queueName, | ||
body: "Ping from k6" | ||
// exchange: '', | ||
// mandatory: false, | ||
// immediate: false, | ||
}) | ||
Queue.declare({ | ||
name: queueName, | ||
// durable: false, | ||
// delete_when_unused: false, | ||
// exclusive: false, | ||
// no_wait: false, | ||
// args: null | ||
}) | ||
|
||
console.log(queueName + " queue is ready") | ||
|
||
const listener = function(data) { console.log('received data: ' + data) } | ||
Amqp.listen({ | ||
queue_name: queueName, | ||
listener: listener, | ||
auto_ack: true, | ||
// consumer: '', | ||
// exclusive: false, | ||
Amqp.publish({ | ||
queue_name: queueName, | ||
body: "Ping from k6 vu: " + __VU + ", iter:"+ __ITER, | ||
// exchange: '', | ||
// mandatory: false, | ||
// immediate: false, | ||
}) | ||
|
||
const listener = function(data) { console.log(`received data by VU ${__VU}, ITER ${__ITER}: ${data} `)} | ||
Amqp.listen({ | ||
queue_name: queueName, | ||
listener: listener, | ||
auto_ack: true, | ||
// consumer: '', | ||
// exclusive: false, | ||
// no_local: false, | ||
// no_wait: false, | ||
// args: null | ||
}) | ||
// args: null | ||
}) | ||
|
||
sleep(2); | ||
} |
This file contains 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
Oops, something went wrong.