org.springframework.messaging.simp.user.UserDestinationMessageHandler Java Examples
The following examples show how to use
org.springframework.messaging.simp.user.UserDestinationMessageHandler.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MessageBrokerConfigurationTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void userBroadcasts() { ApplicationContext context = loadConfig(BrokerRelayConfig.class); SimpUserRegistry userRegistry = context.getBean(SimpUserRegistry.class); assertEquals(MultiServerUserRegistry.class, userRegistry.getClass()); UserDestinationMessageHandler handler1 = context.getBean(UserDestinationMessageHandler.class); assertEquals("/topic/unresolved-user-destination", handler1.getBroadcastDestination()); UserRegistryMessageHandler handler2 = context.getBean(UserRegistryMessageHandler.class); assertEquals("/topic/simp-user-registry", handler2.getBroadcastDestination()); StompBrokerRelayMessageHandler relay = context.getBean(StompBrokerRelayMessageHandler.class); assertNotNull(relay.getSystemSubscriptions()); assertEquals(2, relay.getSystemSubscriptions().size()); assertSame(handler1, relay.getSystemSubscriptions().get("/topic/unresolved-user-destination")); assertSame(handler2, relay.getSystemSubscriptions().get("/topic/simp-user-registry")); }
Example #2
Source File: MessageBrokerBeanDefinitionParserTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void customChannels() { loadBeanDefinitions("websocket-config-broker-customchannels.xml"); List<Class<? extends MessageHandler>> subscriberTypes = Arrays.<Class<? extends MessageHandler>>asList(SimpAnnotationMethodMessageHandler.class, UserDestinationMessageHandler.class, SimpleBrokerMessageHandler.class); testChannel("clientInboundChannel", subscriberTypes, 3); testExecutor("clientInboundChannel", 100, 200, 600); subscriberTypes = Collections.singletonList(SubProtocolWebSocketHandler.class); testChannel("clientOutboundChannel", subscriberTypes, 3); testExecutor("clientOutboundChannel", 101, 201, 601); subscriberTypes = Arrays.<Class<? extends MessageHandler>>asList(SimpleBrokerMessageHandler.class, UserDestinationMessageHandler.class); testChannel("brokerChannel", subscriberTypes, 1); testExecutor("brokerChannel", 102, 202, 602); }
Example #3
Source File: MessageBrokerBeanDefinitionParser.java From spring4-understanding with Apache License 2.0 | 6 votes |
private RuntimeBeanReference registerUserDestHandler(Element brokerElem, RuntimeBeanReference userRegistry, RuntimeBeanReference inChannel, RuntimeBeanReference brokerChannel, ParserContext context, Object source) { Object userDestResolver = registerUserDestResolver(brokerElem, userRegistry, context, source); RootBeanDefinition beanDef = new RootBeanDefinition(UserDestinationMessageHandler.class); beanDef.getConstructorArgumentValues().addIndexedArgumentValue(0, inChannel); beanDef.getConstructorArgumentValues().addIndexedArgumentValue(1, brokerChannel); beanDef.getConstructorArgumentValues().addIndexedArgumentValue(2, userDestResolver); Element relayElement = DomUtils.getChildElementByTagName(brokerElem, "stomp-broker-relay"); if (relayElement != null && relayElement.hasAttribute("user-destination-broadcast")) { String destination = relayElement.getAttribute("user-destination-broadcast"); beanDef.getPropertyValues().add("broadcastDestination", destination); } String beanName = registerBeanDef(beanDef, context, source); return new RuntimeBeanReference(beanName); }
Example #4
Source File: MessageBrokerConfigurationTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void userBroadcasts() throws Exception { SimpUserRegistry userRegistry = this.brokerRelayContext.getBean(SimpUserRegistry.class); assertEquals(MultiServerUserRegistry.class, userRegistry.getClass()); UserDestinationMessageHandler handler1 = this.brokerRelayContext.getBean(UserDestinationMessageHandler.class); assertEquals("/topic/unresolved-user-destination", handler1.getBroadcastDestination()); UserRegistryMessageHandler handler2 = this.brokerRelayContext.getBean(UserRegistryMessageHandler.class); assertEquals("/topic/simp-user-registry", handler2.getBroadcastDestination()); StompBrokerRelayMessageHandler relay = this.brokerRelayContext.getBean(StompBrokerRelayMessageHandler.class); assertNotNull(relay.getSystemSubscriptions()); assertEquals(2, relay.getSystemSubscriptions().size()); assertSame(handler1, relay.getSystemSubscriptions().get("/topic/unresolved-user-destination")); assertSame(handler2, relay.getSystemSubscriptions().get("/topic/simp-user-registry")); }
Example #5
Source File: MessageBrokerBeanDefinitionParser.java From java-technology-stack with MIT License | 6 votes |
private RuntimeBeanReference registerUserDestHandler(Element brokerElem, RuntimeBeanReference userRegistry, RuntimeBeanReference inChannel, RuntimeBeanReference brokerChannel, ParserContext context, @Nullable Object source) { Object userDestResolver = registerUserDestResolver(brokerElem, userRegistry, context, source); RootBeanDefinition beanDef = new RootBeanDefinition(UserDestinationMessageHandler.class); beanDef.getConstructorArgumentValues().addIndexedArgumentValue(0, inChannel); beanDef.getConstructorArgumentValues().addIndexedArgumentValue(1, brokerChannel); beanDef.getConstructorArgumentValues().addIndexedArgumentValue(2, userDestResolver); Element relayElement = DomUtils.getChildElementByTagName(brokerElem, "stomp-broker-relay"); if (relayElement != null && relayElement.hasAttribute("user-destination-broadcast")) { String destination = relayElement.getAttribute("user-destination-broadcast"); beanDef.getPropertyValues().add("broadcastDestination", destination); } String beanName = registerBeanDef(beanDef, context, source); return new RuntimeBeanReference(beanName); }
Example #6
Source File: MessageBrokerBeanDefinitionParser.java From spring-analysis-note with MIT License | 6 votes |
private RuntimeBeanReference registerUserDestHandler(Element brokerElem, RuntimeBeanReference userRegistry, RuntimeBeanReference inChannel, RuntimeBeanReference brokerChannel, ParserContext context, @Nullable Object source) { Object userDestResolver = registerUserDestResolver(brokerElem, userRegistry, context, source); RootBeanDefinition beanDef = new RootBeanDefinition(UserDestinationMessageHandler.class); beanDef.getConstructorArgumentValues().addIndexedArgumentValue(0, inChannel); beanDef.getConstructorArgumentValues().addIndexedArgumentValue(1, brokerChannel); beanDef.getConstructorArgumentValues().addIndexedArgumentValue(2, userDestResolver); Element relayElement = DomUtils.getChildElementByTagName(brokerElem, "stomp-broker-relay"); if (relayElement != null && relayElement.hasAttribute("user-destination-broadcast")) { String destination = relayElement.getAttribute("user-destination-broadcast"); beanDef.getPropertyValues().add("broadcastDestination", destination); } String beanName = registerBeanDef(beanDef, context, source); return new RuntimeBeanReference(beanName); }
Example #7
Source File: MessageBrokerConfigurationTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void userBroadcasts() { ApplicationContext context = loadConfig(BrokerRelayConfig.class); SimpUserRegistry userRegistry = context.getBean(SimpUserRegistry.class); assertEquals(MultiServerUserRegistry.class, userRegistry.getClass()); UserDestinationMessageHandler handler1 = context.getBean(UserDestinationMessageHandler.class); assertEquals("/topic/unresolved-user-destination", handler1.getBroadcastDestination()); UserRegistryMessageHandler handler2 = context.getBean(UserRegistryMessageHandler.class); assertEquals("/topic/simp-user-registry", handler2.getBroadcastDestination()); StompBrokerRelayMessageHandler relay = context.getBean(StompBrokerRelayMessageHandler.class); assertNotNull(relay.getSystemSubscriptions()); assertEquals(2, relay.getSystemSubscriptions().size()); assertSame(handler1, relay.getSystemSubscriptions().get("/topic/unresolved-user-destination")); assertSame(handler2, relay.getSystemSubscriptions().get("/topic/simp-user-registry")); }
Example #8
Source File: MessageBrokerConfigurationTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void clientInboundChannel() { ApplicationContext context = loadConfig(SimpleBrokerConfig.class); TestChannel channel = context.getBean("clientInboundChannel", TestChannel.class); Set<MessageHandler> handlers = channel.getSubscribers(); assertEquals(3, handlers.size()); assertTrue(handlers.contains(context.getBean(SimpAnnotationMethodMessageHandler.class))); assertTrue(handlers.contains(context.getBean(UserDestinationMessageHandler.class))); assertTrue(handlers.contains(context.getBean(SimpleBrokerMessageHandler.class))); }
Example #9
Source File: MessageBrokerConfigurationTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void userBroadcastsDisabledWithSimpleBroker() { ApplicationContext context = loadConfig(SimpleBrokerConfig.class); SimpUserRegistry registry = context.getBean(SimpUserRegistry.class); assertNotNull(registry); assertNotEquals(MultiServerUserRegistry.class, registry.getClass()); UserDestinationMessageHandler handler = context.getBean(UserDestinationMessageHandler.class); assertNull(handler.getBroadcastDestination()); Object nullBean = context.getBean("userRegistryMessageHandler"); assertTrue(nullBean.equals(null)); }
Example #10
Source File: WebSocketMessageBrokerConfigurationSupportTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void brokerChannel() { ApplicationContext config = createConfig(TestChannelConfig.class, TestConfigurer.class); TestChannel channel = config.getBean("brokerChannel", TestChannel.class); Set<MessageHandler> handlers = channel.getSubscribers(); List<ChannelInterceptor> interceptors = channel.getInterceptors(); assertEquals(ImmutableMessageChannelInterceptor.class, interceptors.get(interceptors.size()-1).getClass()); assertEquals(2, handlers.size()); assertTrue(handlers.contains(config.getBean(SimpleBrokerMessageHandler.class))); assertTrue(handlers.contains(config.getBean(UserDestinationMessageHandler.class))); }
Example #11
Source File: MessageBrokerConfigurationTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void clientInboundChannelWithBrokerRelay() { ApplicationContext context = loadConfig(BrokerRelayConfig.class); TestChannel channel = context.getBean("clientInboundChannel", TestChannel.class); Set<MessageHandler> handlers = channel.getSubscribers(); assertEquals(3, handlers.size()); assertTrue(handlers.contains(context.getBean(SimpAnnotationMethodMessageHandler.class))); assertTrue(handlers.contains(context.getBean(UserDestinationMessageHandler.class))); assertTrue(handlers.contains(context.getBean(StompBrokerRelayMessageHandler.class))); }
Example #12
Source File: MessageBrokerConfigurationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void userBroadcastsDisabledWithSimpleBroker() throws Exception { SimpUserRegistry registry = this.simpleBrokerContext.getBean(SimpUserRegistry.class); assertNotNull(registry); assertNotEquals(MultiServerUserRegistry.class, registry.getClass()); UserDestinationMessageHandler handler = this.simpleBrokerContext.getBean(UserDestinationMessageHandler.class); assertNull(handler.getBroadcastDestination()); String name = "userRegistryMessageHandler"; MessageHandler messageHandler = this.simpleBrokerContext.getBean(name, MessageHandler.class); assertNotEquals(UserRegistryMessageHandler.class, messageHandler.getClass()); }
Example #13
Source File: MessageBrokerConfigurationTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void brokerChannel() { ApplicationContext context = loadConfig(SimpleBrokerConfig.class); TestChannel channel = context.getBean("brokerChannel", TestChannel.class); Set<MessageHandler> handlers = channel.getSubscribers(); assertEquals(2, handlers.size()); assertTrue(handlers.contains(context.getBean(UserDestinationMessageHandler.class))); assertTrue(handlers.contains(context.getBean(SimpleBrokerMessageHandler.class))); assertNull(channel.getExecutor()); }
Example #14
Source File: MessageBrokerConfigurationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void brokerChannelWithBrokerRelay() { TestChannel channel = this.brokerRelayContext.getBean("brokerChannel", TestChannel.class); Set<MessageHandler> handlers = channel.getSubscribers(); assertEquals(2, handlers.size()); assertTrue(handlers.contains(brokerRelayContext.getBean(UserDestinationMessageHandler.class))); assertTrue(handlers.contains(brokerRelayContext.getBean(StompBrokerRelayMessageHandler.class))); }
Example #15
Source File: MessageBrokerConfigurationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void brokerChannel() { TestChannel channel = this.simpleBrokerContext.getBean("brokerChannel", TestChannel.class); Set<MessageHandler> handlers = channel.getSubscribers(); assertEquals(2, handlers.size()); assertTrue(handlers.contains(simpleBrokerContext.getBean(UserDestinationMessageHandler.class))); assertTrue(handlers.contains(simpleBrokerContext.getBean(SimpleBrokerMessageHandler.class))); assertNull(channel.getExecutor()); }
Example #16
Source File: MessageBrokerConfigurationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void clientInboundChannelWithBrokerRelay() { TestChannel channel = this.brokerRelayContext.getBean("clientInboundChannel", TestChannel.class); Set<MessageHandler> handlers = channel.getSubscribers(); assertEquals(3, handlers.size()); assertTrue(handlers.contains(brokerRelayContext.getBean(SimpAnnotationMethodMessageHandler.class))); assertTrue(handlers.contains(brokerRelayContext.getBean(UserDestinationMessageHandler.class))); assertTrue(handlers.contains(brokerRelayContext.getBean(StompBrokerRelayMessageHandler.class))); }
Example #17
Source File: MessageBrokerConfigurationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void clientInboundChannel() { TestChannel channel = this.simpleBrokerContext.getBean("clientInboundChannel", TestChannel.class); Set<MessageHandler> handlers = channel.getSubscribers(); assertEquals(3, handlers.size()); assertTrue(handlers.contains(simpleBrokerContext.getBean(SimpAnnotationMethodMessageHandler.class))); assertTrue(handlers.contains(simpleBrokerContext.getBean(UserDestinationMessageHandler.class))); assertTrue(handlers.contains(simpleBrokerContext.getBean(SimpleBrokerMessageHandler.class))); }
Example #18
Source File: AbstractMessageBrokerConfiguration.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Bean public UserDestinationMessageHandler userDestinationMessageHandler() { UserDestinationMessageHandler handler = new UserDestinationMessageHandler(clientInboundChannel(), brokerChannel(), userDestinationResolver()); String destination = getBrokerRegistry().getUserDestinationBroadcast(); handler.setBroadcastDestination(destination); return handler; }
Example #19
Source File: MessageBrokerBeanDefinitionParserTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void customChannels() { loadBeanDefinitions("websocket-config-broker-customchannels.xml"); SimpAnnotationMethodMessageHandler annotationMethodMessageHandler = this.appContext.getBean(SimpAnnotationMethodMessageHandler.class); Validator validator = annotationMethodMessageHandler.getValidator(); assertNotNull(validator); assertSame(this.appContext.getBean("myValidator"), validator); assertThat(validator, Matchers.instanceOf(TestValidator.class)); List<Class<? extends MessageHandler>> subscriberTypes = Arrays.asList(SimpAnnotationMethodMessageHandler.class, UserDestinationMessageHandler.class, SimpleBrokerMessageHandler.class); testChannel("clientInboundChannel", subscriberTypes, 3); testExecutor("clientInboundChannel", 100, 200, 600); subscriberTypes = Collections.singletonList(SubProtocolWebSocketHandler.class); testChannel("clientOutboundChannel", subscriberTypes, 3); testExecutor("clientOutboundChannel", 101, 201, 601); subscriberTypes = Arrays.asList(SimpleBrokerMessageHandler.class, UserDestinationMessageHandler.class); testChannel("brokerChannel", subscriberTypes, 1); testExecutor("brokerChannel", 102, 202, 602); }
Example #20
Source File: WebSocketMessageBrokerConfigurationSupportTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void brokerChannel() { ApplicationContext config = createConfig(TestChannelConfig.class, TestConfigurer.class); TestChannel channel = config.getBean("brokerChannel", TestChannel.class); Set<MessageHandler> handlers = channel.getSubscribers(); List<ChannelInterceptor> interceptors = channel.getInterceptors(); assertEquals(ImmutableMessageChannelInterceptor.class, interceptors.get(interceptors.size()-1).getClass()); assertEquals(2, handlers.size()); assertTrue(handlers.contains(config.getBean(SimpleBrokerMessageHandler.class))); assertTrue(handlers.contains(config.getBean(UserDestinationMessageHandler.class))); }
Example #21
Source File: MessageBrokerConfigurationTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void brokerChannelWithBrokerRelay() { ApplicationContext context = loadConfig(BrokerRelayConfig.class); TestChannel channel = context.getBean("brokerChannel", TestChannel.class); Set<MessageHandler> handlers = channel.getSubscribers(); assertEquals(2, handlers.size()); assertTrue(handlers.contains(context.getBean(UserDestinationMessageHandler.class))); assertTrue(handlers.contains(context.getBean(StompBrokerRelayMessageHandler.class))); }
Example #22
Source File: MessageBrokerConfigurationTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void userBroadcastsDisabledWithSimpleBroker() { ApplicationContext context = loadConfig(SimpleBrokerConfig.class); SimpUserRegistry registry = context.getBean(SimpUserRegistry.class); assertNotNull(registry); assertNotEquals(MultiServerUserRegistry.class, registry.getClass()); UserDestinationMessageHandler handler = context.getBean(UserDestinationMessageHandler.class); assertNull(handler.getBroadcastDestination()); Object nullBean = context.getBean("userRegistryMessageHandler"); assertTrue(nullBean.equals(null)); }
Example #23
Source File: AbstractMessageBrokerConfiguration.java From spring-analysis-note with MIT License | 5 votes |
@Bean public UserDestinationMessageHandler userDestinationMessageHandler() { UserDestinationMessageHandler handler = new UserDestinationMessageHandler(clientInboundChannel(), brokerChannel(), userDestinationResolver()); String destination = getBrokerRegistry().getUserDestinationBroadcast(); if (destination != null) { handler.setBroadcastDestination(destination); } return handler; }
Example #24
Source File: MessageBrokerConfigurationTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void brokerChannelWithBrokerRelay() { ApplicationContext context = loadConfig(BrokerRelayConfig.class); TestChannel channel = context.getBean("brokerChannel", TestChannel.class); Set<MessageHandler> handlers = channel.getSubscribers(); assertEquals(2, handlers.size()); assertTrue(handlers.contains(context.getBean(UserDestinationMessageHandler.class))); assertTrue(handlers.contains(context.getBean(StompBrokerRelayMessageHandler.class))); }
Example #25
Source File: MessageBrokerConfigurationTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void brokerChannel() { ApplicationContext context = loadConfig(SimpleBrokerConfig.class); TestChannel channel = context.getBean("brokerChannel", TestChannel.class); Set<MessageHandler> handlers = channel.getSubscribers(); assertEquals(2, handlers.size()); assertTrue(handlers.contains(context.getBean(UserDestinationMessageHandler.class))); assertTrue(handlers.contains(context.getBean(SimpleBrokerMessageHandler.class))); assertNull(channel.getExecutor()); }
Example #26
Source File: MessageBrokerConfigurationTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void clientInboundChannelWithBrokerRelay() { ApplicationContext context = loadConfig(BrokerRelayConfig.class); TestChannel channel = context.getBean("clientInboundChannel", TestChannel.class); Set<MessageHandler> handlers = channel.getSubscribers(); assertEquals(3, handlers.size()); assertTrue(handlers.contains(context.getBean(SimpAnnotationMethodMessageHandler.class))); assertTrue(handlers.contains(context.getBean(UserDestinationMessageHandler.class))); assertTrue(handlers.contains(context.getBean(StompBrokerRelayMessageHandler.class))); }
Example #27
Source File: MessageBrokerConfigurationTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void clientInboundChannel() { ApplicationContext context = loadConfig(SimpleBrokerConfig.class); TestChannel channel = context.getBean("clientInboundChannel", TestChannel.class); Set<MessageHandler> handlers = channel.getSubscribers(); assertEquals(3, handlers.size()); assertTrue(handlers.contains(context.getBean(SimpAnnotationMethodMessageHandler.class))); assertTrue(handlers.contains(context.getBean(UserDestinationMessageHandler.class))); assertTrue(handlers.contains(context.getBean(SimpleBrokerMessageHandler.class))); }
Example #28
Source File: AbstractMessageBrokerConfiguration.java From java-technology-stack with MIT License | 5 votes |
@Bean public UserDestinationMessageHandler userDestinationMessageHandler() { UserDestinationMessageHandler handler = new UserDestinationMessageHandler(clientInboundChannel(), brokerChannel(), userDestinationResolver()); String destination = getBrokerRegistry().getUserDestinationBroadcast(); if (destination != null) { handler.setBroadcastDestination(destination); } return handler; }
Example #29
Source File: MessageBrokerBeanDefinitionParserTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void customChannels() { loadBeanDefinitions("websocket-config-broker-customchannels.xml"); SimpAnnotationMethodMessageHandler annotationMethodMessageHandler = this.appContext.getBean(SimpAnnotationMethodMessageHandler.class); Validator validator = annotationMethodMessageHandler.getValidator(); assertNotNull(validator); assertSame(this.appContext.getBean("myValidator"), validator); assertThat(validator, Matchers.instanceOf(TestValidator.class)); List<Class<? extends MessageHandler>> subscriberTypes = Arrays.asList(SimpAnnotationMethodMessageHandler.class, UserDestinationMessageHandler.class, SimpleBrokerMessageHandler.class); testChannel("clientInboundChannel", subscriberTypes, 3); testExecutor("clientInboundChannel", 100, 200, 600); subscriberTypes = Collections.singletonList(SubProtocolWebSocketHandler.class); testChannel("clientOutboundChannel", subscriberTypes, 3); testExecutor("clientOutboundChannel", 101, 201, 601); subscriberTypes = Arrays.asList(SimpleBrokerMessageHandler.class, UserDestinationMessageHandler.class); testChannel("brokerChannel", subscriberTypes, 1); testExecutor("brokerChannel", 102, 202, 602); }
Example #30
Source File: WebSocketMessageBrokerConfigurationSupportTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void brokerChannel() { ApplicationContext config = createConfig(TestChannelConfig.class, TestConfigurer.class); TestChannel channel = config.getBean("brokerChannel", TestChannel.class); Set<MessageHandler> handlers = channel.getSubscribers(); List<ChannelInterceptor> interceptors = channel.getInterceptors(); assertEquals(ImmutableMessageChannelInterceptor.class, interceptors.get(interceptors.size()-1).getClass()); assertEquals(2, handlers.size()); assertTrue(handlers.contains(config.getBean(SimpleBrokerMessageHandler.class))); assertTrue(handlers.contains(config.getBean(UserDestinationMessageHandler.class))); }