public static void sendAsynchronously( Message message, RemoteEndpoint remoteEndpoint )
			throws IOException {

		Future<Void> fut = null;
		Exception exception = null;
		try {
			byte[] rawData = SerializationUtils.serializeObject( message );
			ByteBuffer data = ByteBuffer.wrap( rawData );
			fut = remoteEndpoint.sendBytesByFuture( data );

			// Wait for completion (timeout)
			fut.get( 8, TimeUnit.SECONDS );

		} catch( ExecutionException | InterruptedException e ) {
			exception = e;

		} catch( TimeoutException e ) {
			exception = e;
			final Logger logger = Logger.getLogger( HttpUtils.class.getName());
			logger.warning( "A message could not be sent to a remote end-point (HTTP messaging). Sending timed out." );

			// FIXME: should we send the message once again?
			if( fut != null )
				fut.cancel(true);

		} finally {
			if( exception != null )
				throw new IOException( exception );
		}
	}
public static void sendAsynchronously ( Message message , RemoteEndpoint remoteEndpoint ) throws IOException { Future < Void > fut = null ; Exception exception = null ; try { byte [ ] rawData = SerializationUtils . serializeObject ( message ) ; ByteBuffer data = ByteBuffer . wrap ( rawData ) ; fut = remoteEndpoint . sendBytesByFuture ( data ) ; fut . get ( 8 , TimeUnit . SECONDS ) ; } catch ( ExecutionException | InterruptedException e ) { exception = e ; } catch ( TimeoutException e ) { exception = e ; final Logger logger = Logger . getLogger ( HttpUtils . class . getName ( ) ) ; logger . warning ( "A message could not be sent to a remote end-point (HTTP messaging). Sending timed out." ) ; if ( fut != null ) fut . cancel ( true ) ; } finally { if ( exception != null ) throw new IOException ( exception ) ; } }
Sends a message asynchronously to a remote end point.
<p>
Asynchronous sending is necessary since we may have several threads that
use the same messaging client. Blocking sending may result in issues such
as #598.
</p>

@param message the message to send
@param remoteEndpoint the remote end-point
@throws IOException if something went wrong