Skip to content

Commit

Permalink
Web Socket configuration now works with CF
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornharvold committed Feb 8, 2015
1 parent 0462077 commit e522dbd
Show file tree
Hide file tree
Showing 8 changed files with 228 additions and 99 deletions.
277 changes: 185 additions & 92 deletions .idea/workspace.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<output url="file://$MODULE_DIR$/../target/classes" />
<output-test url="file://$MODULE_DIR$/../target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
Expand Down
4 changes: 2 additions & 2 deletions bearchoke-backend/bearchoke-platform-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@
</dependency>
<dependency>
<groupId>stax</groupId>
<artifactId>stax-ri</artifactId>
<version>1.0</version>
<artifactId>stax-api</artifactId>
<version>1.0.1</version>
</dependency>
<dependency>
<groupId>com.cenqua.clover</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.context.annotation.PropertySource;

@Configuration
@Profile("rabbit-cloud")
@PropertySource(value = "classpath:rabbit-cloud.properties")
@Slf4j
public class RabbitMQCloudConfig extends AbstractCloudConfig {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Copyright 2014 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

rabbitmq.host=tiger.cloudamqp.com
rabbitmq.username=uetwdtmj
rabbitmq.password=6pKR5W2qQ9UXM9M5LIrG1jMTPF9HDU99
rabbitmq.virtualhost=uetwdtmj
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
rabbitmq.host=localhost
rabbitmq.port=5672
rabbitmq.username=guest
rabbitmq.password=guest
rabbitmq.password=guest
rabbitmq.virtualhost=/
2 changes: 1 addition & 1 deletion bearchoke-backend/bearchoke-server/manifest.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
applications:
- name: bearchoke-server
memory: 1G
memory: 2G
instances: 1
host: bearchoke-server
path: target/bearchoke-server-0.0.1-SNAPSHOT.war
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.http.HttpHeaders;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
Expand All @@ -38,6 +39,7 @@
import org.springframework.messaging.simp.SimpMessageSendingOperations;
import org.springframework.messaging.simp.config.ChannelRegistration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.messaging.simp.config.StompBrokerRelayRegistration;
import org.springframework.messaging.simp.stomp.StompCommand;
import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
import org.springframework.messaging.support.ChannelInterceptorAdapter;
Expand Down Expand Up @@ -70,6 +72,9 @@
@Slf4j
public class WebSocketConfig<S extends ExpiringSession> extends AbstractSessionWebSocketMessageBrokerConfigurer<S> {

@Inject
private Environment environment;

@Inject
private CustomObjectMapper objectMapper;

Expand Down Expand Up @@ -115,7 +120,15 @@ public boolean configureMessageConverters(List<MessageConverter> converters) {
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.setApplicationDestinationPrefixes("/app");
config.enableStompBrokerRelay("/queue/", "/topic/");

StompBrokerRelayRegistration stompBrokerRelayRegistration = config.enableStompBrokerRelay("/queue/", "/topic/");

stompBrokerRelayRegistration.setRelayHost(environment.getProperty("rabbitmq.host"));
stompBrokerRelayRegistration.setVirtualHost(environment.getProperty("rabbitmq.virtualhost"));
stompBrokerRelayRegistration.setClientLogin(environment.getProperty("rabbitmq.username"));
stompBrokerRelayRegistration.setSystemLogin(environment.getProperty("rabbitmq.username"));
stompBrokerRelayRegistration.setClientPasscode(environment.getProperty("rabbitmq.password"));
stompBrokerRelayRegistration.setSystemPasscode(environment.getProperty("rabbitmq.password"));

// only if we want to use . instead of / for path separator e.g. /app/user.chat
// config.setPathMatcher(new AntPathMatcher("."));
Expand Down

0 comments on commit e522dbd

Please sign in to comment.