use of org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler in project spring-integration by spring-projects.
the class StompInboundChannelAdapterWebSocketIntegrationTests method waitForSubscribe.
private void waitForSubscribe(String destination) throws InterruptedException {
SimpleBrokerMessageHandler serverBrokerMessageHandler = this.serverContext.getBean("simpleBrokerMessageHandler", SimpleBrokerMessageHandler.class);
SubscriptionRegistry subscriptionRegistry = serverBrokerMessageHandler.getSubscriptionRegistry();
int n = 0;
while (!containsDestination(destination, subscriptionRegistry) && n++ < 100) {
Thread.sleep(100);
}
assertTrue("The subscription for the '" + destination + "' destination hasn't been registered", n < 100);
}
use of org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler in project spring-integration by spring-projects.
the class StompInboundChannelAdapterWebSocketIntegrationTests method waitForUnsubscribe.
private void waitForUnsubscribe(String destination) throws InterruptedException {
SimpleBrokerMessageHandler serverBrokerMessageHandler = this.serverContext.getBean("simpleBrokerMessageHandler", SimpleBrokerMessageHandler.class);
SubscriptionRegistry subscriptionRegistry = serverBrokerMessageHandler.getSubscriptionRegistry();
int n = 0;
while (containsDestination(destination, subscriptionRegistry) && n++ < 100) {
Thread.sleep(100);
}
assertTrue("The subscription for the '" + destination + "' destination hasn't been registered", n < 100);
}
use of org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler in project spring-integration by spring-projects.
the class StompIntegrationTests method waitForSubscribe.
private void waitForSubscribe(String destination) throws InterruptedException {
SimpleBrokerMessageHandler serverBrokerMessageHandler = this.serverContext.getBean("simpleBrokerMessageHandler", SimpleBrokerMessageHandler.class);
SubscriptionRegistry subscriptionRegistry = serverBrokerMessageHandler.getSubscriptionRegistry();
int n = 0;
while (!containsDestination(destination, subscriptionRegistry) && n++ < 100) {
Thread.sleep(100);
}
assertTrue("The subscription for the '" + destination + "' destination hasn't been registered", n < 100);
}
use of org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler in project spring-framework by spring-projects.
the class MessageBrokerConfigurationTests method customCacheLimit.
@Test
public void customCacheLimit() {
ApplicationContext context = loadConfig(CustomConfig.class);
SimpleBrokerMessageHandler broker = context.getBean(SimpleBrokerMessageHandler.class);
DefaultSubscriptionRegistry registry = (DefaultSubscriptionRegistry) broker.getSubscriptionRegistry();
assertThat(registry.getCacheLimit()).isEqualTo(8192);
}
use of org.springframework.messaging.simp.broker.SimpleBrokerMessageHandler in project spring-framework by spring-projects.
the class MessageBrokerConfigurationTests method clientOutboundChannelUsedBySimpleBroker.
@Test
public void clientOutboundChannelUsedBySimpleBroker() {
ApplicationContext context = loadConfig(SimpleBrokerConfig.class);
TestChannel outboundChannel = context.getBean("clientOutboundChannel", TestChannel.class);
SimpleBrokerMessageHandler broker = context.getBean(SimpleBrokerMessageHandler.class);
StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SUBSCRIBE);
headers.setSessionId("sess1");
headers.setSubscriptionId("subs1");
headers.setDestination("/foo");
Message<?> message = MessageBuilder.createMessage(new byte[0], headers.getMessageHeaders());
// subscribe
broker.handleMessage(createConnectMessage("sess1", new long[] { 0, 0 }));
broker.handleMessage(message);
headers = StompHeaderAccessor.create(StompCommand.SEND);
headers.setSessionId("sess1");
headers.setDestination("/foo");
message = MessageBuilder.createMessage("bar".getBytes(), headers.getMessageHeaders());
// message
broker.handleMessage(message);
message = outboundChannel.messages.get(1);
headers = StompHeaderAccessor.wrap(message);
assertThat(headers.getMessageType()).isEqualTo(SimpMessageType.MESSAGE);
assertThat(headers.getDestination()).isEqualTo("/foo");
assertThat(new String((byte[]) message.getPayload())).isEqualTo("bar");
}
Aggregations