
io.jsync.eventbus.Message Maven / Gradle / Ivy
Show all versions of jsync.io Show documentation
/*
* Copyright (c) 2011-2013 The original author or authors
* ------------------------------------------------------
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.jsync.eventbus;
import io.jsync.AsyncResult;
import io.jsync.Handler;
import io.jsync.buffer.Buffer;
import io.jsync.json.JsonArray;
import io.jsync.json.JsonObject;
/**
* Represents a message on the event bus.
*
* Instances of this class are not thread-safe
*
* @author Tim Fox
*/
public interface Message {
/**
* The address the message was sent to
*/
String address();
/**
* The body of the message
*/
T body();
/**
* The reply address (if any)
*/
String replyAddress();
/**
* Same as {@code reply(T message)} but with an empty body
*/
void reply();
/**
* Reply to this message. If the message was sent specifying a reply handler, that handler will be
* called when it has received a reply. If the message wasn't sent specifying a receipt handler
* this method does nothing.
*/
void reply(Object message);
/**
* Reply to this message. If the message was sent specifying a reply handler, that handler will be
* called when it has received a reply. If the message wasn't sent specifying a receipt handler
* this method does nothing.
*/
void reply(JsonObject message);
/**
* Reply to this message. If the message was sent specifying a reply handler, that handler will be
* called when it has received a reply. If the message wasn't sent specifying a receipt handler
* this method does nothing.
*/
void reply(JsonArray message);
/**
* Reply to this message. If the message was sent specifying a reply handler, that handler will be
* called when it has received a reply. If the message wasn't sent specifying a receipt handler
* this method does nothing.
*/
void reply(String message);
/**
* Reply to this message. If the message was sent specifying a reply handler, that handler will be
* called when it has received a reply. If the message wasn't sent specifying a receipt handler
* this method does nothing.
*/
void reply(Buffer message);
/**
* Reply to this message. If the message was sent specifying a reply handler, that handler will be
* called when it has received a reply. If the message wasn't sent specifying a receipt handler
* this method does nothing.
*/
void reply(byte[] message);
/**
* Reply to this message. If the message was sent specifying a reply handler, that handler will be
* called when it has received a reply. If the message wasn't sent specifying a receipt handler
* this method does nothing.
*/
void reply(Integer message);
/**
* Reply to this message. If the message was sent specifying a reply handler, that handler will be
* called when it has received a reply. If the message wasn't sent specifying a receipt handler
* this method does nothing.
*/
void reply(Long message);
/**
* Reply to this message. If the message was sent specifying a reply handler, that handler will be
* called when it has received a reply. If the message wasn't sent specifying a receipt handler
* this method does nothing.
*/
void reply(Short message);
/**
* Reply to this message. If the message was sent specifying a reply handler, that handler will be
* called when it has received a reply. If the message wasn't sent specifying a receipt handler
* this method does nothing.
*/
void reply(Character message);
/**
* Reply to this message. If the message was sent specifying a reply handler, that handler will be
* called when it has received a reply. If the message wasn't sent specifying a receipt handler
* this method does nothing.
*/
void reply(Boolean message);
/**
* Reply to this message. If the message was sent specifying a reply handler, that handler will be
* called when it has received a reply. If the message wasn't sent specifying a receipt handler
* this method does nothing.
*/
void reply(Float message);
/**
* Reply to this message. If the message was sent specifying a reply handler, that handler will be
* called when it has received a reply. If the message wasn't sent specifying a receipt handler
* this method does nothing.
*/
void reply(Double message);
/**
* The same as {@code reply()} but you can specify handler for the reply - i.e.
* to receive the reply to the reply.
*/
void reply(Handler> replyHandler);
/**
* Reply to this message. Specifying a timeout and a reply handler
*/
void replyWithTimeout(long timeout, Handler>> replyHandler);
/**
* The same as {@code reply(JsonObject message)} but you can specify handler for the reply - i.e.
* to receive the reply to the reply.
*/
void reply(Object message, Handler> replyHandler);
/**
* Reply to this message. Specifying a timeout and a reply handler
*/
void replyWithTimeout(Object message, long timeout, Handler>> replyHandler);
/**
* The same as {@code reply(JsonObject message)} but you can specify handler for the reply - i.e.
* to receive the reply to the reply.
*/
void reply(JsonObject message, Handler> replyHandler);
/**
* Reply to this message. Specifying a timeout and a reply handler
*/
void replyWithTimeout(JsonObject message, long timeout, Handler>> replyHandler);
/**
* The same as {@code reply(JsonArray message)} but you can specify handler for the reply - i.e.
* to receive the reply to the reply.
*/
void reply(JsonArray message, Handler> replyHandler);
/**
* Reply to this message. Specifying a timeout and a reply handler
*/
void replyWithTimeout(JsonArray message, long timeout, Handler>> replyHandler);
/**
* The same as {@code reply(String message)} but you can specify handler for the reply - i.e.
* to receive the reply to the reply.
*/
void reply(String message, Handler> replyHandler);
/**
* Reply to this message. Specifying a timeout and a reply handler
*/
void replyWithTimeout(String message, long timeout, Handler>> replyHandler);
/**
* The same as {@code reply(Buffer message)} but you can specify handler for the reply - i.e.
* to receive the reply to the reply.
*/
void reply(Buffer message, Handler> replyHandler);
/**
* Reply to this message. Specifying a timeout and a reply handler
*/
void replyWithTimeout(Buffer message, long timeout, Handler>> replyHandler);
/**
* The same as {@code reply(byte[] message)} but you can specify handler for the reply - i.e.
* to receive the reply to the reply.
*/
void reply(byte[] message, Handler> replyHandler);
/**
* Reply to this message. Specifying a timeout and a reply handler
*/
void replyWithTimeout(byte[] message, long timeout, Handler>> replyHandler);
/**
* The same as {@code reply(Integer message)} but you can specify handler for the reply - i.e.
* to receive the reply to the reply.
*/
void reply(Integer message, Handler> replyHandler);
/**
* Reply to this message. Specifying a timeout and a reply handler
*/
void replyWithTimeout(Integer message, long timeout, Handler>> replyHandler);
/**
* The same as {@code reply(Long message)} but you can specify handler for the reply - i.e.
* to receive the reply to the reply.
*/
void reply(Long message, Handler> replyHandler);
/**
* Reply to this message. Specifying a timeout and a reply handler
*/
void replyWithTimeout(Long message, long timeout, Handler>> replyHandler);
/**
* The same as {@code reply(Short message)} but you can specify handler for the reply - i.e.
* to receive the reply to the reply.
*/
void reply(Short message, Handler> replyHandler);
/**
* Reply to this message. Specifying a timeout and a reply handler
*/
void replyWithTimeout(Short message, long timeout, Handler>> replyHandler);
/**
* The same as {@code reply(Character message)} but you can specify handler for the reply - i.e.
* to receive the reply to the reply.
*/
void reply(Character message, Handler> replyHandler);
/**
* Reply to this message. Specifying a timeout and a reply handler
*/
void replyWithTimeout(Character message, long timeout, Handler>> replyHandler);
/**
* The same as {@code reply(Boolean message)} but you can specify handler for the reply - i.e.
* to receive the reply to the reply.
*/
void reply(Boolean message, Handler> replyHandler);
/**
* Reply to this message. Specifying a timeout and a reply handler
*/
void replyWithTimeout(Boolean message, long timeout, Handler>> replyHandler);
/**
* The same as {@code reply(Float message)} but you can specify handler for the reply - i.e.
* to receive the reply to the reply.
*/
void reply(Float message, Handler> replyHandler);
/**
* Reply to this message. Specifying a timeout and a reply handler
*/
void replyWithTimeout(Float message, long timeout, Handler>> replyHandler);
/**
* The same as {@code reply(Double message)} but you can specify handler for the reply - i.e.
* to receive the reply to the reply.
*/
void reply(Double message, Handler> replyHandler);
/**
* Reply to this message. Specifying a timeout and a reply handler
*/
void replyWithTimeout(Double message, long timeout, Handler>> replyHandler);
/**
* Signal that processing of this message failed. If the message was sent specifying a result handler
* the handler will be called with a failure corresponding to the failure code and message specified here
*
* @param failureCode A failure code to pass back to the sender
* @param message A message to pass back to the sender
*/
void fail(int failureCode, String message);
}