Runtime exception in callback prevents subsequent publish

6 views
Skip to first unread message

Abraham Menacherry

unread,
Apr 27, 2011, 3:58:09 AM4/27/11
to jetlang-dev
Hi,

If a callback throws a runtime exception, then any subsequent calls to
channel.publish does not invoke the callback. Is this the expected
behavior? Or am I doing something wrong. Is there any work around to
"re-start" the fiber in such scenario?

Code snippet:
final CountDownLatch latch = new CountDownLatch(2);
Fiber fiber = new ThreadFiber();
fiber.start();
MemoryChannel<Integer> channel = new MemoryChannel<Integer>();
Callback<Integer> exceptionCallBack = new Callback<Integer>()
{
@Override
public void onMessage(Integer message)
{
System.out.println("received " + message);
latch.countDown();
throw new NullPointerException();
}
};

channel.subscribe(fiber,exceptionCallBack);
channel.publish(1);// throws the NPE as expected

//Any futher calls to publish has no effect, it is not getting picked
up, no more NPE's get thrown

channel.publish(2);// No effect

Thanks,
Abraham.

peter royal

unread,
Apr 27, 2011, 7:41:49 PM4/27/11
to jetla...@googlegroups.com
you will want to implement a http://jetlang.googlecode.com/svn/site/apidocs/org/jetlang/core/BatchExecutor.html that implements your desired exception handling policy.

-pete

--
(peter.royal|osi)@pobox.com - http://fotap.org/~osi

> --
> You received this message because you are subscribed to the Google Groups "jetlang-dev" group.
> To post to this group, send email to jetla...@googlegroups.com.
> To unsubscribe from this group, send email to jetlang-dev...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/jetlang-dev?hl=en.
>

Abraham Menacherry

unread,
Apr 28, 2011, 3:06:38 AM4/28/11
to jetlang-dev
pete,

Thanks for the tip.

On Apr 28, 4:41 am, peter royal <peter.ro...@pobox.com> wrote:
> you will want to implement ahttp://jetlang.googlecode.com/svn/site/apidocs/org/jetlang/core/Batch...that implements your desired exception handling policy.
>
> -pete
>
> --
> (peter.royal|osi)@pobox.com -http://fotap.org/~osi
> > For more options, visit this group athttp://groups.google.com/group/jetlang-dev?hl=en.- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages