/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.catalina.tribes.demos; import java.io.Serializable; import org.apache.catalina.tribes.Channel; import org.apache.catalina.tribes.ManagedChannel; import org.apache.catalina.tribes.Member; import org.apache.catalina.tribes.group.Response; import org.apache.catalina.tribes.group.RpcCallback; import org.apache.catalina.tribes.group.RpcChannel; public class EchoRpcTest implements RpcCallback, Runnable { Channel channel; int count; String message; long pause; RpcChannel rpc; int options; long timeout; String name; public EchoRpcTest(Channel channel, String name, int count, String message, long pause, int options, long timeout) { this.channel = channel; this.count = count; this.message = message; this.pause = pause; this.options = options; this.rpc = new RpcChannel(name.getBytes(),channel,this); this.timeout = timeout; this.name = name; } /** * If the reply has already been sent to the requesting thread, the rpc * callback can handle any data that comes in after the fact. * * @param msg Serializable * @param sender Member */ @Override public void leftOver(Serializable msg, Member sender) { System.out.println("Received a left over message from ["+sender.getName()+"] with data ["+msg+"]"); } /** * * @param msg Serializable * @param sender Member * @return Serializable - null if no reply should be sent */ @Override public Serializable replyRequest(Serializable msg, Member sender) { System.out.println("Received a reply request message from ["+sender.getName()+"] with data ["+msg+"]"); return "Reply("+name+"):"+msg; } @Override public void run() { long counter = 0; while (counter