@GET
    @Path("subscribeAndUsingExternalThread")
    @Suspend(resumeOnBroadcast = true, listeners = {EventsLogger.class})
    public String subscribeAndResumeUsingExternalThread(final @PathParam("topic") String topic) {
        Executors.newSingleThreadExecutor().submit(new Runnable() {
            public void run() {
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                }
                broadcaster.getBroadcasterConfig().getAtmosphereConfig().getBroadcasterFactory()
                        .lookup(JerseyBroadcaster.class, topic).broadcast("\nEcho: " + topic);
            }
        });
        return "foo";
    }
@ GET @ Path ( "subscribeAndUsingExternalThread" ) @ Suspend ( resumeOnBroadcast = true , listeners = { EventsLogger . class } ) public String subscribeAndResumeUsingExternalThread ( final @ PathParam ( "topic" ) String topic ) { Executors . newSingleThreadExecutor ( ) . submit ( new Runnable ( ) { public void run ( ) { try { Thread . sleep ( 5000 ) ; } catch ( InterruptedException e ) { } broadcaster . getBroadcasterConfig ( ) . getAtmosphereConfig ( ) . getBroadcasterFactory ( ) . lookup ( JerseyBroadcaster . class , topic ) . broadcast ( "\nEcho: " + topic ) ; } } ) ; return "foo" ; }
Suspend the response, and register a {@link AtmosphereResourceEventListener}
that get notified when events occurs like client disconnection, broadcast
or when the response get resumed.

@return A {@link Broadcastable} used to broadcast events.