RabbitMQ Steps
-
create a queue
createRabbitmqQueue
-
delete a queue
deleteRabbitmqQueue
-
publish a message on a queue
publishRabbitmqMessage
-
read a message from a queue
givenMessageFromRabbitmqQueue
-
read multiple messages from a queue
givenMessagesFromRabbitmqQueue
-
count number of messages in a queue `givenNumberOfMessagesInRabbitmqQueue
Create a queue on RabbitMQ
This step may seem useless, consider it as a helper to build scenarios
Parameters to provide on step
-
name: String? // optional, give a name to your step to make scenario execution more readable
-
retry: String // optional, give a chance for step to fail several times before passing
-
builder: RabbitMQQueueCreationExecutionBuilder.() → Unit // mandatory, configure execution of step
builder parameters are:-
message: QueueAndBinding // mandatory, configuration of queue to create
-
queue: String // mandatory, queue to create
-
exchange: String? // optional, if not set no binding will be created to any exchange
-
routingKey: String // optional, routing key to bind on exchange
// QueueAndBinding is built by a combination if three functions written as follows: createQueue { "world" } andBindItToExchange "universe" withRoutingKey "galaxy"
kotlin
-
-
connection: String // optional, connection string to rabbitmq, defaults to amqp://guest:guest@localhost:5672
-
vhost: String // optional, defaults to /
connection and vhost can be set globally on kest configuration file:
kest.ymlrabbitmq: connection: amqp://mylogin:mypwd@myhost:4567 vhost: /myvhost
yml
-
Delete a queue on RabbitMQ
This step may seem useless, consider it as a helper to build scenarios
Parameters to provide on step
-
name: String? // optional, give a name to your step to make scenario execution more readable
-
retry: String // optional, give a chance for step to fail several times before passing
-
builder: RabbitMQQueueDeletionExecutionBuilder.() → Unit // mandatory, configure execution of step
builder parameters are:-
queue: String // mandatory, queue to create
-
connection: String // optional, connection string to rabbitmq, defaults to amqp://guest:guest@localhost:5672
-
vhost: String // optional, defaults to /
connection and vhost can be set globally on kest configuration file:
kest.ymlrabbitmq: connection: amqp://mylogin:mypwd@myhost:4567 vhost: /myvhost
yml
-
Read one message from rabbitMQ queue
This step comes as a parameterized function, the parameterized type is the expected return type for the message to read.
Default return type is ByteArray
Parameters to provide on step
-
name: String? // optional, give a name to your step to make scenario execution more readable
-
retry: String // optional, give a chance for step to fail several times before passing
-
builder: RabbitMQMessageExecutionBuilder.() → Unit // mandatory, configure execution of step
builder parameters are:-
queue: String // queue from which read message
-
messageTransformer: String // transformer from
ByteArray
to expected return type, mandatory if other thanByteArray
-
deleteQueue: Boolean // Should queue be deleted after reading, defaults to false
-
connection: String // optional, connection string to rabbitmq, defaults to amqp://guest:guest@localhost:5672
-
vhost: String // optional, defaults to /
connection and vhost can be set globally on kest configuration file:
kest.ymlrabbitmq: connection: amqp://mylogin:mypwd@myhost:4567 vhost: /myvhost
yml
-
Sample
givenMessageFromRabbitmqQueue<String> {
queue = "kest"
messageTransformer = { toString(Charsets.UTF_8) }
}
N.B: For messages with Json format you may use toJson
function, which maps ByteArray
to a JsonMap
.
See Kest JSON documentation for more details.
Read multiple messages from rabbitMQ
This step comes as a parameterized function, the parameterized type is the expected return type for the message to read.
Default return type is ByteArray
Parameters to provide on step
-
name: String? // optional, give a name to your step to make scenario execution more readable
-
retry: String // optional, give a chance for step to fail several times before passing
-
builder: RabbitMQMessagesExecutionBuilder.() → Unit // mandatory, configure execution of step
builder parameters are:-
queue: String // queue from which read message
-
messageTransformer: String // transformer from
ByteArray
to expected return type, mandatory if other thanByteArray
-
nbMessages: Int // optional number of messages to retrieve, defaults to 1
-
deleteQueue: Boolean // Should queue be deleted after reading, defaults to false
-
connection: String // optional, connection string to rabbitmq, defaults to amqp://guest:guest@localhost:5672
-
vhost: String // optional, defaults to /
connection and vhost can be set globally on kest configuration file:
kest.ymlrabbitmq: connection: amqp://mylogin:mypwd@myhost:4567 vhost: /myvhost
yml
-
Sample
givenMessagesFromRabbitmqQueue<String> {
queue = "kest"
messageTransformer = { toString(Charsets.UTF_8) }
nbMessages = 2
}
N.B: For messages with Json format you may use toJson
function, which maps ByteArray
to a JsonMap
.
See Kest JSON documentation for more details.
Publish a message on RabbitMQ
Parameters to provide on step
-
name: String? // optional, give a name to your step to make scenario execution more readable
-
retry: String // optional, give a chance for step to fail several times before passing
-
builder: RabbitMQMessageExecutionBuilder.() → Unit // mandatory, configure execution of step
builder parameters are:-
message: RabbitMQMessage // mandatory, configuration of message to deliver
-
message: String // mandatory, message to deliver
-
exchange: String? // optional, exchange on which deliver message, defaults to ""
-
routingKey: String // mandatory, routing key for message
-
headers: Map<String, Any> // optional
-
properties: RabbitMQPublicationProperties // optional
-
contentType: String // optional
-
contentEncoding: String // optional
-
deliveryMode: Int // optional
-
priority: Int // optional
-
correlationId: String // optional
-
replyTo: String // optional
-
type: String // optional
-
messageId: String // optional
-
expiration: String // optional time in millis when message will expire
-
timestamp: Date // optional
-
userId: String // optional
-
appId: String // optional
// RabbitMQMessage may be built by a combination of functions written as follows: publish { "message_to_publish" } toExchange "target_exchange" withRoutingKey "routing_key" withHeaders mapOf( "header" to "headerValue" ) withProperties { messageId = "my id" expiration = "10000" }
kotlin
-
-
-
connection: String // optional, connection string to rabbitmq, defaults to amqp://guest:guest@localhost:5672
-
vhost: String // optional, defaults to /
connection, vhost and exchange can be set globally on kest configuration file:
kest.ymlrabbitmq: connection: amqp://mylogin:mypwd@myhost:4567 vhost: /myvhost exchange: my_exchange
yml
-
count number of messages in a queue
This step uses RabbitMQ management api, results are not instantaneous, this step should be used carefully regarding of that. |
Parameters to provide on step
-
name: String? // optional, give a name to your step to make scenario execution more readable
-
retry: String // optional, give a chance for step to fail several times before passing
-
builder: RabbitMQCountMessagesExecutionBuilder.() → Unit // mandatory, configure execution of step
builder parameters are:-
queue: String // queue from which count messages
-
connection: String // optional, connection string to rabbitmq management api, defaults to http://localhost:15672
-
user: String // optional, user to connect to management api, defaults to guest
-
password: String // optional, password to connect to management api, defaults to guest
-
vhost: String // optional, defaults to /
connection, user, password and vhost can be set globally on kest configuration file:
kest.ymlrabbitmq: managementapi: connection: http://my_host:15672 user: my_user password: my_password vhost: /myvhost
yml
-