Set virtualHost on StompBrokerRelayRegistration

Prior to this commit, one couldn't set the virtualHost property on
StompBrokerRelayMessageHandler via JavaConfig, since
StompBrokerRelayRegistration's API didn't offer that possibility.

This commit adds a new method in StompBrokerRelayRegistration's fluent
API to set the virtualHost used by StompBrokerRelayMessageHandler.
Note: this property is already configurable via xml config.

Issue: SPR-11433
This commit is contained in:
Brian Clozel
2014-02-17 14:49:48 +01:00
parent bde4964af5
commit 1dedb67fbc
2 changed files with 20 additions and 0 deletions

View File

@@ -45,6 +45,8 @@ public class StompBrokerRelayRegistration extends AbstractBrokerRegistration {
private Long systemHeartbeatReceiveInterval;
private String virtualHost;
private boolean autoStartup = true;
@@ -146,6 +148,19 @@ public class StompBrokerRelayRegistration extends AbstractBrokerRegistration {
return this;
}
/**
* Set the value of the "host" header to use in STOMP CONNECT frames. When this
* property is configured, a "host" header will be added to every STOMP frame sent to
* the STOMP broker. This may be useful for example in a cloud environment where the
* actual host to which the TCP connection is established is different from the host
* providing the cloud-based STOMP service.
* <p>By default this property is not set.
*/
public StompBrokerRelayRegistration setVirtualHost(String virtualHost) {
this.virtualHost = virtualHost;
return this;
}
/**
* Configure whether the {@link StompBrokerRelayMessageHandler} should start
* automatically when the Spring ApplicationContext is refreshed.
@@ -177,6 +192,9 @@ public class StompBrokerRelayRegistration extends AbstractBrokerRegistration {
if (this.systemHeartbeatReceiveInterval != null) {
handler.setSystemHeartbeatReceiveInterval(this.systemHeartbeatReceiveInterval);
}
if(this.virtualHost != null) {
handler.setVirtualHost(this.virtualHost);
}
handler.setAutoStartup(this.autoStartup);