diff --git a/spring-integration-core/src/main/java/org/springframework/integration/dsl/MessageProducerSpec.java b/spring-integration-core/src/main/java/org/springframework/integration/dsl/MessageProducerSpec.java index e01ac331d1..c08c1afd15 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/dsl/MessageProducerSpec.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/dsl/MessageProducerSpec.java @@ -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, 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}. diff --git a/spring-integration-jms/src/test/java/org/springframework/integration/jms/dsl/JmsTests.java b/spring-integration-jms/src/test/java/org/springframework/integration/jms/dsl/JmsTests.java index 19066acea2..ca919851ef 100644 --- a/spring-integration-jms/src/test/java/org/springframework/integration/jms/dsl/JmsTests.java +++ b/spring-integration-jms/src/test/java/org/springframework/integration/jms/dsl/JmsTests.java @@ -522,6 +522,7 @@ public class JmsTests extends ActiveMQMultiContextTests { public IntegrationFlow jmsMessageDrivenRedeliveryFlow() { return IntegrationFlow .from(Jms.messageDrivenChannelAdapter(amqFactory) + .role("someRole") .errorChannel("errorChannelForRedelivery") .destination("jmsMessageDrivenRedelivery") .configureListenerContainer(c -> c