Search in sources :

Example 31 with RequestOptions

use of org.jgroups.blocks.RequestOptions in project JGroups by belaban.

the class MessageDispatcherRSVPTest method sendMessageOnClosedChannel.

protected void sendMessageOnClosedChannel(Address dest, Message.Flag... flags) throws Exception {
    RequestOptions opts = RequestOptions.SYNC().timeout(2000).flags(flags);
    byte[] data = "bla".getBytes();
    ByteArray buf = new ByteArray(data, 0, data.length);
    channels[0].close();
    try {
        if (dest == null) {
            // multicast
            Address dst = channels[1].getAddress();
            dispatchers[0].castMessage(Collections.singleton(dst), new BytesMessage(dst, buf), opts);
        } else
            dispatchers[0].sendMessage(new BytesMessage(dest, buf), opts);
        assert false : "sending the message on a closed channel should have thrown an exception";
    } catch (IllegalStateException t) {
        System.out.println("received \"" + t + "\" as expected");
    }
}
Also used : RequestOptions(org.jgroups.blocks.RequestOptions) ByteArray(org.jgroups.util.ByteArray)

Aggregations

RequestOptions (org.jgroups.blocks.RequestOptions)31 MethodCall (org.jgroups.blocks.MethodCall)15 Rsp (org.jgroups.util.Rsp)10 RpcDispatcher (org.jgroups.blocks.RpcDispatcher)8 IOException (java.io.IOException)7 CancellationException (java.util.concurrent.CancellationException)4 ExecutionException (java.util.concurrent.ExecutionException)4 TimeoutException (java.util.concurrent.TimeoutException)4 BytesMessage (org.jgroups.BytesMessage)4 Message (org.jgroups.Message)4 MessageDispatcher (org.jgroups.blocks.MessageDispatcher)4 ResponseMode (org.jgroups.blocks.ResponseMode)4 RspList (org.jgroups.util.RspList)4 Map (java.util.Map)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 org.jgroups (org.jgroups)3 Address (org.jgroups.Address)3 CommandDispatcherException (org.wildfly.clustering.dispatcher.CommandDispatcherException)3 Method (java.lang.reflect.Method)2 InetAddress (java.net.InetAddress)2