|
|
@ -43,14 +43,14 @@ public class MessageBrokerRegistry { |
|
|
|
|
|
|
|
|
|
|
|
private StompBrokerRelayRegistration brokerRelayRegistration; |
|
|
|
private StompBrokerRelayRegistration brokerRelayRegistration; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final ChannelRegistration brokerChannelRegistration = new ChannelRegistration(); |
|
|
|
|
|
|
|
|
|
|
|
private String[] applicationDestinationPrefixes; |
|
|
|
private String[] applicationDestinationPrefixes; |
|
|
|
|
|
|
|
|
|
|
|
private String userDestinationPrefix; |
|
|
|
private String userDestinationPrefix; |
|
|
|
|
|
|
|
|
|
|
|
private PathMatcher pathMatcher; |
|
|
|
private PathMatcher pathMatcher; |
|
|
|
|
|
|
|
|
|
|
|
private ChannelRegistration brokerChannelRegistration = new ChannelRegistration(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MessageBrokerRegistry(SubscribableChannel clientInboundChannel, MessageChannel clientOutboundChannel) { |
|
|
|
public MessageBrokerRegistry(SubscribableChannel clientInboundChannel, MessageChannel clientOutboundChannel) { |
|
|
|
Assert.notNull(clientInboundChannel); |
|
|
|
Assert.notNull(clientInboundChannel); |
|
|
@ -59,6 +59,7 @@ public class MessageBrokerRegistry { |
|
|
|
this.clientOutboundChannel = clientOutboundChannel; |
|
|
|
this.clientOutboundChannel = clientOutboundChannel; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Enable a simple message broker and configure one or more prefixes to filter |
|
|
|
* Enable a simple message broker and configure one or more prefixes to filter |
|
|
|
* destinations targeting the broker (e.g. destinations prefixed with "/topic"). |
|
|
|
* destinations targeting the broker (e.g. destinations prefixed with "/topic"). |
|
|
@ -80,6 +81,21 @@ public class MessageBrokerRegistry { |
|
|
|
return this.brokerRelayRegistration; |
|
|
|
return this.brokerRelayRegistration; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Customize the channel used to send messages from the application to the message |
|
|
|
|
|
|
|
* broker. By default, messages from the application to the message broker are sent |
|
|
|
|
|
|
|
* synchronously, which means application code sending a message will find out |
|
|
|
|
|
|
|
* if the message cannot be sent through an exception. However, this can be changed |
|
|
|
|
|
|
|
* if the broker channel is configured here with task executor properties. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public ChannelRegistration configureBrokerChannel() { |
|
|
|
|
|
|
|
return this.brokerChannelRegistration; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected ChannelRegistration getBrokerChannelRegistration() { |
|
|
|
|
|
|
|
return this.brokerChannelRegistration; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Configure one or more prefixes to filter destinations targeting application |
|
|
|
* Configure one or more prefixes to filter destinations targeting application |
|
|
|
* annotated methods. For example destinations prefixed with "/app" may be |
|
|
|
* annotated methods. For example destinations prefixed with "/app" may be |
|
|
@ -95,6 +111,11 @@ public class MessageBrokerRegistry { |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected Collection<String> getApplicationDestinationPrefixes() { |
|
|
|
|
|
|
|
return (this.applicationDestinationPrefixes != null ? |
|
|
|
|
|
|
|
Arrays.asList(this.applicationDestinationPrefixes) : null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Configure the prefix used to identify user destinations. User destinations |
|
|
|
* Configure the prefix used to identify user destinations. User destinations |
|
|
|
* provide the ability for a user to subscribe to queue names unique to their |
|
|
|
* provide the ability for a user to subscribe to queue names unique to their |
|
|
@ -112,24 +133,24 @@ public class MessageBrokerRegistry { |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected String getUserDestinationPrefix() { |
|
|
|
|
|
|
|
return this.userDestinationPrefix; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Configure the PathMatcher to use to match the destinations of incoming |
|
|
|
* Configure the PathMatcher to use to match the destinations of incoming |
|
|
|
* messages to {@code @MessageMapping} and {@code @SubscribeMapping} methods. |
|
|
|
* messages to {@code @MessageMapping} and {@code @SubscribeMapping} methods. |
|
|
|
* |
|
|
|
|
|
|
|
* <p>By default {@link org.springframework.util.AntPathMatcher} is configured. |
|
|
|
* <p>By default {@link org.springframework.util.AntPathMatcher} is configured. |
|
|
|
* However applications may provide an {@code AntPathMatcher} instance |
|
|
|
* However applications may provide an {@code AntPathMatcher} instance |
|
|
|
* customized to use "." (commonly used in messaging) instead of "/" as path |
|
|
|
* customized to use "." (commonly used in messaging) instead of "/" as path |
|
|
|
* separator or provide a completely different PathMatcher implementation. |
|
|
|
* separator or provide a completely different PathMatcher implementation. |
|
|
|
* |
|
|
|
|
|
|
|
* <p>Note that the configured PathMatcher is only used for matching the |
|
|
|
* <p>Note that the configured PathMatcher is only used for matching the |
|
|
|
* portion of the destination after the configured prefix. For example given |
|
|
|
* portion of the destination after the configured prefix. For example given |
|
|
|
* application destination prefix "/app" and destination "/app/price.stock.**", |
|
|
|
* application destination prefix "/app" and destination "/app/price.stock.**", |
|
|
|
* the message might be mapped to a controller with "price" and "stock.**" |
|
|
|
* the message might be mapped to a controller with "price" and "stock.**" |
|
|
|
* as its type and method-level mappings respectively. |
|
|
|
* as its type and method-level mappings respectively. |
|
|
|
* |
|
|
|
|
|
|
|
* <p>When the simple broker is enabled, the PathMatcher configured here is |
|
|
|
* <p>When the simple broker is enabled, the PathMatcher configured here is |
|
|
|
* also used to match message destinations when brokering messages. |
|
|
|
* also used to match message destinations when brokering messages. |
|
|
|
* |
|
|
|
|
|
|
|
* @since 4.1 |
|
|
|
* @since 4.1 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public MessageBrokerRegistry setPathMatcher(PathMatcher pathMatcher) { |
|
|
|
public MessageBrokerRegistry setPathMatcher(PathMatcher pathMatcher) { |
|
|
@ -137,19 +158,13 @@ public class MessageBrokerRegistry { |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
protected PathMatcher getPathMatcher() { |
|
|
|
* Customize the channel used to send messages from the application to the message |
|
|
|
return this.pathMatcher; |
|
|
|
* broker. By default messages from the application to the message broker are sent |
|
|
|
|
|
|
|
* synchronously, which means application code sending a message will find out |
|
|
|
|
|
|
|
* if the message cannot be sent through an exception. However, this can be changed |
|
|
|
|
|
|
|
* if the broker channel is configured here with task executor properties. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public ChannelRegistration configureBrokerChannel() { |
|
|
|
|
|
|
|
return this.brokerChannelRegistration; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected SimpleBrokerMessageHandler getSimpleBroker(SubscribableChannel brokerChannel) { |
|
|
|
protected SimpleBrokerMessageHandler getSimpleBroker(SubscribableChannel brokerChannel) { |
|
|
|
if ((this.simpleBrokerRegistration == null) && (this.brokerRelayRegistration == null)) { |
|
|
|
if (this.simpleBrokerRegistration == null && this.brokerRelayRegistration == null) { |
|
|
|
enableSimpleBroker(); |
|
|
|
enableSimpleBroker(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (this.simpleBrokerRegistration != null) { |
|
|
|
if (this.simpleBrokerRegistration != null) { |
|
|
@ -167,21 +182,4 @@ public class MessageBrokerRegistry { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected Collection<String> getApplicationDestinationPrefixes() { |
|
|
|
|
|
|
|
return (this.applicationDestinationPrefixes != null) |
|
|
|
|
|
|
|
? Arrays.asList(this.applicationDestinationPrefixes) : null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected String getUserDestinationPrefix() { |
|
|
|
|
|
|
|
return this.userDestinationPrefix; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected PathMatcher getPathMatcher() { |
|
|
|
|
|
|
|
return this.pathMatcher; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected ChannelRegistration getBrokerChannelRegistration() { |
|
|
|
|
|
|
|
return this.brokerChannelRegistration; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|