You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "John D. Ament" <jo...@apache.org> on 2017/09/17 20:21:54 UTC

Does SSE + CDI work?

I'm trying to create a very basic example of using SSE + CDI events.  To do
that, I created a basic endpoint based on a CXF systest that I found, but
tried to adapt it to work with CDI.

@Path("/sse")
@RequestScoped
public class SseEventEndpoint {
    @Inject
    private Event<SseEvent> event;
    @Context
    private Sse sse;
    @GET
    @Path("{connectionId}")
    @Produces(MediaType.SERVER_SENT_EVENTS)
    public void onEvent(@Context SseEventSink sink,
@PathParam("connectionId") final String id) {
        System.out.println("Received request "+sse);
        event.fireAsync(new SseEvent(sink, sse, id));
    }
}

However, no matter what I do, the Sse object is null.  Is there something I
need to do to enable Sse integration?  This is what my dependencies look
like

        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-integration-cdi</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-rs-client</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-rs-sse</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
        </dependency>

Re: Does SSE + CDI work?

Posted by Andriy Redko <re...@apache.org>.
Sorry for delayed response, somehow missed this thread. Yes, we should be able to discover features automatically when using CDI. The @Provider may not be required, we rely on javax.ws.rs.core.Feature implementors instead. But John is right, in the sample the SseFeature is manually registered (but transport part is tuned from the extension). I will look into the issue shortly.

On 2017-09-18 03:36, Sergey Beryozkin <sb...@gmail.com> wrote: 
> Ok, I added
> @Provider(value = Type.Feature, scope = Scope.Server)
> 
> Andriy, will CXF CDI auto-discover it now or will it have to be updated 
> a bit to have CXF features/interceptors picked up, same way we can do it 
> for Spring ?
> 
> Thanks, Sergey
> On 18/09/17 11:27, Sergey Beryozkin wrote:
> > On 18/09/17 11:14, John D. Ament wrote:
> >> I'm assuming you mean
> >> https://github.com/apache/cxf/blob/master/distribution/src/main/release/samples/jax_rs/sse_cdi/src/main/java/demo/jaxrs/sse/StatsApplication.java#L39 
> >>
> >> ?
> >> That looks manually registered.
> > It should not be there,
> > 
> > we need to add a CXF @Provider(type=Feature) to
> > 
> > https://github.com/apache/cxf/blob/master/rt/rs/sse/src/main/java/org/apache/cxf/jaxrs/sse/SseFeature.java 
> > 
> > 
> >>
> >> For my #1 its a CDI 2.0 feature.  I think it'll work with this approach
> >> though.
> >>
> >> Any thoughts on the instability?
> > Well, it's a totally new feature. I know Andriy found some issues while 
> > working on the integration with Atmosphere, my understanding there were 
> > many timing related test issues, but what is more important is how it 
> > works once the server is up an running, for a regular application, is 
> > not stable in your case ?
> > 
> > Sergey
> >>
> >> John
> >>
> >> On Mon, Sep 18, 2017 at 5:09 AM Sergey Beryozkin <sb...@gmail.com>
> >> wrote:
> >>
> >>> Have a look at the sse cdi demo Andriy added to the distribution,
> >>> the feature (the one dealing with SSE) is expected to be 
> >>> auto-registered.
> >>>
> >>> Re the transport id, by default CXF assumes it is 'plain' HTTP, so it
> >>> needs a hint.
> >>>
> >>> What did you mean with 1) ?
> >>>
> >>> Sergey
> >>>
> >>> On 18/09/17 00:57, John D. Ament wrote:
> >>>> Ok, i was able to work a bit deeper into this.
> >>>>
> >>>> 1. the integration works, but firing async events doesn't work.  I'm 
> >>>> not
> >>>> sure it should, since you're just appending to the request; but I 
> >>>> want to
> >>>> play with async requests a bit.
> >>>>
> >>>> 2. The integration seems flakey I'm afraid.  I'll run a test, almost
> >>> always
> >>>> it passes, but then every off test run will cause SSE to not get
> >>>> activated.  I have no reproducer for this.
> >>>>
> >>>> When it does fail, all I get on the log is
> >>>>
> >>>> Sep 17, 2017 7:50:33 PM
> >>> org.apache.cxf.transport.servlet.ServletController
> >>>> invoke
> >>>> WARNING: Can't find the request for http://my-hostname:4403/rest's
> >>> Observer
> >>>>
> >>>> However, I see none of the atmosphere bootstrap occurring when this
> >>>> happens.  Here's full logs for both failure and success:
> >>>> https://paste.apache.org/rWwj
> >>>>
> >>>> 3. I had to manually install the feature.  Does CXF have any notion of
> >>>> automatically registering features?
> >>>>
> >>>> 4. I also had to customize the transport id.  It would be good if this
> >>> was
> >>>> automatic.
> >>>>
> >>>> John
> >>>>
> >>>> On Sun, Sep 17, 2017 at 4:21 PM John D. Ament <jo...@apache.org>
> >>> wrote:
> >>>>
> >>>>> I'm trying to create a very basic example of using SSE + CDI 
> >>>>> events.  To
> >>>>> do that, I created a basic endpoint based on a CXF systest that I 
> >>>>> found,
> >>>>> but tried to adapt it to work with CDI.
> >>>>>
> >>>>> @Path("/sse")
> >>>>> @RequestScoped
> >>>>> public class SseEventEndpoint {
> >>>>>       @Inject
> >>>>>       private Event<SseEvent> event;
> >>>>>       @Context
> >>>>>       private Sse sse;
> >>>>>       @GET
> >>>>>       @Path("{connectionId}")
> >>>>>       @Produces(MediaType.SERVER_SENT_EVENTS)
> >>>>>       public void onEvent(@Context SseEventSink sink,
> >>>>> @PathParam("connectionId") final String id) {
> >>>>>           System.out.println("Received request "+sse);
> >>>>>           event.fireAsync(new SseEvent(sink, sse, id));
> >>>>>       }
> >>>>> }
> >>>>>
> >>>>> However, no matter what I do, the Sse object is null.  Is there
> >>> something
> >>>>> I need to do to enable Sse integration?  This is what my dependencies
> >>> look
> >>>>> like
> >>>>>
> >>>>>           <dependency>
> >>>>>               <groupId>org.apache.cxf</groupId>
> >>>>>               <artifactId>cxf-integration-cdi</artifactId>
> >>>>>           </dependency>
> >>>>>           <dependency>
> >>>>>               <groupId>org.apache.cxf</groupId>
> >>>>>               <artifactId>cxf-rt-rs-client</artifactId>
> >>>>>           </dependency>
> >>>>>           <dependency>
> >>>>>               <groupId>org.apache.cxf</groupId>
> >>>>>               <artifactId>cxf-rt-rs-sse</artifactId>
> >>>>>           </dependency>
> >>>>>           <dependency>
> >>>>>               <groupId>org.apache.cxf</groupId>
> >>>>>               <artifactId>cxf-rt-transports-http</artifactId>
> >>>>>           </dependency>
> >>>>>
> >>>>
> >>>
> >>>
> >>> -- 
> >>> Sergey Beryozkin
> >>>
> >>> Talend Community Coders
> >>> http://coders.talend.com/
> >>>
> >>
> 
> 
> -- 
> Sergey Beryozkin
> 
> Talend Community Coders
> http://coders.talend.com/
> 

Re: Does SSE + CDI work?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Ok, I added
@Provider(value = Type.Feature, scope = Scope.Server)

Andriy, will CXF CDI auto-discover it now or will it have to be updated 
a bit to have CXF features/interceptors picked up, same way we can do it 
for Spring ?

Thanks, Sergey
On 18/09/17 11:27, Sergey Beryozkin wrote:
> On 18/09/17 11:14, John D. Ament wrote:
>> I'm assuming you mean
>> https://github.com/apache/cxf/blob/master/distribution/src/main/release/samples/jax_rs/sse_cdi/src/main/java/demo/jaxrs/sse/StatsApplication.java#L39 
>>
>> ?
>> That looks manually registered.
> It should not be there,
> 
> we need to add a CXF @Provider(type=Feature) to
> 
> https://github.com/apache/cxf/blob/master/rt/rs/sse/src/main/java/org/apache/cxf/jaxrs/sse/SseFeature.java 
> 
> 
>>
>> For my #1 its a CDI 2.0 feature.  I think it'll work with this approach
>> though.
>>
>> Any thoughts on the instability?
> Well, it's a totally new feature. I know Andriy found some issues while 
> working on the integration with Atmosphere, my understanding there were 
> many timing related test issues, but what is more important is how it 
> works once the server is up an running, for a regular application, is 
> not stable in your case ?
> 
> Sergey
>>
>> John
>>
>> On Mon, Sep 18, 2017 at 5:09 AM Sergey Beryozkin <sb...@gmail.com>
>> wrote:
>>
>>> Have a look at the sse cdi demo Andriy added to the distribution,
>>> the feature (the one dealing with SSE) is expected to be 
>>> auto-registered.
>>>
>>> Re the transport id, by default CXF assumes it is 'plain' HTTP, so it
>>> needs a hint.
>>>
>>> What did you mean with 1) ?
>>>
>>> Sergey
>>>
>>> On 18/09/17 00:57, John D. Ament wrote:
>>>> Ok, i was able to work a bit deeper into this.
>>>>
>>>> 1. the integration works, but firing async events doesn't work.  I'm 
>>>> not
>>>> sure it should, since you're just appending to the request; but I 
>>>> want to
>>>> play with async requests a bit.
>>>>
>>>> 2. The integration seems flakey I'm afraid.  I'll run a test, almost
>>> always
>>>> it passes, but then every off test run will cause SSE to not get
>>>> activated.  I have no reproducer for this.
>>>>
>>>> When it does fail, all I get on the log is
>>>>
>>>> Sep 17, 2017 7:50:33 PM
>>> org.apache.cxf.transport.servlet.ServletController
>>>> invoke
>>>> WARNING: Can't find the request for http://my-hostname:4403/rest's
>>> Observer
>>>>
>>>> However, I see none of the atmosphere bootstrap occurring when this
>>>> happens.  Here's full logs for both failure and success:
>>>> https://paste.apache.org/rWwj
>>>>
>>>> 3. I had to manually install the feature.  Does CXF have any notion of
>>>> automatically registering features?
>>>>
>>>> 4. I also had to customize the transport id.  It would be good if this
>>> was
>>>> automatic.
>>>>
>>>> John
>>>>
>>>> On Sun, Sep 17, 2017 at 4:21 PM John D. Ament <jo...@apache.org>
>>> wrote:
>>>>
>>>>> I'm trying to create a very basic example of using SSE + CDI 
>>>>> events.  To
>>>>> do that, I created a basic endpoint based on a CXF systest that I 
>>>>> found,
>>>>> but tried to adapt it to work with CDI.
>>>>>
>>>>> @Path("/sse")
>>>>> @RequestScoped
>>>>> public class SseEventEndpoint {
>>>>>       @Inject
>>>>>       private Event<SseEvent> event;
>>>>>       @Context
>>>>>       private Sse sse;
>>>>>       @GET
>>>>>       @Path("{connectionId}")
>>>>>       @Produces(MediaType.SERVER_SENT_EVENTS)
>>>>>       public void onEvent(@Context SseEventSink sink,
>>>>> @PathParam("connectionId") final String id) {
>>>>>           System.out.println("Received request "+sse);
>>>>>           event.fireAsync(new SseEvent(sink, sse, id));
>>>>>       }
>>>>> }
>>>>>
>>>>> However, no matter what I do, the Sse object is null.  Is there
>>> something
>>>>> I need to do to enable Sse integration?  This is what my dependencies
>>> look
>>>>> like
>>>>>
>>>>>           <dependency>
>>>>>               <groupId>org.apache.cxf</groupId>
>>>>>               <artifactId>cxf-integration-cdi</artifactId>
>>>>>           </dependency>
>>>>>           <dependency>
>>>>>               <groupId>org.apache.cxf</groupId>
>>>>>               <artifactId>cxf-rt-rs-client</artifactId>
>>>>>           </dependency>
>>>>>           <dependency>
>>>>>               <groupId>org.apache.cxf</groupId>
>>>>>               <artifactId>cxf-rt-rs-sse</artifactId>
>>>>>           </dependency>
>>>>>           <dependency>
>>>>>               <groupId>org.apache.cxf</groupId>
>>>>>               <artifactId>cxf-rt-transports-http</artifactId>
>>>>>           </dependency>
>>>>>
>>>>
>>>
>>>
>>> -- 
>>> Sergey Beryozkin
>>>
>>> Talend Community Coders
>>> http://coders.talend.com/
>>>
>>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Re: Does SSE + CDI work?

Posted by "John D. Ament" <jo...@apache.org>.
On Mon, Sep 18, 2017 at 7:01 AM John D. Ament <jo...@apache.org> wrote:

> On Mon, Sep 18, 2017 at 6:27 AM Sergey Beryozkin <sb...@gmail.com>
> wrote:
>
>> On 18/09/17 11:14, John D. Ament wrote:
>> > I'm assuming you mean
>> >
>> https://github.com/apache/cxf/blob/master/distribution/src/main/release/samples/jax_rs/sse_cdi/src/main/java/demo/jaxrs/sse/StatsApplication.java#L39
>> > ?
>> > That looks manually registered.
>> It should not be there,
>>
>> we need to add a CXF @Provider(type=Feature) to
>>
>>
>> https://github.com/apache/cxf/blob/master/rt/rs/sse/src/main/java/org/apache/cxf/jaxrs/sse/SseFeature.java
>>
>> >
>> > For my #1 its a CDI 2.0 feature.  I think it'll work with this approach
>> > though.
>> >
>> > Any thoughts on the instability?
>> Well, it's a totally new feature. I know Andriy found some issues while
>> working on the integration with Atmosphere, my understanding there were
>> many timing related test issues, but what is more important is how it
>> works once the server is up an running, for a regular application, is
>> not stable in your case ?
>>
>
> I have to test it that way further.  I'm doing everything via automation,
> but need to run a sample app to check.  My main concern is stability within
> my own pipeline by simply enabling this flag.
>

Ok, so good news (kind of?).  I use capsule packaging, and when using
capsule it works OK, not able to replicate the problem.  However, the fact
that automation fails is concerning.

Any ideas on what the race condition may be?


>
>
>>
>> Sergey
>> >
>> > John
>> >
>> > On Mon, Sep 18, 2017 at 5:09 AM Sergey Beryozkin <sb...@gmail.com>
>> > wrote:
>> >
>> >> Have a look at the sse cdi demo Andriy added to the distribution,
>> >> the feature (the one dealing with SSE) is expected to be
>> auto-registered.
>> >>
>> >> Re the transport id, by default CXF assumes it is 'plain' HTTP, so it
>> >> needs a hint.
>> >>
>> >> What did you mean with 1) ?
>> >>
>> >> Sergey
>> >>
>> >> On 18/09/17 00:57, John D. Ament wrote:
>> >>> Ok, i was able to work a bit deeper into this.
>> >>>
>> >>> 1. the integration works, but firing async events doesn't work.  I'm
>> not
>> >>> sure it should, since you're just appending to the request; but I
>> want to
>> >>> play with async requests a bit.
>> >>>
>> >>> 2. The integration seems flakey I'm afraid.  I'll run a test, almost
>> >> always
>> >>> it passes, but then every off test run will cause SSE to not get
>> >>> activated.  I have no reproducer for this.
>> >>>
>> >>> When it does fail, all I get on the log is
>> >>>
>> >>> Sep 17, 2017 7:50:33 PM
>> >> org.apache.cxf.transport.servlet.ServletController
>> >>> invoke
>> >>> WARNING: Can't find the request for http://my-hostname:4403/rest's
>> >> Observer
>> >>>
>> >>> However, I see none of the atmosphere bootstrap occurring when this
>> >>> happens.  Here's full logs for both failure and success:
>> >>> https://paste.apache.org/rWwj
>> >>>
>> >>> 3. I had to manually install the feature.  Does CXF have any notion of
>> >>> automatically registering features?
>> >>>
>> >>> 4. I also had to customize the transport id.  It would be good if this
>> >> was
>> >>> automatic.
>> >>>
>> >>> John
>> >>>
>> >>> On Sun, Sep 17, 2017 at 4:21 PM John D. Ament <jo...@apache.org>
>> >> wrote:
>> >>>
>> >>>> I'm trying to create a very basic example of using SSE + CDI
>> events.  To
>> >>>> do that, I created a basic endpoint based on a CXF systest that I
>> found,
>> >>>> but tried to adapt it to work with CDI.
>> >>>>
>> >>>> @Path("/sse")
>> >>>> @RequestScoped
>> >>>> public class SseEventEndpoint {
>> >>>>       @Inject
>> >>>>       private Event<SseEvent> event;
>> >>>>       @Context
>> >>>>       private Sse sse;
>> >>>>       @GET
>> >>>>       @Path("{connectionId}")
>> >>>>       @Produces(MediaType.SERVER_SENT_EVENTS)
>> >>>>       public void onEvent(@Context SseEventSink sink,
>> >>>> @PathParam("connectionId") final String id) {
>> >>>>           System.out.println("Received request "+sse);
>> >>>>           event.fireAsync(new SseEvent(sink, sse, id));
>> >>>>       }
>> >>>> }
>> >>>>
>> >>>> However, no matter what I do, the Sse object is null.  Is there
>> >> something
>> >>>> I need to do to enable Sse integration?  This is what my dependencies
>> >> look
>> >>>> like
>> >>>>
>> >>>>           <dependency>
>> >>>>               <groupId>org.apache.cxf</groupId>
>> >>>>               <artifactId>cxf-integration-cdi</artifactId>
>> >>>>           </dependency>
>> >>>>           <dependency>
>> >>>>               <groupId>org.apache.cxf</groupId>
>> >>>>               <artifactId>cxf-rt-rs-client</artifactId>
>> >>>>           </dependency>
>> >>>>           <dependency>
>> >>>>               <groupId>org.apache.cxf</groupId>
>> >>>>               <artifactId>cxf-rt-rs-sse</artifactId>
>> >>>>           </dependency>
>> >>>>           <dependency>
>> >>>>               <groupId>org.apache.cxf</groupId>
>> >>>>               <artifactId>cxf-rt-transports-http</artifactId>
>> >>>>           </dependency>
>> >>>>
>> >>>
>> >>
>> >>
>> >> --
>> >> Sergey Beryozkin
>> >>
>> >> Talend Community Coders
>> >> http://coders.talend.com/
>> >>
>> >
>>
>

Re: Does SSE + CDI work?

Posted by "John D. Ament" <jo...@apache.org>.
On Mon, Sep 18, 2017 at 6:27 AM Sergey Beryozkin <sb...@gmail.com>
wrote:

> On 18/09/17 11:14, John D. Ament wrote:
> > I'm assuming you mean
> >
> https://github.com/apache/cxf/blob/master/distribution/src/main/release/samples/jax_rs/sse_cdi/src/main/java/demo/jaxrs/sse/StatsApplication.java#L39
> > ?
> > That looks manually registered.
> It should not be there,
>
> we need to add a CXF @Provider(type=Feature) to
>
>
> https://github.com/apache/cxf/blob/master/rt/rs/sse/src/main/java/org/apache/cxf/jaxrs/sse/SseFeature.java
>
> >
> > For my #1 its a CDI 2.0 feature.  I think it'll work with this approach
> > though.
> >
> > Any thoughts on the instability?
> Well, it's a totally new feature. I know Andriy found some issues while
> working on the integration with Atmosphere, my understanding there were
> many timing related test issues, but what is more important is how it
> works once the server is up an running, for a regular application, is
> not stable in your case ?
>

I have to test it that way further.  I'm doing everything via automation,
but need to run a sample app to check.  My main concern is stability within
my own pipeline by simply enabling this flag.


>
> Sergey
> >
> > John
> >
> > On Mon, Sep 18, 2017 at 5:09 AM Sergey Beryozkin <sb...@gmail.com>
> > wrote:
> >
> >> Have a look at the sse cdi demo Andriy added to the distribution,
> >> the feature (the one dealing with SSE) is expected to be
> auto-registered.
> >>
> >> Re the transport id, by default CXF assumes it is 'plain' HTTP, so it
> >> needs a hint.
> >>
> >> What did you mean with 1) ?
> >>
> >> Sergey
> >>
> >> On 18/09/17 00:57, John D. Ament wrote:
> >>> Ok, i was able to work a bit deeper into this.
> >>>
> >>> 1. the integration works, but firing async events doesn't work.  I'm
> not
> >>> sure it should, since you're just appending to the request; but I want
> to
> >>> play with async requests a bit.
> >>>
> >>> 2. The integration seems flakey I'm afraid.  I'll run a test, almost
> >> always
> >>> it passes, but then every off test run will cause SSE to not get
> >>> activated.  I have no reproducer for this.
> >>>
> >>> When it does fail, all I get on the log is
> >>>
> >>> Sep 17, 2017 7:50:33 PM
> >> org.apache.cxf.transport.servlet.ServletController
> >>> invoke
> >>> WARNING: Can't find the request for http://my-hostname:4403/rest's
> >> Observer
> >>>
> >>> However, I see none of the atmosphere bootstrap occurring when this
> >>> happens.  Here's full logs for both failure and success:
> >>> https://paste.apache.org/rWwj
> >>>
> >>> 3. I had to manually install the feature.  Does CXF have any notion of
> >>> automatically registering features?
> >>>
> >>> 4. I also had to customize the transport id.  It would be good if this
> >> was
> >>> automatic.
> >>>
> >>> John
> >>>
> >>> On Sun, Sep 17, 2017 at 4:21 PM John D. Ament <jo...@apache.org>
> >> wrote:
> >>>
> >>>> I'm trying to create a very basic example of using SSE + CDI events.
> To
> >>>> do that, I created a basic endpoint based on a CXF systest that I
> found,
> >>>> but tried to adapt it to work with CDI.
> >>>>
> >>>> @Path("/sse")
> >>>> @RequestScoped
> >>>> public class SseEventEndpoint {
> >>>>       @Inject
> >>>>       private Event<SseEvent> event;
> >>>>       @Context
> >>>>       private Sse sse;
> >>>>       @GET
> >>>>       @Path("{connectionId}")
> >>>>       @Produces(MediaType.SERVER_SENT_EVENTS)
> >>>>       public void onEvent(@Context SseEventSink sink,
> >>>> @PathParam("connectionId") final String id) {
> >>>>           System.out.println("Received request "+sse);
> >>>>           event.fireAsync(new SseEvent(sink, sse, id));
> >>>>       }
> >>>> }
> >>>>
> >>>> However, no matter what I do, the Sse object is null.  Is there
> >> something
> >>>> I need to do to enable Sse integration?  This is what my dependencies
> >> look
> >>>> like
> >>>>
> >>>>           <dependency>
> >>>>               <groupId>org.apache.cxf</groupId>
> >>>>               <artifactId>cxf-integration-cdi</artifactId>
> >>>>           </dependency>
> >>>>           <dependency>
> >>>>               <groupId>org.apache.cxf</groupId>
> >>>>               <artifactId>cxf-rt-rs-client</artifactId>
> >>>>           </dependency>
> >>>>           <dependency>
> >>>>               <groupId>org.apache.cxf</groupId>
> >>>>               <artifactId>cxf-rt-rs-sse</artifactId>
> >>>>           </dependency>
> >>>>           <dependency>
> >>>>               <groupId>org.apache.cxf</groupId>
> >>>>               <artifactId>cxf-rt-transports-http</artifactId>
> >>>>           </dependency>
> >>>>
> >>>
> >>
> >>
> >> --
> >> Sergey Beryozkin
> >>
> >> Talend Community Coders
> >> http://coders.talend.com/
> >>
> >
>

Re: Does SSE + CDI work?

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 18/09/17 11:14, John D. Ament wrote:
> I'm assuming you mean
> https://github.com/apache/cxf/blob/master/distribution/src/main/release/samples/jax_rs/sse_cdi/src/main/java/demo/jaxrs/sse/StatsApplication.java#L39
> ?
> That looks manually registered.
It should not be there,

we need to add a CXF @Provider(type=Feature) to

https://github.com/apache/cxf/blob/master/rt/rs/sse/src/main/java/org/apache/cxf/jaxrs/sse/SseFeature.java

> 
> For my #1 its a CDI 2.0 feature.  I think it'll work with this approach
> though.
> 
> Any thoughts on the instability?
Well, it's a totally new feature. I know Andriy found some issues while 
working on the integration with Atmosphere, my understanding there were 
many timing related test issues, but what is more important is how it 
works once the server is up an running, for a regular application, is 
not stable in your case ?

Sergey
> 
> John
> 
> On Mon, Sep 18, 2017 at 5:09 AM Sergey Beryozkin <sb...@gmail.com>
> wrote:
> 
>> Have a look at the sse cdi demo Andriy added to the distribution,
>> the feature (the one dealing with SSE) is expected to be auto-registered.
>>
>> Re the transport id, by default CXF assumes it is 'plain' HTTP, so it
>> needs a hint.
>>
>> What did you mean with 1) ?
>>
>> Sergey
>>
>> On 18/09/17 00:57, John D. Ament wrote:
>>> Ok, i was able to work a bit deeper into this.
>>>
>>> 1. the integration works, but firing async events doesn't work.  I'm not
>>> sure it should, since you're just appending to the request; but I want to
>>> play with async requests a bit.
>>>
>>> 2. The integration seems flakey I'm afraid.  I'll run a test, almost
>> always
>>> it passes, but then every off test run will cause SSE to not get
>>> activated.  I have no reproducer for this.
>>>
>>> When it does fail, all I get on the log is
>>>
>>> Sep 17, 2017 7:50:33 PM
>> org.apache.cxf.transport.servlet.ServletController
>>> invoke
>>> WARNING: Can't find the request for http://my-hostname:4403/rest's
>> Observer
>>>
>>> However, I see none of the atmosphere bootstrap occurring when this
>>> happens.  Here's full logs for both failure and success:
>>> https://paste.apache.org/rWwj
>>>
>>> 3. I had to manually install the feature.  Does CXF have any notion of
>>> automatically registering features?
>>>
>>> 4. I also had to customize the transport id.  It would be good if this
>> was
>>> automatic.
>>>
>>> John
>>>
>>> On Sun, Sep 17, 2017 at 4:21 PM John D. Ament <jo...@apache.org>
>> wrote:
>>>
>>>> I'm trying to create a very basic example of using SSE + CDI events.  To
>>>> do that, I created a basic endpoint based on a CXF systest that I found,
>>>> but tried to adapt it to work with CDI.
>>>>
>>>> @Path("/sse")
>>>> @RequestScoped
>>>> public class SseEventEndpoint {
>>>>       @Inject
>>>>       private Event<SseEvent> event;
>>>>       @Context
>>>>       private Sse sse;
>>>>       @GET
>>>>       @Path("{connectionId}")
>>>>       @Produces(MediaType.SERVER_SENT_EVENTS)
>>>>       public void onEvent(@Context SseEventSink sink,
>>>> @PathParam("connectionId") final String id) {
>>>>           System.out.println("Received request "+sse);
>>>>           event.fireAsync(new SseEvent(sink, sse, id));
>>>>       }
>>>> }
>>>>
>>>> However, no matter what I do, the Sse object is null.  Is there
>> something
>>>> I need to do to enable Sse integration?  This is what my dependencies
>> look
>>>> like
>>>>
>>>>           <dependency>
>>>>               <groupId>org.apache.cxf</groupId>
>>>>               <artifactId>cxf-integration-cdi</artifactId>
>>>>           </dependency>
>>>>           <dependency>
>>>>               <groupId>org.apache.cxf</groupId>
>>>>               <artifactId>cxf-rt-rs-client</artifactId>
>>>>           </dependency>
>>>>           <dependency>
>>>>               <groupId>org.apache.cxf</groupId>
>>>>               <artifactId>cxf-rt-rs-sse</artifactId>
>>>>           </dependency>
>>>>           <dependency>
>>>>               <groupId>org.apache.cxf</groupId>
>>>>               <artifactId>cxf-rt-transports-http</artifactId>
>>>>           </dependency>
>>>>
>>>
>>
>>
>> --
>> Sergey Beryozkin
>>
>> Talend Community Coders
>> http://coders.talend.com/
>>
> 

Re: Does SSE + CDI work?

Posted by "John D. Ament" <jo...@apache.org>.
I'm assuming you mean
https://github.com/apache/cxf/blob/master/distribution/src/main/release/samples/jax_rs/sse_cdi/src/main/java/demo/jaxrs/sse/StatsApplication.java#L39
?
That looks manually registered.

For my #1 its a CDI 2.0 feature.  I think it'll work with this approach
though.

Any thoughts on the instability?

John

On Mon, Sep 18, 2017 at 5:09 AM Sergey Beryozkin <sb...@gmail.com>
wrote:

> Have a look at the sse cdi demo Andriy added to the distribution,
> the feature (the one dealing with SSE) is expected to be auto-registered.
>
> Re the transport id, by default CXF assumes it is 'plain' HTTP, so it
> needs a hint.
>
> What did you mean with 1) ?
>
> Sergey
>
> On 18/09/17 00:57, John D. Ament wrote:
> > Ok, i was able to work a bit deeper into this.
> >
> > 1. the integration works, but firing async events doesn't work.  I'm not
> > sure it should, since you're just appending to the request; but I want to
> > play with async requests a bit.
> >
> > 2. The integration seems flakey I'm afraid.  I'll run a test, almost
> always
> > it passes, but then every off test run will cause SSE to not get
> > activated.  I have no reproducer for this.
> >
> > When it does fail, all I get on the log is
> >
> > Sep 17, 2017 7:50:33 PM
> org.apache.cxf.transport.servlet.ServletController
> > invoke
> > WARNING: Can't find the request for http://my-hostname:4403/rest's
> Observer
> >
> > However, I see none of the atmosphere bootstrap occurring when this
> > happens.  Here's full logs for both failure and success:
> > https://paste.apache.org/rWwj
> >
> > 3. I had to manually install the feature.  Does CXF have any notion of
> > automatically registering features?
> >
> > 4. I also had to customize the transport id.  It would be good if this
> was
> > automatic.
> >
> > John
> >
> > On Sun, Sep 17, 2017 at 4:21 PM John D. Ament <jo...@apache.org>
> wrote:
> >
> >> I'm trying to create a very basic example of using SSE + CDI events.  To
> >> do that, I created a basic endpoint based on a CXF systest that I found,
> >> but tried to adapt it to work with CDI.
> >>
> >> @Path("/sse")
> >> @RequestScoped
> >> public class SseEventEndpoint {
> >>      @Inject
> >>      private Event<SseEvent> event;
> >>      @Context
> >>      private Sse sse;
> >>      @GET
> >>      @Path("{connectionId}")
> >>      @Produces(MediaType.SERVER_SENT_EVENTS)
> >>      public void onEvent(@Context SseEventSink sink,
> >> @PathParam("connectionId") final String id) {
> >>          System.out.println("Received request "+sse);
> >>          event.fireAsync(new SseEvent(sink, sse, id));
> >>      }
> >> }
> >>
> >> However, no matter what I do, the Sse object is null.  Is there
> something
> >> I need to do to enable Sse integration?  This is what my dependencies
> look
> >> like
> >>
> >>          <dependency>
> >>              <groupId>org.apache.cxf</groupId>
> >>              <artifactId>cxf-integration-cdi</artifactId>
> >>          </dependency>
> >>          <dependency>
> >>              <groupId>org.apache.cxf</groupId>
> >>              <artifactId>cxf-rt-rs-client</artifactId>
> >>          </dependency>
> >>          <dependency>
> >>              <groupId>org.apache.cxf</groupId>
> >>              <artifactId>cxf-rt-rs-sse</artifactId>
> >>          </dependency>
> >>          <dependency>
> >>              <groupId>org.apache.cxf</groupId>
> >>              <artifactId>cxf-rt-transports-http</artifactId>
> >>          </dependency>
> >>
> >
>
>
> --
> Sergey Beryozkin
>
> Talend Community Coders
> http://coders.talend.com/
>

Re: Does SSE + CDI work?

Posted by Sergey Beryozkin <sb...@gmail.com>.
Have a look at the sse cdi demo Andriy added to the distribution,
the feature (the one dealing with SSE) is expected to be auto-registered.

Re the transport id, by default CXF assumes it is 'plain' HTTP, so it 
needs a hint.

What did you mean with 1) ?

Sergey

On 18/09/17 00:57, John D. Ament wrote:
> Ok, i was able to work a bit deeper into this.
> 
> 1. the integration works, but firing async events doesn't work.  I'm not
> sure it should, since you're just appending to the request; but I want to
> play with async requests a bit.
> 
> 2. The integration seems flakey I'm afraid.  I'll run a test, almost always
> it passes, but then every off test run will cause SSE to not get
> activated.  I have no reproducer for this.
> 
> When it does fail, all I get on the log is
> 
> Sep 17, 2017 7:50:33 PM org.apache.cxf.transport.servlet.ServletController
> invoke
> WARNING: Can't find the request for http://my-hostname:4403/rest's Observer
> 
> However, I see none of the atmosphere bootstrap occurring when this
> happens.  Here's full logs for both failure and success:
> https://paste.apache.org/rWwj
> 
> 3. I had to manually install the feature.  Does CXF have any notion of
> automatically registering features?
> 
> 4. I also had to customize the transport id.  It would be good if this was
> automatic.
> 
> John
> 
> On Sun, Sep 17, 2017 at 4:21 PM John D. Ament <jo...@apache.org> wrote:
> 
>> I'm trying to create a very basic example of using SSE + CDI events.  To
>> do that, I created a basic endpoint based on a CXF systest that I found,
>> but tried to adapt it to work with CDI.
>>
>> @Path("/sse")
>> @RequestScoped
>> public class SseEventEndpoint {
>>      @Inject
>>      private Event<SseEvent> event;
>>      @Context
>>      private Sse sse;
>>      @GET
>>      @Path("{connectionId}")
>>      @Produces(MediaType.SERVER_SENT_EVENTS)
>>      public void onEvent(@Context SseEventSink sink,
>> @PathParam("connectionId") final String id) {
>>          System.out.println("Received request "+sse);
>>          event.fireAsync(new SseEvent(sink, sse, id));
>>      }
>> }
>>
>> However, no matter what I do, the Sse object is null.  Is there something
>> I need to do to enable Sse integration?  This is what my dependencies look
>> like
>>
>>          <dependency>
>>              <groupId>org.apache.cxf</groupId>
>>              <artifactId>cxf-integration-cdi</artifactId>
>>          </dependency>
>>          <dependency>
>>              <groupId>org.apache.cxf</groupId>
>>              <artifactId>cxf-rt-rs-client</artifactId>
>>          </dependency>
>>          <dependency>
>>              <groupId>org.apache.cxf</groupId>
>>              <artifactId>cxf-rt-rs-sse</artifactId>
>>          </dependency>
>>          <dependency>
>>              <groupId>org.apache.cxf</groupId>
>>              <artifactId>cxf-rt-transports-http</artifactId>
>>          </dependency>
>>
> 


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Re: Does SSE + CDI work?

Posted by "John D. Ament" <jo...@apache.org>.
Ok, i was able to work a bit deeper into this.

1. the integration works, but firing async events doesn't work.  I'm not
sure it should, since you're just appending to the request; but I want to
play with async requests a bit.

2. The integration seems flakey I'm afraid.  I'll run a test, almost always
it passes, but then every off test run will cause SSE to not get
activated.  I have no reproducer for this.

When it does fail, all I get on the log is

Sep 17, 2017 7:50:33 PM org.apache.cxf.transport.servlet.ServletController
invoke
WARNING: Can't find the request for http://my-hostname:4403/rest's Observer

However, I see none of the atmosphere bootstrap occurring when this
happens.  Here's full logs for both failure and success:
https://paste.apache.org/rWwj

3. I had to manually install the feature.  Does CXF have any notion of
automatically registering features?

4. I also had to customize the transport id.  It would be good if this was
automatic.

John

On Sun, Sep 17, 2017 at 4:21 PM John D. Ament <jo...@apache.org> wrote:

> I'm trying to create a very basic example of using SSE + CDI events.  To
> do that, I created a basic endpoint based on a CXF systest that I found,
> but tried to adapt it to work with CDI.
>
> @Path("/sse")
> @RequestScoped
> public class SseEventEndpoint {
>     @Inject
>     private Event<SseEvent> event;
>     @Context
>     private Sse sse;
>     @GET
>     @Path("{connectionId}")
>     @Produces(MediaType.SERVER_SENT_EVENTS)
>     public void onEvent(@Context SseEventSink sink,
> @PathParam("connectionId") final String id) {
>         System.out.println("Received request "+sse);
>         event.fireAsync(new SseEvent(sink, sse, id));
>     }
> }
>
> However, no matter what I do, the Sse object is null.  Is there something
> I need to do to enable Sse integration?  This is what my dependencies look
> like
>
>         <dependency>
>             <groupId>org.apache.cxf</groupId>
>             <artifactId>cxf-integration-cdi</artifactId>
>         </dependency>
>         <dependency>
>             <groupId>org.apache.cxf</groupId>
>             <artifactId>cxf-rt-rs-client</artifactId>
>         </dependency>
>         <dependency>
>             <groupId>org.apache.cxf</groupId>
>             <artifactId>cxf-rt-rs-sse</artifactId>
>         </dependency>
>         <dependency>
>             <groupId>org.apache.cxf</groupId>
>             <artifactId>cxf-rt-transports-http</artifactId>
>         </dependency>
>