Java Code Examples for io.vertx.core.eventbus.EventBus#publish()

The following examples show how to use io.vertx.core.eventbus.EventBus#publish() . 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: MessageConsumerMethodTest.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Test
public void testPublish() throws InterruptedException {
    SimpleBean.MESSAGES.clear();
    EventBus eventBus = Arc.container().instance(EventBus.class).get();
    SimpleBean.latch = new CountDownLatch(2);
    eventBus.publish("pub", "Hello");
    SimpleBean.latch.await(2, TimeUnit.SECONDS);
    assertTrue(SimpleBean.MESSAGES.contains("hello"));
    assertTrue(SimpleBean.MESSAGES.contains("HELLO"));
}
 
Example 2
Source File: MessageConsumerMethodTest.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Test
public void testBlockingConsumer() throws InterruptedException {
    SimpleBean.MESSAGES.clear();
    EventBus eventBus = Arc.container().instance(EventBus.class).get();
    SimpleBean.latch = new CountDownLatch(1);
    eventBus.publish("blocking", "Hello");
    SimpleBean.latch.await(2, TimeUnit.SECONDS);
    assertEquals(1, SimpleBean.MESSAGES.size());
    String message = SimpleBean.MESSAGES.get(0);
    assertTrue(message.contains("hello::true"));
}
 
Example 3
Source File: MessageConsumerMethodTest.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Test
public void testPublishRx() throws InterruptedException {
    SimpleBean.MESSAGES.clear();
    EventBus eventBus = Arc.container().instance(EventBus.class).get();
    SimpleBean.latch = new CountDownLatch(1);
    eventBus.publish("pub-rx", "Hello");
    SimpleBean.latch.await(2, TimeUnit.SECONDS);
    assertTrue(SimpleBean.MESSAGES.contains("HELLO"));
}
 
Example 4
Source File: MessageConsumerMethodTest.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Test
public void testPublishAxle() throws InterruptedException {
    SimpleBean.MESSAGES.clear();
    EventBus eventBus = Arc.container().instance(EventBus.class).get();
    SimpleBean.latch = new CountDownLatch(1);
    eventBus.publish("pub-axle", "Hello");
    SimpleBean.latch.await(2, TimeUnit.SECONDS);
    assertTrue(SimpleBean.MESSAGES.contains("HELLO"));
}
 
Example 5
Source File: MessageConsumerMethodTest.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@Test
public void testPublishMutiny() throws InterruptedException {
    SimpleBean.MESSAGES.clear();
    EventBus eventBus = Arc.container().instance(EventBus.class).get();
    SimpleBean.latch = new CountDownLatch(1);
    eventBus.publish("pub-mutiny", "Hello");
    SimpleBean.latch.await(2, TimeUnit.SECONDS);
    assertTrue(SimpleBean.MESSAGES.contains("HELLO"));
}
 
Example 6
Source File: TestSockJSController.java    From nubes with Apache License 2.0 4 votes vote down vote up
@OnOpen
public void openHandler(SockJSSocket socket, EventBus eventBus) {
	eventBus.publish(EB_ADDRESS, "opened");
}
 
Example 7
Source File: TestSockJSController.java    From nubes with Apache License 2.0 4 votes vote down vote up
@OnClose
public void closeHandler(SockJSSocket socket, EventBus eventBus) {
	eventBus.publish(EB_ADDRESS, "closed");
}
 
Example 8
Source File: Socket.java    From wisdom with Apache License 2.0 2 votes vote down vote up
/**
 * Sends a text frame on the socket.
 *
 * @param message the message
 * @param bus     the Vert.x event bus.
 */
public void publish(String message, EventBus bus) {
    bus.publish(getWriteHandlerId(), message);
}
 
Example 9
Source File: Socket.java    From wisdom with Apache License 2.0 2 votes vote down vote up
/**
 * Sends a binary frame on the socket.
 *
 * @param message the message
 * @param bus     the Vert.x event bus.
 */
public void publish(byte[] message, EventBus bus) {
    bus.publish(getBinaryWriteHandlerId(), Buffer.buffer(message));
}