Servicebus
Send and receive messages on Azure Service Bus queues and topics.
Note
If message.wait
is not set, azure.servicebus
will wait until there is a message available, and hence block the scenario.
Attention
Do not use expression
to filter messages unless you do not care about the messages that does not match the expression. If
you do care about them, you should setup a subscription to do the filtering in Azure.
User is based on azure.servicebus
for communicating with Azure Service Bus. But creating a connection and session towards a queue or a topic
is a costly operation, and caching of the session was causing problems with gevent
due to the sockets blocking and hence grizzly was
blocking when finished. To get around this, the user implementation communicates with a stand-alone process via zmq
, which in turn communicates
with Azure Service Bus.
async-messaged
starts automagically when a scenario uses the ServiceBusUser
.
Request methods
Supports the following request methods:
- send
- receive
Format
Format of host
is the following, when using connection strings:
[Endpoint=]sb://<hostname>/;SharedAccessKeyName=<shared key name>;SharedAccessKey=<shared key>
When using credentials context variables auth.tenant
, auth.user.username
and auth.user.password
has to be set, and the format of host
should be:
sb://<qualified namespace>[.servicebus.windows.net]
endpoint
in the request must have the prefix queue:
or topic:
followed by the name of the targeted
type. When receiving messages from a topic, the argument subscription:
is mandatory. The format of endpoint is:
[queue|topic]:<endpoint name>[, subscription:<subscription name>][, expression:<expression>]
Where <expression>
can be a XPath or jsonpath expression, depending on the specified content type. This argument is only allowed when
receiving messages. See example below.
Examples
Example of how to use it in a scenario:
Given a user of type "ServiceBus" load testing "sb://sb.example.com/;SharedAccessKeyName=authorization-key;SharedAccessKey=c2VjcmV0LXN0dWZm"
And set context variable "message.wait" to "5"
Then send request "queue-send" to endpoint "queue:shared-queue"
Then send request "topic-send" to endpoint "topic:shared-topic"
Then receive request "queue-recv" from endpoint "queue:shared-queue"
Then receive request "topic-recv" from endpoint "topic:shared-topic, subscription:my-subscription"
Get message with expression
When specifying an expression, the messages on the endpoint is first peeked on. If any message matches the expression, it is later consumed from the
endpoint. If no matching messages was found when peeking, it is repeated again after a slight delay, up until the specified message.wait
seconds has
elapsed. To use expressions, a content type must be specified for the request, e.g. application/xml
.
Given a user of type "ServiceBus" load testing "sb://my-sbns"
And set context variable "message.wait" to "5"
And set context variable "auth.tenant" to "example.com"
And set context variable "auth.user.username" to "bob@example.com"
And set context variable "auth.user.password" to "secret"
Then receive request "queue-recv" from endpoint "queue:shared-queue, expression:$.document[?(@.name=='TPM report')].id"
And set response content type to "application/json"
Then receive request "topic-recv" from endpoint "topic:shared-topic, subscription:my-subscription, expression:/documents/document[@name='TPM Report']/id/text()"
And set response content type to "application/xml"