|
|
|
@ -42,6 +42,7 @@ import org.springframework.util.PathMatcher; |
|
|
|
* {@link SubscriptionRegistry} and sends messages to subscribers. |
|
|
|
* {@link SubscriptionRegistry} and sends messages to subscribers. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Rossen Stoyanchev |
|
|
|
* @author Rossen Stoyanchev |
|
|
|
|
|
|
|
* @author Juergen Hoeller |
|
|
|
* @since 4.0 |
|
|
|
* @since 4.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class SimpleBrokerMessageHandler extends AbstractBrokerMessageHandler { |
|
|
|
public class SimpleBrokerMessageHandler extends AbstractBrokerMessageHandler { |
|
|
|
@ -54,6 +55,8 @@ public class SimpleBrokerMessageHandler extends AbstractBrokerMessageHandler { |
|
|
|
|
|
|
|
|
|
|
|
private PathMatcher pathMatcher; |
|
|
|
private PathMatcher pathMatcher; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Integer cacheLimit; |
|
|
|
|
|
|
|
|
|
|
|
private TaskScheduler taskScheduler; |
|
|
|
private TaskScheduler taskScheduler; |
|
|
|
|
|
|
|
|
|
|
|
private long[] heartbeatValue; |
|
|
|
private long[] heartbeatValue; |
|
|
|
@ -90,14 +93,7 @@ public class SimpleBrokerMessageHandler extends AbstractBrokerMessageHandler { |
|
|
|
Assert.notNull(subscriptionRegistry, "SubscriptionRegistry must not be null"); |
|
|
|
Assert.notNull(subscriptionRegistry, "SubscriptionRegistry must not be null"); |
|
|
|
this.subscriptionRegistry = subscriptionRegistry; |
|
|
|
this.subscriptionRegistry = subscriptionRegistry; |
|
|
|
initPathMatcherToUse(); |
|
|
|
initPathMatcherToUse(); |
|
|
|
} |
|
|
|
initCacheLimitToUse(); |
|
|
|
|
|
|
|
|
|
|
|
private void initPathMatcherToUse() { |
|
|
|
|
|
|
|
if (this.pathMatcher != null) { |
|
|
|
|
|
|
|
if (this.subscriptionRegistry instanceof DefaultSubscriptionRegistry) { |
|
|
|
|
|
|
|
((DefaultSubscriptionRegistry) this.subscriptionRegistry).setPathMatcher(this.pathMatcher); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public SubscriptionRegistry getSubscriptionRegistry() { |
|
|
|
public SubscriptionRegistry getSubscriptionRegistry() { |
|
|
|
@ -105,14 +101,46 @@ public class SimpleBrokerMessageHandler extends AbstractBrokerMessageHandler { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* When configured, the given PathMatcher is passed down to the |
|
|
|
* When configured, the given PathMatcher is passed down to the underlying |
|
|
|
* SubscriptionRegistry to use for matching destination to subscriptions. |
|
|
|
* SubscriptionRegistry to use for matching destination to subscriptions. |
|
|
|
|
|
|
|
* <p>Default is a standard {@link org.springframework.util.AntPathMatcher}. |
|
|
|
|
|
|
|
* @since 4.1 |
|
|
|
|
|
|
|
* @see #setSubscriptionRegistry |
|
|
|
|
|
|
|
* @see DefaultSubscriptionRegistry#setPathMatcher |
|
|
|
|
|
|
|
* @see org.springframework.util.AntPathMatcher |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setPathMatcher(PathMatcher pathMatcher) { |
|
|
|
public void setPathMatcher(PathMatcher pathMatcher) { |
|
|
|
this.pathMatcher = pathMatcher; |
|
|
|
this.pathMatcher = pathMatcher; |
|
|
|
initPathMatcherToUse(); |
|
|
|
initPathMatcherToUse(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initPathMatcherToUse() { |
|
|
|
|
|
|
|
if (this.pathMatcher != null && this.subscriptionRegistry instanceof DefaultSubscriptionRegistry) { |
|
|
|
|
|
|
|
((DefaultSubscriptionRegistry) this.subscriptionRegistry).setPathMatcher(this.pathMatcher); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* When configured, the specified cache limit is passed down to the |
|
|
|
|
|
|
|
* underlying SubscriptionRegistry, overriding any default there. |
|
|
|
|
|
|
|
* <p>With a standard {@link DefaultSubscriptionRegistry}, the default |
|
|
|
|
|
|
|
* cache limit is 1024. |
|
|
|
|
|
|
|
* @since 4.3.2 |
|
|
|
|
|
|
|
* @see #setSubscriptionRegistry |
|
|
|
|
|
|
|
* @see DefaultSubscriptionRegistry#setCacheLimit |
|
|
|
|
|
|
|
* @see DefaultSubscriptionRegistry#DEFAULT_CACHE_LIMIT |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void setCacheLimit(Integer cacheLimit) { |
|
|
|
|
|
|
|
this.cacheLimit = cacheLimit; |
|
|
|
|
|
|
|
initCacheLimitToUse(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void initCacheLimitToUse() { |
|
|
|
|
|
|
|
if (this.cacheLimit != null && this.subscriptionRegistry instanceof DefaultSubscriptionRegistry) { |
|
|
|
|
|
|
|
((DefaultSubscriptionRegistry) this.subscriptionRegistry).setCacheLimit(this.cacheLimit); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Configure the {@link org.springframework.scheduling.TaskScheduler} to |
|
|
|
* Configure the {@link org.springframework.scheduling.TaskScheduler} to |
|
|
|
* use for providing heartbeat support. Setting this property also sets the |
|
|
|
* use for providing heartbeat support. Setting this property also sets the |
|
|
|
@ -130,6 +158,7 @@ public class SimpleBrokerMessageHandler extends AbstractBrokerMessageHandler { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return the configured TaskScheduler. |
|
|
|
* Return the configured TaskScheduler. |
|
|
|
|
|
|
|
* @since 4.2 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public TaskScheduler getTaskScheduler() { |
|
|
|
public TaskScheduler getTaskScheduler() { |
|
|
|
return this.taskScheduler; |
|
|
|
return this.taskScheduler; |
|
|
|
@ -151,6 +180,7 @@ public class SimpleBrokerMessageHandler extends AbstractBrokerMessageHandler { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* The configured value for the heart-beat settings. |
|
|
|
* The configured value for the heart-beat settings. |
|
|
|
|
|
|
|
* @since 4.2 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public long[] getHeartbeatValue() { |
|
|
|
public long[] getHeartbeatValue() { |
|
|
|
return this.heartbeatValue; |
|
|
|
return this.heartbeatValue; |
|
|
|
@ -160,6 +190,7 @@ public class SimpleBrokerMessageHandler extends AbstractBrokerMessageHandler { |
|
|
|
* Configure a {@link MessageHeaderInitializer} to apply to the headers |
|
|
|
* Configure a {@link MessageHeaderInitializer} to apply to the headers |
|
|
|
* of all messages sent to the client outbound channel. |
|
|
|
* of all messages sent to the client outbound channel. |
|
|
|
* <p>By default this property is not set. |
|
|
|
* <p>By default this property is not set. |
|
|
|
|
|
|
|
* @since 4.1 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setHeaderInitializer(MessageHeaderInitializer headerInitializer) { |
|
|
|
public void setHeaderInitializer(MessageHeaderInitializer headerInitializer) { |
|
|
|
this.headerInitializer = headerInitializer; |
|
|
|
this.headerInitializer = headerInitializer; |
|
|
|
@ -167,6 +198,7 @@ public class SimpleBrokerMessageHandler extends AbstractBrokerMessageHandler { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Return the configured header initializer. |
|
|
|
* Return the configured header initializer. |
|
|
|
|
|
|
|
* @since 4.1 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public MessageHeaderInitializer getHeaderInitializer() { |
|
|
|
public MessageHeaderInitializer getHeaderInitializer() { |
|
|
|
return this.headerInitializer; |
|
|
|
return this.headerInitializer; |
|
|
|
|