org.springframework.messaging.simp.SimpMessagingTemplate Java Examples
The following examples show how to use
org.springframework.messaging.simp.SimpMessagingTemplate.
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: SendToMethodReturnValueHandlerTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void sendTo() throws Exception { given(this.messageChannel.send(any(Message.class))).willReturn(true); String sessionId = "sess1"; Message<?> inputMessage = createInputMessage(sessionId, "sub1", null, null, null); this.handler.handleReturnValue(PAYLOAD, this.sendToReturnType, inputMessage); verify(this.messageChannel, times(2)).send(this.messageCaptor.capture()); SimpMessageHeaderAccessor accessor = getCapturedAccessor(0); assertEquals(sessionId, accessor.getSessionId()); assertEquals("/dest1", accessor.getDestination()); assertEquals(MIME_TYPE, accessor.getContentType()); assertNull("Subscription id should not be copied", accessor.getSubscriptionId()); assertEquals(this.sendToReturnType, accessor.getHeader(SimpMessagingTemplate.CONVERSION_HINT_HEADER)); accessor = getCapturedAccessor(1); assertEquals(sessionId, accessor.getSessionId()); assertEquals("/dest2", accessor.getDestination()); assertEquals(MIME_TYPE, accessor.getContentType()); assertNull("Subscription id should not be copied", accessor.getSubscriptionId()); assertEquals(this.sendToReturnType, accessor.getHeader(SimpMessagingTemplate.CONVERSION_HINT_HEADER)); }
Example #2
Source File: HrMaxQuizService.java From qzr with Apache License 2.0 | 6 votes |
@Autowired public HrMaxQuizService(KieContainer kieContainer, SimpMessagingTemplate template) { log.info("Initialising a new quiz session."); this.kieSession = kieContainer.newKieSession("HrmaxSession"); this.agendaEventPublisher = new PublishingAgendaEventListener(template); this.agendaEventListener = new LoggingAgendaEventListener(); this.ruleRuntimeEventListener = new LoggingRuleRuntimeEventListener(); this.kieSession.addEventListener(agendaEventPublisher); this.kieSession.addEventListener(agendaEventListener); this.kieSession.addEventListener(ruleRuntimeEventListener); this.kieSession.fireAllRules(); }
Example #3
Source File: SimpAnnotationMethodMessageHandler.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Create an instance of SimpAnnotationMethodMessageHandler with the given * message channels and broker messaging template. * @param clientInboundChannel the channel for receiving messages from clients (e.g. WebSocket clients) * @param clientOutboundChannel the channel for messages to clients (e.g. WebSocket clients) * @param brokerTemplate a messaging template to send application messages to the broker */ public SimpAnnotationMethodMessageHandler(SubscribableChannel clientInboundChannel, MessageChannel clientOutboundChannel, SimpMessageSendingOperations brokerTemplate) { Assert.notNull(clientInboundChannel, "clientInboundChannel must not be null"); Assert.notNull(clientOutboundChannel, "clientOutboundChannel must not be null"); Assert.notNull(brokerTemplate, "brokerTemplate must not be null"); this.clientInboundChannel = clientInboundChannel; this.clientMessagingTemplate = new SimpMessagingTemplate(clientOutboundChannel); this.brokerTemplate = brokerTemplate; Collection<MessageConverter> converters = new ArrayList<MessageConverter>(); converters.add(new StringMessageConverter()); converters.add(new ByteArrayMessageConverter()); this.messageConverter = new CompositeMessageConverter(converters); }
Example #4
Source File: SendToMethodReturnValueHandlerTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void sendToDefaultDestination() throws Exception { given(this.messageChannel.send(any(Message.class))).willReturn(true); String sessionId = "sess1"; Message<?> inputMessage = createInputMessage(sessionId, "sub1", "/app", "/dest", null); this.handler.handleReturnValue(PAYLOAD, this.sendToDefaultDestReturnType, inputMessage); verify(this.messageChannel, times(1)).send(this.messageCaptor.capture()); SimpMessageHeaderAccessor accessor = getCapturedAccessor(0); assertEquals(sessionId, accessor.getSessionId()); assertEquals("/topic/dest", accessor.getDestination()); assertEquals(MIME_TYPE, accessor.getContentType()); assertNull("Subscription id should not be copied", accessor.getSubscriptionId()); assertEquals(this.sendToDefaultDestReturnType, accessor.getHeader(SimpMessagingTemplate.CONVERSION_HINT_HEADER)); }
Example #5
Source File: SendToMethodReturnValueHandlerTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void sendToUserDefaultDestinationSingleSession() throws Exception { given(this.messageChannel.send(any(Message.class))).willReturn(true); String sessionId = "sess1"; TestUser user = new TestUser(); Message<?> message = createMessage(sessionId, "sub1", "/app", "/dest", user); this.handler.handleReturnValue(PAYLOAD, this.sendToUserInSessionDefaultDestReturnType, message); verify(this.messageChannel, times(1)).send(this.messageCaptor.capture()); SimpMessageHeaderAccessor accessor = getCapturedAccessor(0); assertEquals(sessionId, accessor.getSessionId()); assertEquals("/user/" + user.getName() + "/queue/dest", accessor.getDestination()); assertEquals(MIME_TYPE, accessor.getContentType()); assertNull("Subscription id should not be copied", accessor.getSubscriptionId()); assertEquals(this.sendToUserInSessionDefaultDestReturnType, accessor.getHeader(SimpMessagingTemplate.CONVERSION_HINT_HEADER)); }
Example #6
Source File: SendToMethodReturnValueHandlerTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testHeadersToSend() throws Exception { Message<?> message = createMessage("sess1", "sub1", "/app", "/dest", null); SimpMessageSendingOperations messagingTemplate = Mockito.mock(SimpMessageSendingOperations.class); SendToMethodReturnValueHandler handler = new SendToMethodReturnValueHandler(messagingTemplate, false); handler.handleReturnValue(PAYLOAD, this.noAnnotationsReturnType, message); ArgumentCaptor<MessageHeaders> captor = ArgumentCaptor.forClass(MessageHeaders.class); verify(messagingTemplate).convertAndSend(eq("/topic/dest"), eq(PAYLOAD), captor.capture()); MessageHeaders headers = captor.getValue(); SimpMessageHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(headers, SimpMessageHeaderAccessor.class); assertNotNull(accessor); assertTrue(accessor.isMutable()); assertEquals("sess1", accessor.getSessionId()); assertNull("Subscription id should not be copied", accessor.getSubscriptionId()); assertEquals(this.noAnnotationsReturnType, accessor.getHeader(SimpMessagingTemplate.CONVERSION_HINT_HEADER)); }
Example #7
Source File: SubscriptionMethodReturnValueHandlerTests.java From spring-analysis-note with MIT License | 6 votes |
@Before public void setup() throws Exception { MockitoAnnotations.initMocks(this); SimpMessagingTemplate messagingTemplate = new SimpMessagingTemplate(this.messageChannel); messagingTemplate.setMessageConverter(new StringMessageConverter()); this.handler = new SubscriptionMethodReturnValueHandler(messagingTemplate); SimpMessagingTemplate jsonMessagingTemplate = new SimpMessagingTemplate(this.messageChannel); jsonMessagingTemplate.setMessageConverter(new MappingJackson2MessageConverter()); this.jsonHandler = new SubscriptionMethodReturnValueHandler(jsonMessagingTemplate); Method method = this.getClass().getDeclaredMethod("getData"); this.subscribeEventReturnType = new MethodParameter(method, -1); method = this.getClass().getDeclaredMethod("getDataAndSendTo"); this.subscribeEventSendToReturnType = new MethodParameter(method, -1); method = this.getClass().getDeclaredMethod("handle"); this.messageMappingReturnType = new MethodParameter(method, -1); method = this.getClass().getDeclaredMethod("getJsonView"); this.subscribeEventJsonViewReturnType = new MethodParameter(method, -1); }
Example #8
Source File: SubscriptionMethodReturnValueHandlerTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void testMessageSentToChannel() throws Exception { given(this.messageChannel.send(any(Message.class))).willReturn(true); String sessionId = "sess1"; String subscriptionId = "subs1"; String destination = "/dest"; Message<?> inputMessage = createInputMessage(sessionId, subscriptionId, destination, null); this.handler.handleReturnValue(PAYLOAD, this.subscribeEventReturnType, inputMessage); verify(this.messageChannel).send(this.messageCaptor.capture()); assertNotNull(this.messageCaptor.getValue()); Message<?> message = this.messageCaptor.getValue(); SimpMessageHeaderAccessor headerAccessor = SimpMessageHeaderAccessor.wrap(message); assertNull("SimpMessageHeaderAccessor should have disabled id", headerAccessor.getId()); assertNull("SimpMessageHeaderAccessor should have disabled timestamp", headerAccessor.getTimestamp()); assertEquals(sessionId, headerAccessor.getSessionId()); assertEquals(subscriptionId, headerAccessor.getSubscriptionId()); assertEquals(destination, headerAccessor.getDestination()); assertEquals(MIME_TYPE, headerAccessor.getContentType()); assertEquals(this.subscribeEventReturnType, headerAccessor.getHeader(SimpMessagingTemplate.CONVERSION_HINT_HEADER)); }
Example #9
Source File: SubscriptionMethodReturnValueHandlerTests.java From spring-analysis-note with MIT License | 6 votes |
@Test @SuppressWarnings({ "unchecked", "rawtypes" }) public void testHeadersPassedToMessagingTemplate() throws Exception { String sessionId = "sess1"; String subscriptionId = "subs1"; String destination = "/dest"; Message<?> inputMessage = createInputMessage(sessionId, subscriptionId, destination, null); MessageSendingOperations messagingTemplate = Mockito.mock(MessageSendingOperations.class); SubscriptionMethodReturnValueHandler handler = new SubscriptionMethodReturnValueHandler(messagingTemplate); handler.handleReturnValue(PAYLOAD, this.subscribeEventReturnType, inputMessage); ArgumentCaptor<MessageHeaders> captor = ArgumentCaptor.forClass(MessageHeaders.class); verify(messagingTemplate).convertAndSend(eq("/dest"), eq(PAYLOAD), captor.capture()); SimpMessageHeaderAccessor headerAccessor = MessageHeaderAccessor.getAccessor(captor.getValue(), SimpMessageHeaderAccessor.class); assertNotNull(headerAccessor); assertTrue(headerAccessor.isMutable()); assertEquals(sessionId, headerAccessor.getSessionId()); assertEquals(subscriptionId, headerAccessor.getSubscriptionId()); assertEquals(this.subscribeEventReturnType, headerAccessor.getHeader(SimpMessagingTemplate.CONVERSION_HINT_HEADER)); }
Example #10
Source File: SendToMethodReturnValueHandlerTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void sendToUserSingleSession() throws Exception { given(this.messageChannel.send(any(Message.class))).willReturn(true); String sessionId = "sess1"; TestUser user = new TestUser(); Message<?> inputMessage = createInputMessage(sessionId, "sub1", null, null, user); this.handler.handleReturnValue(PAYLOAD, this.sendToUserSingleSessionReturnType, inputMessage); verify(this.messageChannel, times(2)).send(this.messageCaptor.capture()); SimpMessageHeaderAccessor accessor = getCapturedAccessor(0); assertEquals(sessionId, accessor.getSessionId()); assertEquals(MIME_TYPE, accessor.getContentType()); assertEquals("/user/" + user.getName() + "/dest1", accessor.getDestination()); assertNull("Subscription id should not be copied", accessor.getSubscriptionId()); assertEquals(this.sendToUserSingleSessionReturnType, accessor.getHeader(SimpMessagingTemplate.CONVERSION_HINT_HEADER)); accessor = getCapturedAccessor(1); assertEquals(sessionId, accessor.getSessionId()); assertEquals("/user/" + user.getName() + "/dest2", accessor.getDestination()); assertEquals(MIME_TYPE, accessor.getContentType()); assertNull("Subscription id should not be copied", accessor.getSubscriptionId()); assertEquals(this.sendToUserSingleSessionReturnType, accessor.getHeader(SimpMessagingTemplate.CONVERSION_HINT_HEADER)); }
Example #11
Source File: SubscriptionMethodReturnValueHandlerTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings({ "unchecked", "rawtypes" }) public void testHeadersPassedToMessagingTemplate() throws Exception { String sessionId = "sess1"; String subscriptionId = "subs1"; String destination = "/dest"; Message<?> inputMessage = createInputMessage(sessionId, subscriptionId, destination, null); MessageSendingOperations messagingTemplate = Mockito.mock(MessageSendingOperations.class); SubscriptionMethodReturnValueHandler handler = new SubscriptionMethodReturnValueHandler(messagingTemplate); handler.handleReturnValue(PAYLOAD, this.subscribeEventReturnType, inputMessage); ArgumentCaptor<MessageHeaders> captor = ArgumentCaptor.forClass(MessageHeaders.class); verify(messagingTemplate).convertAndSend(eq("/dest"), eq(PAYLOAD), captor.capture()); SimpMessageHeaderAccessor headerAccessor = MessageHeaderAccessor.getAccessor(captor.getValue(), SimpMessageHeaderAccessor.class); assertNotNull(headerAccessor); assertTrue(headerAccessor.isMutable()); assertEquals(sessionId, headerAccessor.getSessionId()); assertEquals(subscriptionId, headerAccessor.getSubscriptionId()); assertEquals(this.subscribeEventReturnType, headerAccessor.getHeader(SimpMessagingTemplate.CONVERSION_HINT_HEADER)); }
Example #12
Source File: SendToMethodReturnValueHandlerTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void sendToUserDefaultDestinationSingleSession() throws Exception { given(this.messageChannel.send(any(Message.class))).willReturn(true); String sessionId = "sess1"; TestUser user = new TestUser(); Message<?> inputMessage = createInputMessage(sessionId, "sub1", "/app", "/dest", user); this.handler.handleReturnValue(PAYLOAD, this.sendToUserSingleSessionDefaultDestReturnType, inputMessage); verify(this.messageChannel, times(1)).send(this.messageCaptor.capture()); SimpMessageHeaderAccessor accessor = getCapturedAccessor(0); assertEquals(sessionId, accessor.getSessionId()); assertEquals("/user/" + user.getName() + "/queue/dest", accessor.getDestination()); assertEquals(MIME_TYPE, accessor.getContentType()); assertNull("Subscription id should not be copied", accessor.getSubscriptionId()); assertEquals(this.sendToUserSingleSessionDefaultDestReturnType, accessor.getHeader(SimpMessagingTemplate.CONVERSION_HINT_HEADER)); }
Example #13
Source File: PageResource.java From bonita-ui-designer with GNU General Public License v2.0 | 6 votes |
@Inject public PageResource( PageService pageService, PageRepository pageRepository, SimpMessagingTemplate messagingTemplate, ContractToPageMapper contractToPageMapper, AssetService<Page> pageAssetService, AssetVisitor assetVisitor, ComponentVisitor componentVisitor, AuthRulesCollector authRulesCollector) { super(pageAssetService, pageRepository, assetVisitor, Optional.of(messagingTemplate)); this.pageRepository = pageRepository; this.messagingTemplate = messagingTemplate; this.contractToPageMapper = contractToPageMapper; this.pageService = pageService; this.componentVisitor = componentVisitor; this.authRulesCollector = authRulesCollector; }
Example #14
Source File: UserRegistryMessageHandlerTests.java From java-technology-stack with MIT License | 6 votes |
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); when(this.brokerChannel.send(any())).thenReturn(true); this.converter = new MappingJackson2MessageConverter(); SimpMessagingTemplate brokerTemplate = new SimpMessagingTemplate(this.brokerChannel); brokerTemplate.setMessageConverter(this.converter); this.localRegistry = mock(SimpUserRegistry.class); this.multiServerRegistry = new MultiServerUserRegistry(this.localRegistry); this.handler = new UserRegistryMessageHandler(this.multiServerRegistry, brokerTemplate, "/topic/simp-user-registry", this.taskScheduler); }
Example #15
Source File: SendToMethodReturnValueHandlerTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void sendToNoAnnotations() throws Exception { given(this.messageChannel.send(any(Message.class))).willReturn(true); Message<?> inputMessage = createInputMessage("sess1", "sub1", "/app", "/dest", null); this.handler.handleReturnValue(PAYLOAD, this.noAnnotationsReturnType, inputMessage); verify(this.messageChannel, times(1)).send(this.messageCaptor.capture()); SimpMessageHeaderAccessor accessor = getCapturedAccessor(0); assertEquals("sess1", accessor.getSessionId()); assertEquals("/topic/dest", accessor.getDestination()); assertEquals(MIME_TYPE, accessor.getContentType()); assertNull("Subscription id should not be copied", accessor.getSubscriptionId()); assertEquals(this.noAnnotationsReturnType, accessor.getHeader(SimpMessagingTemplate.CONVERSION_HINT_HEADER)); }
Example #16
Source File: ProjectTopologyService.java From DBus with Apache License 2.0 | 6 votes |
public ResultEntity operate(String msg, Session session, Map<String, Object> map, SimpMessagingTemplate smt) throws Exception { // {"cmdType":"start/stop", "projectName":"", "topoName":"testdb", "jarPath":""} // {"cmdType":"stop", "topoName":"testdb", "id":10, "uid": topoName+time} // {"cmdType":"start", "topoName":"testdb", "id":10, "uid": topoName+time} Map<String, Object> param = null; if (session != null) { ObjectMapper mapper = new ObjectMapper(); param = mapper.readValue(msg, new TypeReference<HashMap<String, Object>>() { }); } else { param = map; } ResultEntity result = null; if (StringUtils.equals("start", (String) param.get("cmdType"))) result = start(param, session, smt); else if (StringUtils.equals("stop", (String) param.get("cmdType"))) result = stop(param, session, smt); return result; }
Example #17
Source File: SubscriptionMethodReturnValueHandlerTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testMessageSentToChannel() throws Exception { given(this.messageChannel.send(any(Message.class))).willReturn(true); String sessionId = "sess1"; String subscriptionId = "subs1"; String destination = "/dest"; Message<?> inputMessage = createInputMessage(sessionId, subscriptionId, destination, null); this.handler.handleReturnValue(PAYLOAD, this.subscribeEventReturnType, inputMessage); verify(this.messageChannel).send(this.messageCaptor.capture()); assertNotNull(this.messageCaptor.getValue()); Message<?> message = this.messageCaptor.getValue(); SimpMessageHeaderAccessor headerAccessor = SimpMessageHeaderAccessor.wrap(message); assertNull("SimpMessageHeaderAccessor should have disabled id", headerAccessor.getId()); assertNull("SimpMessageHeaderAccessor should have disabled timestamp", headerAccessor.getTimestamp()); assertEquals(sessionId, headerAccessor.getSessionId()); assertEquals(subscriptionId, headerAccessor.getSubscriptionId()); assertEquals(destination, headerAccessor.getDestination()); assertEquals(MIME_TYPE, headerAccessor.getContentType()); assertEquals(this.subscribeEventReturnType, headerAccessor.getHeader(SimpMessagingTemplate.CONVERSION_HINT_HEADER)); }
Example #18
Source File: SendToMethodReturnValueHandlerTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void testHeadersToSend() throws Exception { Message<?> message = createMessage("sess1", "sub1", "/app", "/dest", null); SimpMessageSendingOperations messagingTemplate = Mockito.mock(SimpMessageSendingOperations.class); SendToMethodReturnValueHandler handler = new SendToMethodReturnValueHandler(messagingTemplate, false); handler.handleReturnValue(PAYLOAD, this.noAnnotationsReturnType, message); ArgumentCaptor<MessageHeaders> captor = ArgumentCaptor.forClass(MessageHeaders.class); verify(messagingTemplate).convertAndSend(eq("/topic/dest"), eq(PAYLOAD), captor.capture()); MessageHeaders headers = captor.getValue(); SimpMessageHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(headers, SimpMessageHeaderAccessor.class); assertNotNull(accessor); assertTrue(accessor.isMutable()); assertEquals("sess1", accessor.getSessionId()); assertNull("Subscription id should not be copied", accessor.getSubscriptionId()); assertEquals(this.noAnnotationsReturnType, accessor.getHeader(SimpMessagingTemplate.CONVERSION_HINT_HEADER)); }
Example #19
Source File: SendToMethodReturnValueHandlerTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void testHeadersToSend() throws Exception { Message<?> inputMessage = createInputMessage("sess1", "sub1", "/app", "/dest", null); SimpMessageSendingOperations messagingTemplate = Mockito.mock(SimpMessageSendingOperations.class); SendToMethodReturnValueHandler handler = new SendToMethodReturnValueHandler(messagingTemplate, false); handler.handleReturnValue(PAYLOAD, this.noAnnotationsReturnType, inputMessage); ArgumentCaptor<MessageHeaders> captor = ArgumentCaptor.forClass(MessageHeaders.class); verify(messagingTemplate).convertAndSend(eq("/topic/dest"), eq(PAYLOAD), captor.capture()); MessageHeaders messageHeaders = captor.getValue(); SimpMessageHeaderAccessor accessor = getAccessor(messageHeaders, SimpMessageHeaderAccessor.class); assertNotNull(accessor); assertTrue(accessor.isMutable()); assertEquals("sess1", accessor.getSessionId()); assertNull("Subscription id should not be copied", accessor.getSubscriptionId()); assertEquals(this.noAnnotationsReturnType, accessor.getHeader(SimpMessagingTemplate.CONVERSION_HINT_HEADER)); }
Example #20
Source File: UserRegistryMessageHandlerTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); when(this.brokerChannel.send(any())).thenReturn(true); this.converter = new MappingJackson2MessageConverter(); SimpMessagingTemplate brokerTemplate = new SimpMessagingTemplate(this.brokerChannel); brokerTemplate.setMessageConverter(this.converter); this.localRegistry = mock(SimpUserRegistry.class); this.multiServerRegistry = new MultiServerUserRegistry(this.localRegistry); this.handler = new UserRegistryMessageHandler(this.multiServerRegistry, brokerTemplate, "/topic/simp-user-registry", this.taskScheduler); }
Example #21
Source File: WebSocketConsumersManager.java From kafka-webview with MIT License | 6 votes |
/** * Constructor. * @param webKafkaConsumerFactory For creating new Consumers. * @param messagingTemplate For publishing consumed messages back through the web socket. * @param maxConcurrentConsumers Configuration, how many consumers to run. */ public WebSocketConsumersManager( final WebKafkaConsumerFactory webKafkaConsumerFactory, final SimpMessagingTemplate messagingTemplate, final int maxConcurrentConsumers ) { this( webKafkaConsumerFactory, messagingTemplate, // Setup managed thread pool with number of concurrent threads. new ThreadPoolExecutor( maxConcurrentConsumers, maxConcurrentConsumers, 5, TimeUnit.MINUTES, new LinkedBlockingQueue<>(100) ) ); }
Example #22
Source File: SubscriptionMethodReturnValueHandler.java From spring4-understanding with Apache License 2.0 | 5 votes |
private MessageHeaders createHeaders(String sessionId, String subscriptionId, MethodParameter returnType) { SimpMessageHeaderAccessor headerAccessor = SimpMessageHeaderAccessor.create(SimpMessageType.MESSAGE); if (getHeaderInitializer() != null) { getHeaderInitializer().initHeaders(headerAccessor); } headerAccessor.setSessionId(sessionId); headerAccessor.setSubscriptionId(subscriptionId); headerAccessor.setHeader(SimpMessagingTemplate.CONVERSION_HINT_HEADER, returnType); headerAccessor.setLeaveMutable(true); return headerAccessor.getMessageHeaders(); }
Example #23
Source File: WebsocketSender.java From metasfresh-webui-api-legacy with GNU General Public License v3.0 | 5 votes |
public WebsocketEventsQueue( @NonNull final String name, @NonNull final SimpMessagingTemplate websocketMessagingTemplate, @NonNull final WebsocketEventsLog eventsLog, final boolean autoflush) { this.name = name; this.websocketMessagingTemplate = websocketMessagingTemplate; this.eventsLog = eventsLog; this.autoflush = autoflush; }
Example #24
Source File: UserRegistryMessageHandler.java From spring4-understanding with Apache License 2.0 | 5 votes |
public UserRegistryMessageHandler(SimpUserRegistry userRegistry, SimpMessagingTemplate brokerTemplate, String broadcastDestination, TaskScheduler scheduler) { Assert.notNull(userRegistry, "'userRegistry' is required"); Assert.isInstanceOf(MultiServerUserRegistry.class, userRegistry); Assert.notNull(brokerTemplate, "'brokerTemplate' is required"); Assert.hasText(broadcastDestination, "'broadcastDestination' is required"); Assert.notNull(scheduler, "'scheduler' is required"); this.userRegistry = (MultiServerUserRegistry) userRegistry; this.brokerTemplate = brokerTemplate; this.broadcastDestination = broadcastDestination; this.scheduler = scheduler; }
Example #25
Source File: AbstractMessageBrokerConfiguration.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Bean public SimpMessagingTemplate brokerMessagingTemplate() { SimpMessagingTemplate template = new SimpMessagingTemplate(brokerChannel()); String prefix = getBrokerRegistry().getUserDestinationPrefix(); if (prefix != null) { template.setUserDestinationPrefix(prefix); } template.setMessageConverter(brokerMessageConverter()); return template; }
Example #26
Source File: UserDestinationMessageHandler.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Create an instance with the given client and broker channels subscribing * to handle messages from each and then sending any resolved messages to the * broker channel. * @param clientInboundChannel messages received from clients. * @param brokerChannel messages sent to the broker. * @param resolver the resolver for "user" destinations. */ public UserDestinationMessageHandler(SubscribableChannel clientInboundChannel, SubscribableChannel brokerChannel, UserDestinationResolver resolver) { Assert.notNull(clientInboundChannel, "'clientInChannel' must not be null"); Assert.notNull(brokerChannel, "'brokerChannel' must not be null"); Assert.notNull(resolver, "resolver must not be null"); this.clientInboundChannel = clientInboundChannel; this.brokerChannel = brokerChannel; this.messagingTemplate = new SimpMessagingTemplate(brokerChannel); this.destinationResolver = resolver; }
Example #27
Source File: MonitorApplication.java From flowing-retail-old with Apache License 2.0 | 5 votes |
public static void main(String[] args) { // and startup spring boot for Tomcat + REST ConfigurableApplicationContext context = SpringApplication.run(MonitorApplication.class, args); // and startupo KAfka Consumer without spring, but tell it where to find the WebSocket Controller from Spring SimpMessagingTemplate simpMessageTemplate = context.getBean(SimpMessagingTemplate.class); FlowingStartup.startup("monitor", new MonitorEventConsumer(simpMessageTemplate), args); }
Example #28
Source File: MessageBrokerBeanDefinitionParser.java From java-technology-stack with MIT License | 5 votes |
private RuntimeBeanReference registerMessagingTemplate(Element element, RuntimeBeanReference brokerChannel, RuntimeBeanReference messageConverter, ParserContext context, @Nullable Object source) { ConstructorArgumentValues cargs = new ConstructorArgumentValues(); cargs.addIndexedArgumentValue(0, brokerChannel); RootBeanDefinition beanDef = new RootBeanDefinition(SimpMessagingTemplate.class, cargs, null); if (element.hasAttribute("user-destination-prefix")) { beanDef.getPropertyValues().add("userDestinationPrefix", element.getAttribute("user-destination-prefix")); } beanDef.getPropertyValues().add("messageConverter", messageConverter); String name = MESSAGING_TEMPLATE_BEAN_NAME; registerBeanDefByName(name, beanDef, context, source); return new RuntimeBeanReference(name); }
Example #29
Source File: WebSocketAnnotationMethodMessageHandlerTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { this.applicationContext = new StaticApplicationContext(); this.applicationContext.registerSingleton("controller", TestController.class); this.applicationContext.registerSingleton("controllerAdvice", TestControllerAdvice.class); this.applicationContext.refresh(); SubscribableChannel channel = Mockito.mock(SubscribableChannel.class); SimpMessageSendingOperations brokerTemplate = new SimpMessagingTemplate(channel); this.messageHandler = new TestWebSocketAnnotationMethodMessageHandler(brokerTemplate, channel, channel); this.messageHandler.setApplicationContext(this.applicationContext); this.messageHandler.afterPropertiesSet(); }
Example #30
Source File: WebSocketAnnotationMethodMessageHandlerTests.java From java-technology-stack with MIT License | 5 votes |
@Before public void setUp() throws Exception { this.applicationContext = new StaticApplicationContext(); this.applicationContext.registerSingleton("controller", TestController.class); this.applicationContext.registerSingleton("controllerAdvice", TestControllerAdvice.class); this.applicationContext.refresh(); SubscribableChannel channel = Mockito.mock(SubscribableChannel.class); SimpMessageSendingOperations brokerTemplate = new SimpMessagingTemplate(channel); this.messageHandler = new TestWebSocketAnnotationMethodMessageHandler(brokerTemplate, channel, channel); this.messageHandler.setApplicationContext(this.applicationContext); this.messageHandler.afterPropertiesSet(); }