Example #1
0
 /**
  * Asynchronous event publication service for requestSync().
  *
  * <p>requestSync() turns into this method via RemoteMessageTransport.
  *
  * <p>Remote objects uses this method to publish a request as event asynchronously.
  *
  * <p>Although this method is asynchronous, {@link RemoteTransactions} provides a synchronous
  * method to wait for a response from another remote object.
  */
 protected void publishRequestAsync(final int sno, final Request request) throws IOException {
   BufferPacker pk = msgpack.createBufferPacker();
   // write delivery header.
   pk.write(TYPE_REQUEST);
   pk.write(sno);
   pk.write(getSourceDispatcherId());
   // write delivery body.
   pk.write(request);
   byte[] message = pk.toByteArray();
   String channel = request.objectId;
   // PUBLISH
   driverImpl.publish(channel, message);
   if (log.isDebugEnabled()) {
     log.debug(
         "Request sent:\n"
             + "  MessageDispatcher: {}\n"
             + "  sno: {}\n"
             + "  channel: {}\n"
             + "  method: {}\n"
             + "  objectId: {}\n"
             + "  path: /{}/\n"
             + "  body: {}",
         sourceDispatcherId,
         sno,
         channel,
         request.method,
         request.objectId,
         request.path,
         request.getBodyValue());
   }
 }
Example #2
0
 /**
  * Asynchronous event publication service for requestSync().
  *
  * <p>The response eventually reaches its originating method (requestSync()) via
  * RemoteMessageTransport.
  */
 public void publishResponseAsync(
     final int sno, final String channel, final Request request, final Response response)
     throws IOException {
   BufferPacker pk = msgpack.createBufferPacker();
   // write delivery header.
   pk.write(TYPE_RESPONSE);
   pk.write(sno);
   pk.write(request.objectId);
   // write delivery body.
   pk.write(response);
   byte[] message = pk.toByteArray();
   // PUBLISH
   driverImpl.publish(channel, message);
   if (log.isDebugEnabled()) {
     log.debug(
         "Response returned:\n"
             + "  MessageDispatcher: {}\n"
             + "  channel: {}\n"
             + "  statusCode: {}\n"
             + "  body: {}",
         sourceDispatcherId,
         channel,
         response.statusCode,
         response.getBodyValue());
   }
 }
Example #3
0
 /**
  * Asynchronous event publication service
  *
  * <p>Remote objects use this method to publish an event asynchronously.
  */
 public void publishEventAsync(final Event event) throws IOException {
   BufferPacker pk = msgpack.createBufferPacker();
   // write delivery header.
   pk.write(TYPE_EVENT);
   pk.write(0);
   pk.write("event");
   // write delivery body.
   pk.write(event);
   byte[] message = pk.toByteArray();
   String channel = channelString(event.publisherId, event.eventType);
   // PUBLISH
   driverImpl.publish(channel, message);
   if (log.isDebugEnabled()) {
     log.debug(
         "Event sent:\n" + "  MessageDispatcher: {}\n" + "  channel: {}\n" + "  body: {}",
         sourceDispatcherId,
         channel,
         event.getBodyValue());
   }
 }