Skip to content

Commit fd81adf

Browse files
committed
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`**
1 parent 43255b5 commit fd81adf

File tree

2 files changed

+16
-1
lines changed
  • spring-integration-core/src/main/java/org/springframework/integration/dsl
  • spring-integration-jms/src/test/java/org/springframework/integration/jms/dsl

2 files changed

+16
-1
lines changed

spring-integration-core/src/main/java/org/springframework/integration/dsl/MessageProducerSpec.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2016-2023 the original author or authors.
2+
* Copyright 2016-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -70,6 +70,20 @@ public S autoStartup(boolean autoStartup) {
7070
return _this();
7171
}
7272

73+
/**
74+
* Specify the role for the endpoint.
75+
* Such endpoints can be started/stopped as a group.
76+
* @param role the role for this endpoint.
77+
* @return the endpoint spec
78+
* @see org.springframework.context.SmartLifecycle
79+
* @see org.springframework.integration.support.SmartLifecycleRoleController
80+
* @since 6.1.8
81+
*/
82+
public S role(String role) {
83+
this.target.setRole(role);
84+
return _this();
85+
}
86+
7387
/**
7488
* Specify the {@code outputChannel} for the
7589
* {@link org.springframework.integration.core.MessageProducer}.

spring-integration-jms/src/test/java/org/springframework/integration/jms/dsl/JmsTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ public Message<?> preSend(Message<?> message, MessageChannel channel) {
534534
public IntegrationFlow jmsMessageDrivenRedeliveryFlow() {
535535
return IntegrationFlow
536536
.from(Jms.messageDrivenChannelAdapter(amqFactory)
537+
.role("someRole")
537538
.errorChannel("errorChannelForRedelivery")
538539
.destination("jmsMessageDrivenRedelivery")
539540
.configureListenerContainer(c -> c

0 commit comments

Comments
 (0)