List of usage examples for org.springframework.messaging.simp SimpMessagingTemplate SimpMessagingTemplate
public SimpMessagingTemplate(MessageChannel messageChannel)
From source file:org.springframework.samples.portfolio.web.standalone.StandalonePortfolioControllerTests.java
@Before public void setup() { this.portfolioService = new PortfolioServiceImpl(); this.tradeService = new TestTradeService(); PortfolioController controller = new PortfolioController(this.portfolioService, this.tradeService); this.clientOutboundChannel = new TestMessageChannel(); this.annotationMethodMessageHandler = new TestSimpAnnotationMethodMessageHandler(new TestMessageChannel(), clientOutboundChannel, new SimpMessagingTemplate(new TestMessageChannel())); this.annotationMethodMessageHandler.registerHandler(controller); this.annotationMethodMessageHandler.setDestinationPrefixes(Arrays.asList("/app")); this.annotationMethodMessageHandler.setMessageConverter(new MappingJackson2MessageConverter()); this.annotationMethodMessageHandler.setApplicationContext(new StaticApplicationContext()); this.annotationMethodMessageHandler.afterPropertiesSet(); }
From source file:org.springframework.messaging.simp.annotation.support.SimpAnnotationMethodMessageHandler.java
/** * 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 *//*from w w w. ja v a2 s. c om*/ 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<>(); converters.add(new StringMessageConverter()); converters.add(new ByteArrayMessageConverter()); this.messageConverter = new CompositeMessageConverter(converters); }
From source file:org.springframework.messaging.simp.handler.AnnotationMethodMessageHandler.java
/** * @param dispatchMessagingTemplate a messaging template to dispatch messages to for * further processing, e.g. the use of an {@link ReplyTo} annotation on a * message handling method, causes a new (broadcast) message to be sent. * @param webSocketSessionChannel the channel to send messages to WebSocket sessions * on this application server. This is used primarily for processing the return * values from {@link SubscribeEvent}-annotated methods. *///from ww w . jav a 2 s.c om public AnnotationMethodMessageHandler(SimpMessageSendingOperations dispatchMessagingTemplate, MessageChannel webSocketSessionChannel) { Assert.notNull(dispatchMessagingTemplate, "dispatchMessagingTemplate is required"); Assert.notNull(webSocketSessionChannel, "webSocketSessionChannel is required"); this.dispatchMessagingTemplate = dispatchMessagingTemplate; this.webSocketSessionMessagingTemplate = new SimpMessagingTemplate(webSocketSessionChannel); }
From source file:org.springframework.messaging.simp.user.UserDestinationMessageHandler.java
/** * 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./*from ww w .j av a 2s. c o m*/ * @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; }