Skip to content

Commit 179b236

Browse files
committed
Add MessageHandlingRunnable
Issue: SPR-12272
1 parent 84137ab commit 179b236

File tree

3 files changed

+68
-1
lines changed

3 files changed

+68
-1
lines changed

spring-messaging/src/main/java/org/springframework/messaging/support/ExecutorSubscribableChannel.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public boolean sendInternal(Message<?> message, long timeout) {
101101
/**
102102
* Invoke a MessageHandler with ExecutorChannelInterceptor's.
103103
*/
104-
private class SendTask implements Runnable {
104+
private class SendTask implements MessageHandlingRunnable {
105105

106106
private final Message<?> inputMessage;
107107

@@ -115,6 +115,17 @@ public SendTask(Message<?> message, MessageHandler handler) {
115115
this.handler = handler;
116116
}
117117

118+
119+
@Override
120+
public Message<?> getMessage() {
121+
return this.inputMessage;
122+
}
123+
124+
@Override
125+
public MessageHandler getMessageHandler() {
126+
return this.getMessageHandler();
127+
}
128+
118129
@Override
119130
public void run() {
120131
Message<?> message = this.inputMessage;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package org.springframework.messaging.support;
2+
3+
import org.springframework.messaging.Message;
4+
import org.springframework.messaging.MessageHandler;
5+
6+
/**
7+
* Extension of the Runnable interface with methods to obtain the MessageHandler
8+
* and Message to be handled.
9+
*
10+
* @author Rossen Stoyanchev
11+
* @since 4.1
12+
*/
13+
public interface MessageHandlingRunnable extends Runnable {
14+
15+
/**
16+
* Return the Message that will be handled.
17+
*/
18+
Message<?> getMessage();
19+
20+
/**
21+
* Return the MessageHandler that will be used to handle the message.
22+
*/
23+
MessageHandler getMessageHandler();
24+
25+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2002-2014 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.messaging.support;
18+
19+
/**
20+
* @author Rossen Stoyanchev
21+
* @since 4.1
22+
*/
23+
public class Test {
24+
25+
public static void main(String[] args) {
26+
27+
ExecutorSubscribableChannel.ExecutorSubscribableChannelTask task = null;
28+
29+
}
30+
31+
}

0 commit comments

Comments
 (0)