[jboss-user] [Remoting] - Remoting 3 trunk - Ordered delivery problem

barbacena do-not-reply at jboss.com
Tue Sep 16 01:16:50 EDT 2008


Hi,

I am new to remoting project but I am trying the trunk remoting 3 and I am stuck with a unordered delivery of messages in a example derived from samples subproject. Am I doing something wrong or do I need to control this behavior?

My code:
public final class LocalBasicExampleMain {
  | 
  | 	public static void main(String[] args) throws IOException, RemoteExecutionException {
  | 		Integer value = 1;
  | 		Security.addProvider(new Provider());
  | 		RequestListener<Object, Integer> listener = new AbstractRequestListener<Object, Integer>() {
  | 			@Override
  | 			public void handleRequest(RequestContext<Integer> context, final Object request) throws RemoteExecutionException {
  | 				System.out.println("Remote: " + request);
  | 				context.execute(new Runnable() {
  | 					@Override
  | 					public void run() {
  | 						System.out.println("Executing... " + request);
  | 					}
  | 				});
  | 				try {
  | 					context.sendReply(Integer.valueOf(request.toString().substring(0,1)));
  | 				} catch (IOException e) {
  | 					throw new RemoteExecutionException("Failed to send.", e);
  | 				}
  | 			}
  | 		};
  | 		final Endpoint endpoint = Remoting.createEndpoint("simple");
  | 		Client<Object, Integer> client = null;
  | 		try {
  | 			client = Remoting.createLocalClient(endpoint, listener);
  | 			System.out.printf("Local: %s message\n", client.invoke(value++ + " message"));
  | 			System.out.printf("Local: %s message\n", client.invoke(value++ + " message"));
  | 			client.sendOneWay(value++ + " message");
  | 			final IoFuture<Integer> resposta = client.send(value++ + " message");
  | 			System.out.println("Got future: " + resposta.getStatus());
  | 			resposta.addNotifier(new Notifier<Integer>() {
  | 				@Override
  | 				public void notify(IoFuture<Integer> future) {
  | 					System.out.println("Inside notifier " + future.getStatus());
  | 					try {
  | 						System.out.printf("Local: %d mensagem\n", future.get());
  | 					} catch (IOException e) {
  | 						e.printStackTrace();
  | 					}
  | 				}
  | 			});
  | 			client.addCloseHandler(new CloseHandler<Client<Object, Integer>>() {
  | 				@Override
  | 				public void handleClose(Client<Object, Integer> closed) {
  | 					while (resposta.getStatus() != Status.WAITING);
  | 				}
  | 			});
  | 		} finally {
  | 			IoUtils.safeClose(client);
  | //			Remoting.closeEndpoint(endpoint);
  | 		}
  | 	}
  | 
  | }

When you execute you sometimes get:

Remote: 1 message
  | Executing... 1 message
  | Local: 1 message
  | Remote: 2 message
  | Executing... 2 message
  | Local: 2 message
  | Got future: WAITING
  | Remote: 4 message
  | Remote: 3 message
  | Executing... 3 message
  | Executing... 4 message
  | Inside notifier DONE
  | Local: 4 mensagem

And sometimes you get:

Remote: 1 message
  | Executing... 1 message
  | Local: 1 message
  | Remote: 2 message
  | Executing... 2 message
  | Local: 2 message
  | Remote: 3 message
  | Remote: 4 message
  | Got future: WAITING
  | Executing... 3 message
  | Executing... 4 message
  | Inside notifier DONE
  | Local: 4 mensagem

The last output is the behavior that I was waiting always.

ps.: great project but please improve the build. I could only play with it after 4 hours trying to find the right jars. (I can contribute with a maven2 build)
pss: it isn't working with 1.0.0.ga xnio. Is that right?
psss: I am receiving a log warn saying that the client is leaking. What is it?
pssss: Sometimes I am getting this exception:

Exception in thread "Remoting endpoint pool-1-thread-5" java.util.concurrent.RejectedExecutionException
  | 	at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:1759)
  | 	at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:767)
  | 	at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:658)
  | 	at org.jboss.xnio.AbstractIoFuture.runNotifier(AbstractIoFuture.java:298)
  | 	at org.jboss.xnio.AbstractIoFuture.runAllNotifiers(AbstractIoFuture.java:217)
  | 	at org.jboss.xnio.AbstractIoFuture.setResult(AbstractIoFuture.java:255)
  | 	at org.jboss.cx.remoting.core.FutureReplyImpl.access$100(FutureReplyImpl.java:35)
  | 	at org.jboss.cx.remoting.core.FutureReplyImpl$Handler.handleReply(FutureReplyImpl.java:67)
  | 	at org.jboss.cx.remoting.core.RequestContextImpl.sendReply(RequestContextImpl.java:74)
  | 	at org.jboss.cx.remoting.samples.simple.LocalBasicExampleMain$1$1.run(LocalBasicExampleMain.java:36)
  | 	at org.jboss.cx.remoting.core.util.TaggingExecutor$Task.run(TaggingExecutor.java:53)
  | 	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:885)
  | 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:907)
  | 	at java.lang.Thread.run(Thread.java:619)

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4176667#4176667

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4176667



More information about the jboss-user mailing list