blob: fece74279dbcb02d345ab4d1916d3155220fa32f [file] [log] [blame]
Madan Jampaniab6d3112014-10-02 16:30:14 -07001package org.onlab.netty;
2
3import java.io.IOException;
4
5/**
6 * Interface for low level messaging primitives.
7 */
8public interface MessagingService {
9 /**
10 * Sends a message asynchronously to the specified communication end point.
11 * The message is specified using the type and payload.
12 * @param ep end point to send the message to.
13 * @param type type of message.
14 * @param payload message payload.
15 * @throws IOException
16 */
17 public void sendAsync(Endpoint ep, String type, Object payload) throws IOException;
18
19 /**
20 * Sends a message synchronously and waits for a response.
21 * @param ep end point to send the message to.
22 * @param type type of message.
23 * @param payload message payload.
24 * @return a response future
25 * @throws IOException
26 */
27 public <T> Response<T> sendAndReceive(Endpoint ep, String type, Object payload) throws IOException;
28
29 /**
30 * Registers a new message handler for message type.
31 * @param type message type.
32 * @param handler message handler
33 */
34 public void registerHandler(String type, MessageHandler handler);
35
36 /**
37 * Unregister current handler, if one exists for message type.
38 * @param type message type
39 */
40 public void unregisterHandler(String type);
Yuta HIGUCHI993d7aa2014-10-06 22:54:38 -070041
Yuta HIGUCHI672488d2014-10-07 09:23:43 -070042 // FIXME: remove me and add PayloadSerializer to all other methods
Yuta HIGUCHI993d7aa2014-10-06 22:54:38 -070043 /**
44 * Specify the serializer to use for encoding/decoding payload.
45 *
46 * @param payloadSerializer payloadSerializer to use
47 */
48 public void setPayloadSerializer(PayloadSerializer payloadSerializer);
Madan Jampaniab6d3112014-10-02 16:30:14 -070049}