我想阻止用户使用springm流绑定创建队列,同时点击终结点/ prepare-for-shutdown。请在下面的配置中找到,
在pom.xml中添加了依赖项
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
</dependency>
Application.yml:
spring:
cloud:
stream:
bindings:
produceChannel:
binder: rabbit
content-type: application/json
destination: internal-exchange
consumeChannel:
binder: rabbit
content-type: application/json
destination: internal-exchange
group: small-queue
rabbit:
bindings:
consumeChannel:
consumer:
autoBindDlq: true
durableSubscription: true
requeueRejected: false
republishToDlq: true
bindingRoutingKey: admin
produceChannel:
producer:
routingKeyExpression: '"admin"'
sample.java
import org.springframework.cloud.stream.annotation.Input;
import org.springframework.messaging.SubscribableChannel;
public interface Sample{
@Input("consumeChannel")
SubscribableChannel consumeChannel();
@Output("produceChannel")
SubscribableChannel produceChannel();
}
[使用Spring Cloud的@StreamLinster和@EnableBinding抽象实现了与RabbitMQ的集成,如下所示:
@EnableBinding(Sample.class)
@StreamListener("consumeChannel")
public void sampleMessage(String message) {
// code
}
期待以编程方式停止RabbitMQ队列的使用者。在此先感谢
我分析了为什么通过调用执行器端点'/ actuator / bindings'获得空值的问题
当击中执行器绑定端点时,它将调用BindingsEndpoint.class中的方法collectInputBindings()。
在BindingsEndpoint.java中,从inputBindingLifecycle获取绑定值
(Collection<Binding<?>>) new DirectFieldAccessor(inputBindingLifecycle).getPropertyValue("inputBindings");
在下面的方法中,将空绑定列表设置为inputBindings
在InputBindingLifecycle.java中,
void doStartWithBindable(Bindable bindable) {
this.inputBindings = bindable.createAndBindInputs(bindingService);
}
在Bindable.java中,
default Collection<Binding<Object>> createAndBindInputs(BindingService adapter) {
return Collections.<Binding<Object>>emptyList();
}
请建议我解决这些问题,无论是否需要更改任何依赖项或任何代码配置