问题
I'm using qpid-broker
for integration testing my spring-boot-start-amqp
application which uses basicGet
(autoAck=false), basicAck
and basicReject
for handling the messages. basicReject
(with requeue=false) works fine with my external rabbitmq
instance but doesn't work with the qpid-broker
.
I have tested my code with an external RabbitMQ instance where everything works fine but with the embedded Apache Qpid server the test fails because basicReject
is not working properly.
Getting the message and rejecting it:
rabbitTemplate.execute {
val response = it.basicGet(config.queueName, false)
it.basicReject(response.envelope.deliveryTag, false)
}
Check if the message is still in the queue:
rabbitTemplate.execute {
val response = it.basicGet(config.queueName, false)
Assertions.assertThat(response).isNull()
}
My Qpid config:
{
"name": "EmbeddedBroker",
"modelVersion": "7.0",
"authenticationproviders": [
{
"name": "password",
"type": "Plain",
"secureOnlyMechanisms": [],
"users": [
{
"name": "guest",
"password": "guest",
"type": "managed"
}
]
}
],
"ports": [
{
"name": "AMQP",
"port": "${qpid.amqp_port}",
"protocols": [ "AMQP_0_9_1" ],
"authenticationProvider": "password",
"virtualhostaliases": [
{
"name": "defaultAlias",
"type": "defaultAlias"
}
]
}
],
"virtualhostnodes": [
{
"name": "default",
"defaultVirtualHostNode": "true",
"type": "Memory",
"virtualHostInitialConfiguration": "{\"type\": \"Memory\" }"
}
]
}
Why does basicReject
work fine with my RabbitMQ instance but doesn't work properly with the Apache Qpid embedded broker?
Edit: My solution was to move away from qpid and use a RabbitMQ Testcontainer.
来源:https://stackoverflow.com/questions/57873395/why-does-basicreject-does-not-work-with-apache-qpid