{
String remoteEndpoint = "vm://remote.queue?connector=vmRemoteQueueConnector";
// Will connect to the server using The Server endpoint
MuleClient client = new MuleClient(muleContext);
RemoteDispatcher dispatcher = client.getRemoteDispatcher(getRemoteEndpointUri());
// Doubling timeout see MULE-3000
// Use TIMEOUT_NOT_SET_VALUE as we need respective remoteDispatcherEndpoint to you timeout as defined on the endpoint.
MuleMessage message = dispatcher.receiveRemote(remoteEndpoint,MuleEvent.TIMEOUT_NOT_SET_VALUE);
assertNull(message);
// We do a send instead of a dispatch here so the operation is
// synchronous thus eaiser to test
dispatcher.sendRemote(remoteEndpoint, "Test Remote Message 2", null);
// Doubling timeout see MULE-3000
message = dispatcher.receiveRemote(remoteEndpoint, RECEIVE_TIMEOUT * 2);
assertNotNull(message);
assertEquals("Test Remote Message 2", message.getPayload());
}