Expose MessageProducerSpec.role(String) option

Related to: https://stackoverflow.com/questions/78294542/role-in-integrationflow-dsl

**Auto-cherry-pick to `6.2.x` & `6.1.x`**
This commit is contained in:
Artem Bilan
2024-04-08 16:17:30 -04:00
parent 43255b5e58
commit fd81adff27
2 changed files with 16 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016-2023 the original author or authors.
* Copyright 2016-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -70,6 +70,20 @@ public abstract class MessageProducerSpec<S extends MessageProducerSpec<S, P>, P
return _this();
}
/**
* Specify the role for the endpoint.
* Such endpoints can be started/stopped as a group.
* @param role the role for this endpoint.
* @return the endpoint spec
* @see org.springframework.context.SmartLifecycle
* @see org.springframework.integration.support.SmartLifecycleRoleController
* @since 6.1.8
*/
public S role(String role) {
this.target.setRole(role);
return _this();
}
/**
* Specify the {@code outputChannel} for the
* {@link org.springframework.integration.core.MessageProducer}.

View File

@@ -534,6 +534,7 @@ public class JmsTests extends ActiveMQMultiContextTests {
public IntegrationFlow jmsMessageDrivenRedeliveryFlow() {
return IntegrationFlow
.from(Jms.messageDrivenChannelAdapter(amqFactory)
.role("someRole")
.errorChannel("errorChannelForRedelivery")
.destination("jmsMessageDrivenRedelivery")
.configureListenerContainer(c -> c