Search in sources :

Example 1 with RemoteClient

use of com.yahoo.messagebus.jdisc.test.RemoteClient in project vespa by vespa-engine.

the class SharedDestinationSessionTestCase method requireThatSessionCanSendReply.

@Test
public void requireThatSessionCanSendReply() throws InterruptedException {
    RemoteClient client = RemoteClient.newInstanceWithInternSlobrok();
    MessageQueue queue = new MessageQueue();
    DestinationSessionParams params = new DestinationSessionParams().setMessageHandler(queue);
    SharedDestinationSession session = newDestinationSession(client.slobrokId(), params);
    Route route = Route.parse(session.connectionSpec());
    assertTrue(client.sendMessage(new SimpleMessage("foo").setRoute(route)).isAccepted());
    Message msg = queue.awaitMessage(60, TimeUnit.SECONDS);
    assertNotNull(msg);
    Reply reply = new SimpleReply("bar");
    reply.swapState(msg);
    session.sendReply(reply);
    assertNotNull(client.awaitReply(60, TimeUnit.SECONDS));
    session.release();
    client.close();
}
Also used : SimpleReply(com.yahoo.messagebus.test.SimpleReply) MessageQueue(com.yahoo.messagebus.jdisc.test.MessageQueue) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) RemoteClient(com.yahoo.messagebus.jdisc.test.RemoteClient) SimpleReply(com.yahoo.messagebus.test.SimpleReply) Route(com.yahoo.messagebus.routing.Route) Test(org.junit.Test)

Example 2 with RemoteClient

use of com.yahoo.messagebus.jdisc.test.RemoteClient in project vespa by vespa-engine.

the class SharedIntermediateSessionTestCase method requireThatSessionCanSendReply.

@Test
public void requireThatSessionCanSendReply() throws InterruptedException {
    RemoteClient client = RemoteClient.newInstanceWithInternSlobrok();
    MessageQueue queue = new MessageQueue();
    IntermediateSessionParams params = new IntermediateSessionParams().setMessageHandler(queue);
    SharedIntermediateSession session = newIntermediateSession(client.slobrokId(), params);
    Route route = Route.parse(session.connectionSpec());
    assertTrue(client.sendMessage(new SimpleMessage("foo").setRoute(route)).isAccepted());
    Message msg = queue.awaitMessage(60, TimeUnit.SECONDS);
    assertNotNull(msg);
    Reply reply = new SimpleReply("bar");
    reply.swapState(msg);
    session.sendReply(reply);
    assertNotNull(client.awaitReply(60, TimeUnit.SECONDS));
    session.release();
    client.close();
}
Also used : SimpleReply(com.yahoo.messagebus.test.SimpleReply) MessageQueue(com.yahoo.messagebus.jdisc.test.MessageQueue) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) RemoteClient(com.yahoo.messagebus.jdisc.test.RemoteClient) SimpleReply(com.yahoo.messagebus.test.SimpleReply) Route(com.yahoo.messagebus.routing.Route) Test(org.junit.Test)

Aggregations

MessageQueue (com.yahoo.messagebus.jdisc.test.MessageQueue)2 RemoteClient (com.yahoo.messagebus.jdisc.test.RemoteClient)2 Route (com.yahoo.messagebus.routing.Route)2 SimpleMessage (com.yahoo.messagebus.test.SimpleMessage)2 SimpleReply (com.yahoo.messagebus.test.SimpleReply)2 Test (org.junit.Test)2