The code is based on the Java tutorials, with slight modifications to make it work in SoapUI.
bin/ext
directory.You can import and run the RabbitMQ-tutorials-soapui-project.xml
in the GUI.
The project does not have any asserts; all log messages can be viewed in the "script log" tab.
You can also use the CLI runner:
$SOAPUI_HOME/bin/testrunner.sh RabbitMQ-tutorials-soapui-project.xml
.
Or you can use the provided Maven pom: ./mvnw verify
.
The code to send messages to RabbitMQ is pretty much unchanged from the Java tutorials. The biggest change is: there is no reading of the text of the message from the command line - the text of the message is included in each individual step.
There are two changes to the code to consume messages:
The program pauses for a bit to let the message get processed.
Without this, SoapUI ends the script step immediately and
kills the asynchronous process running in the background waiting
for the message. The exact pause will depend on the specific case;
it can be as simple as sleep 10000
, or little more elaborate, e.g.:
int stop = 0
while(message == null && stop++ < 20) {
log.info " [*] Waiting for messages."
sleep 500
}
At the end of each read script step, the channel and connections are closed explicitly:
channel.close()
connection.close()
Without this, some background threads are still running and would make the test hang.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。