/** * Connect and notify the given {@link StompSessionHandler} when connected * on the STOMP level. * @param handler the handler for the STOMP session * @return a ListenableFuture for access to the session when ready for use */ public ListenableFuture<StompSession> connect(StompSessionHandler handler) { return connect(null, handler); }
/** * An overloaded version of {@link #connect(StompSessionHandler)} that * accepts headers to use for the STOMP CONNECT frame. * @param connectHeaders headers to add to the CONNECT frame * @param handler the handler for the STOMP session * @return a ListenableFuture for access to the session when ready for use */ public ListenableFuture<StompSession> connect(@Nullable StompHeaders connectHeaders, StompSessionHandler handler) { ConnectionHandlingStompSession session = createSession(connectHeaders, handler); this.tcpClient.connect(session); return session.getSessionFuture(); }
/** * Create an instance with the given host and port. * @param host the host * @param port the port */ public ReactorNettyTcpStompClient(String host, int port) { this.tcpClient = initTcpClient(host, port); }
@Before public void setUp() throws Exception { logger.debug("Setting up before '" + this.testName.getMethodName() + "'"); int port = SocketUtils.findAvailableTcpPort(61613); this.activeMQBroker = new BrokerService(); this.activeMQBroker.addConnector("stomp://127.0.0.1:" + port); this.activeMQBroker.setStartAsync(false); this.activeMQBroker.setPersistent(false); this.activeMQBroker.setUseJmx(false); this.activeMQBroker.getSystemUsage().getMemoryUsage().setLimit(1024 * 1024 * 5); this.activeMQBroker.getSystemUsage().getTempUsage().setLimit(1024 * 1024 * 5); this.activeMQBroker.start(); ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler(); taskScheduler.afterPropertiesSet(); this.client = new ReactorNettyTcpStompClient("127.0.0.1", port); this.client.setMessageConverter(new StringMessageConverter()); this.client.setTaskScheduler(taskScheduler); }
@BeforeClass public static void setup() throws Exception { int port = SocketUtils.findAvailableTcpPort(61613); activeMQBroker = new BrokerService(); activeMQBroker.addConnector("stomp://127.0.0.1:" + port); activeMQBroker.setPersistent(false); activeMQBroker.setUseJmx(false); activeMQBroker.getSystemUsage().getMemoryUsage().setLimit(1024 * 1024 * 5); activeMQBroker.getSystemUsage().getTempUsage().setLimit(1024 * 1024 * 5); activeMQBroker.start(); stompClient = new ReactorNettyTcpStompClient("127.0.0.1", port); stompClient.setMessageConverter(new PassThruMessageConverter()); ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler(); taskScheduler.afterPropertiesSet(); stompClient.setTaskScheduler(taskScheduler); stompClient.setReceiptTimeLimit(5000); }
@Test public void publishSubscribe() throws Exception { String destination = "/topic/foo"; ConsumingHandler consumingHandler1 = new ConsumingHandler(destination); ListenableFuture<StompSession> consumerFuture1 = this.client.connect(consumingHandler1); ConsumingHandler consumingHandler2 = new ConsumingHandler(destination); ListenableFuture<StompSession> consumerFuture2 = this.client.connect(consumingHandler2); assertTrue(consumingHandler1.awaitForSubscriptions(5000)); assertTrue(consumingHandler2.awaitForSubscriptions(5000)); ProducingHandler producingHandler = new ProducingHandler(); producingHandler.addToSend(destination, "foo1"); producingHandler.addToSend(destination, "foo2"); ListenableFuture<StompSession> producerFuture = this.client.connect(producingHandler); assertTrue(consumingHandler1.awaitForMessageCount(2, 5000)); assertThat(consumingHandler1.getReceived(), containsInAnyOrder("foo1", "foo2")); assertTrue(consumingHandler2.awaitForMessageCount(2, 5000)); assertThat(consumingHandler2.getReceived(), containsInAnyOrder("foo1", "foo2")); consumerFuture1.get().disconnect(); consumerFuture2.get().disconnect(); producerFuture.get().disconnect(); }
/** * Create an instance with the given host and port. * @param host the host * @param port the port */ public ReactorNettyTcpStompClient(String host, int port) { this.tcpClient = initTcpClient(host, port); }
/** * An overloaded version of {@link #connect(StompSessionHandler)} that * accepts headers to use for the STOMP CONNECT frame. * @param connectHeaders headers to add to the CONNECT frame * @param handler the handler for the STOMP session * @return a ListenableFuture for access to the session when ready for use */ public ListenableFuture<StompSession> connect(@Nullable StompHeaders connectHeaders, StompSessionHandler handler) { ConnectionHandlingStompSession session = createSession(connectHeaders, handler); this.tcpClient.connect(session); return session.getSessionFuture(); }
/** * Connect and notify the given {@link StompSessionHandler} when connected * on the STOMP level. * @param handler the handler for the STOMP session * @return a ListenableFuture for access to the session when ready for use */ public ListenableFuture<StompSession> connect(StompSessionHandler handler) { return connect(null, handler); }
/** * Create an instance with the given host and port. * @param host the host * @param port the port */ public ReactorNettyTcpStompClient(String host, int port) { this.tcpClient = initTcpClient(host, port); }
/** * An overloaded version of {@link #connect(StompSessionHandler)} that * accepts headers to use for the STOMP CONNECT frame. * @param connectHeaders headers to add to the CONNECT frame * @param handler the handler for the STOMP session * @return a ListenableFuture for access to the session when ready for use */ public ListenableFuture<StompSession> connect(@Nullable StompHeaders connectHeaders, StompSessionHandler handler) { ConnectionHandlingStompSession session = createSession(connectHeaders, handler); this.tcpClient.connect(session); return session.getSessionFuture(); }
@Override protected ListenableFuture<StompSession> doConnect(StompSessionHandler handler) { return ((ReactorNettyTcpStompClient) this.stompClient).connect(getConnectHeaders(), handler); }
/** * Create an instance with the given host and port. * @param host the host * @param port the port */ public ReactorNettyTcpStompClient(String host, int port) { this.tcpClient = initTcpClient(host, port); }
/** * An overloaded version of {@link #connect(StompSessionHandler)} that * accepts headers to use for the STOMP CONNECT frame. * @param connectHeaders headers to add to the CONNECT frame * @param handler the handler for the STOMP session * @return a ListenableFuture for access to the session when ready for use */ public ListenableFuture<StompSession> connect(@Nullable StompHeaders connectHeaders, StompSessionHandler handler) { ConnectionHandlingStompSession session = createSession(connectHeaders, handler); this.tcpClient.connect(session); return session.getSessionFuture(); }
/** * Connect and notify the given {@link StompSessionHandler} when connected * on the STOMP level. * @param handler the handler for the STOMP session * @return a ListenableFuture for access to the session when ready for use */ public ListenableFuture<StompSession> connect(StompSessionHandler handler) { return connect(null, handler); }
/** * Connect and notify the given {@link StompSessionHandler} when connected * on the STOMP level. * @param handler the handler for the STOMP session * @return a ListenableFuture for access to the session when ready for use */ public ListenableFuture<StompSession> connect(StompSessionHandler handler) { return connect(null, handler); }