Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jaxrs-dev] [Proposal] Provide another non blocking open() in EventSource

Hi Jim,


The Javadoc isn't clear about blocking/non-blocking behavior but I assume it's already non-blocking.


The method "register" allows specifying a callback for all events, not only for a failure.


But I agree that a handler for onopen is missing, it's only possible to listen to events that may not even come.


I've raised an issue to clarify and enhance this: https://github.com/eclipse-ee4j/jaxrs-api/issues/625


Cheers,

Ondrej Mihályi

Senior Payara Service Engineer
Payara Server – Robust. Reliable. Supported.
E: ondrej.mihalyi@xxxxxxxxxxx | T: +1 415 523 0175 | M: +421 902 079 891

----------------------------------------------------------------------------------------------------------------------

Payara Services Limited, Registered office: Unit 11, Malvern Hills Science Park, Geraldine Road, Malvern, WR14 3SZ
Registered in England and Wales: 09998946 | www.payara.fish | info@xxxxxxxxxxx |
@Payara_Fish


From: jaxrs-dev-bounces@xxxxxxxxxxx <jaxrs-dev-bounces@xxxxxxxxxxx> on behalf of Jim Ma <ema@xxxxxxxxxx>
Sent: 26 April 2018 12:17:46
To: jaxrs developer discussions
Subject: [jaxrs-dev] [Proposal] Provide another non blocking open() in EventSource
 
If understand the EventSource#open() correctly, it should wait the connection is established and return. 

/*
 * Open the connection to the supplied SSE underlying {@link WebTarget web target} and start processing incoming
 * {@link InboundSseEvent events}.
 *
 * @throws IllegalStateException in case the event source has already been opened earlier.
 */
void open();

There is already error consumer can be registered to EventSource and user can get exception thrown from open() with that handler.
We can provide another non-blocking open method and allow user not to wait the connection and do the following things like send another request :

eventSource.open(nonBlocking); 
client.target("http://foo.bar/test").request().post(Entity.entity("msg", MediaType.TEXT_PLAIN_TYPE));

WDYT ?

Cheers,
Jim

Back to the top