Simple usage

19 messages Options
Embed this post
Permalink
Á. Eduardo García

Simple usage

Reply Threaded More More options
Print post
Permalink
Hi. I've already send this question to Jean François through mail, but asked me to post it here so all can benefit from it.

Also, forgive me if this is an stupid question, but I'm having a bit of trouble making Atmosphere work in this scenario:

I have a list of resources, and I want some users subscribe to some of the resources to get updates in realtime.

Currently, I'm first connecting to an endpoint (load()) with @GET and @Suspend (I'm using Jersey) to suspend first the connection, and after that I'm connecting to another @GET endpoint (login()) with a JerseyBroadcaster parameter, so I can get the Broadcast event of the user that connected, like in Twitter REST example. I store this Broadcast event so later I can send data to this user. Something like this:

@GET
@Suspend(scope = Suspend.SCOPE.REQUEST)
public String load()
{
}

@POST
public String login(@Context JerseyBroadcaster jb)
{
}

And now my two questions.

a) I'm sure I can made something like a broadcast per resource, so when every resource changes, I can broadcast to all this resource listeners. Any idea or simple way to do it? I'm sure it's very stupid, but I don't seem to get it.

b) Anyone know how to use jQuery to work with Atmosphere? Currently I'm just trying to do long polling using $.get(), but even when my Atmosphere endpoint doesn't return anything, the .get() success callback returns. Maybe I'm not creating my endpoints as I should... I've tried using a @POST method returning void and @GET returning a Broadcaster, but both returns just after calling with $.get().

Thanks in advance for any clue :)
Jeanfrancois Arcand

Re: Simple usage

Reply Threaded More More options
Print post
Permalink
Salut,

Á. Eduardo García wrote:

> Hi. I've already send this question to Jean François through mail, but asked
> me to post it here so all can benefit from it.
>
> Also, forgive me if this is an stupid question, but I'm having a bit of
> trouble making Atmosphere work in this scenario:
>
> I have a list of resources, and I want some users subscribe to some of the
> resources to get updates in realtime.
>
> Currently, I'm first connecting to an endpoint (load()) with @GET and
> @Suspend (I'm using Jersey) to suspend first the connection, and after that
> I'm connecting to another @GET endpoint (login()) with a JerseyBroadcaster
> parameter, so I can get the Broadcast event of the user that connected, like
> in Twitter REST example. I store this Broadcast event so later I can send
> data to this user. Something like this:
>
> @GET
> @Suspend(scope = Suspend.SCOPE.REQUEST)

Is it really per Request that you need? It means you will need to cycle
over all the Broadcaster's instance to broadcast to all. Is that what
you want?

> public String load()
> {
> }
>
> @POST
> public String login(@Context JerseyBroadcaster jb)
> {
> }
>
> And now my two questions.
>
> a) I'm sure I can made something like a broadcast per resource, so when
> every resource changes, I can broadcast to all this resource listeners. Any
> idea or simple way to do it? I'm sure it's very stupid, but I don't seem to
> get it.

I don't have implemented such features. If I understand correctly, you
want to have a meta broadcaster than can be invoked and internally will
broadcast to all instance of Broadcaster?

>
> b) Anyone know how to use jQuery to work with Atmosphere? Currently I'm just
> trying to do long polling using $.get(), but even when my Atmosphere
> endpoint doesn't return anything, the .get() success callback returns.

If you return something, so it make a difference? Like some junk.


  Maybe
> I'm not creating my endpoints as I should... I've tried using a @POST method
> returning void and @GET returning a Broadcaster, but both returns just after
> calling with $.get().

Can you send me a test case (if you can) to jfarcand at apache dot org
so I can quickly debug what's happenning?

Sorry if I can't help more.

A+

-- jeanfrancois


>
> Thanks in advance for any clue :)

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Á. Eduardo García

Re: Simple usage

Reply Threaded More More options
Print post
Permalink
Sorry for the delay and all, I'll rephrase my questions, now that I've taken again this.

I've a class with just this:
@Path("test")
@Singleton
public class test{
    @Suspend(scope = Suspend.SCOPE.REQUEST)
    @GET
    @Produces("text/html")
    public String pageLoad() {
        return "Hello";
    }

    @Path("login")
    @Broadcast
    @POST
    @Produces("text/plain")
    public Broadcastable onLogin(@Context UserBroadcaster bc) {
        map.put("user", bc);

        String m = "test";
        Broadcastable b = new Broadcastable(m, bc);
        return b;
    }

    @Path("action")
    @Broadcast
    @GET
    @Produces("text/html")
    public Broadcastable onAction() {
        UserBroadcaster bc = uc.get("test");

        String script = "<script>alert('COMET!');</script>";
        Broadcastable b = new Broadcastable(script, bc);
        return b;
    }
}

Thats simple enough, I think. As you can see, it's almost the same as the Twitter example. I have two browsers, B1 and B2, and I do this with Ajax (jQuery):

B1: GET("test"); // This gets suspended
B1: POST("test/login"); // This returns "test"
B2: GET("test/action");

On the last call, from another browser, I get my alert showing up, but as I understand it (obviously I'm wrong) the code must be sent to B1, because I'm using the Broadcaster saved in the login method and broadcasting using it. I've also tried to do "bc.broadcast(script);" but no luck either.

Could someone explain it to me? Basically what I'm trying to do right now is suspend a browser, store its broadcaster, and later retrieve it to send some information to that browser from another browser or directly my server (that's just comet, isn't it :P)

Thanks a lot in advance, and sorry if I didn't get to the point this time, again xD
Jeanfrancois Arcand

Re: Simple usage

Reply Threaded More More options
Print post
Permalink
Salut,

Á. Eduardo García wrote:
> Sorry for the delay and all, I'll rephrase my questions, now that I've taken
> again this.

Welcome back!

>
> I've a class with just this:
> @Path("test")
> @Singleton
> public class test{
>     @Suspend(scope = Suspend.SCOPE.REQUEST)
>     @GET
>     @Produces("text/html")
>     public String pageLoad() {
>         return "Hello";
>     }
>
>     @Path("login")
>     @Broadcast
>     @POST
>     @Produces("text/plain")
>     public Broadcastable onLogin(@Context UserBroadcaster bc) {
>         map.put("user", bc);
>
>         String m = "test";
>         Broadcastable b = new Broadcastable(m, bc);
>         return b;
>     }
>
>     @Path("action")
>     @Broadcast
>     @GET
>     @Produces("text/html")
>     public Broadcastable onAction() {
>         UserBroadcaster bc = uc.get("test");
>
>         String script = "<script>alert('COMET!');</script>";
>         Broadcastable b = new Broadcastable(script, bc);
>         return b;
>     }
> }
>
> Thats simple enough, I think. As you can see, it's almost the same as the
> Twitter example. I have two browsers, B1 and B2, and I do this with Ajax
> (jQuery):
>
> B1: GET("test"); // This gets suspended
> B1: POST("test/login"); // This returns "test"
> B2: GET("test/action");
>
> On the last call, from another browser, I get my alert showing up, but as I
> understand it (obviously I'm wrong) the code must be sent to B1, because I'm
> using the Broadcaster saved in the login method and broadcasting using it.
> I've also tried to do "bc.broadcast(script);" but no luck either.

You are right. Let me install the test and see what's hapenning


>
> Could someone explain it to me? Basically what I'm trying to do right now is
> suspend a browser, store its broadcaster, and later retrieve it to send some
> information to that browser from another browser or directly my server
> (that's just comet, isn't it :P)
>
> Thanks a lot in advance, and sorry if I didn't get to the point this time,
> again xD

No that's crystal clear....let me re-create your sample and report back.

Thanks a lot!

--Jeanfrancois




---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Jeanfrancois Arcand

Re: Simple usage

Reply Threaded More More options
Print post
Permalink
Salut,

I confirm there is an issue. The injected Broadcaster has a list of
empty AtmosphereResource...I will fix this soon :-)

Thanks for the test case!

-- Jeanfrancois

Jeanfrancois Arcand wrote:

> Salut,
>
> Á. Eduardo García wrote:
>> Sorry for the delay and all, I'll rephrase my questions, now that I've
>> taken
>> again this.
>
> Welcome back!
>
>>
>> I've a class with just this:
>> @Path("test")
>> @Singleton
>> public class test{
>>     @Suspend(scope = Suspend.SCOPE.REQUEST)
>>     @GET
>>     @Produces("text/html")
>>     public String pageLoad() {
>>         return "Hello";
>>     }
>>
>>     @Path("login")
>>     @Broadcast
>>     @POST
>>     @Produces("text/plain")
>>     public Broadcastable onLogin(@Context UserBroadcaster bc) {
>>         map.put("user", bc);
>>
>>         String m = "test";
>>         Broadcastable b = new Broadcastable(m, bc);
>>         return b;
>>     }
>>
>>     @Path("action")
>>     @Broadcast
>>     @GET
>>     @Produces("text/html")
>>     public Broadcastable onAction() {
>>         UserBroadcaster bc = uc.get("test");
>>
>>         String script = "<script>alert('COMET!');</script>";
>>         Broadcastable b = new Broadcastable(script, bc);
>>         return b;
>>     }
>> }
>>
>> Thats simple enough, I think. As you can see, it's almost the same as the
>> Twitter example. I have two browsers, B1 and B2, and I do this with Ajax
>> (jQuery):
>>
>> B1: GET("test"); // This gets suspended
>> B1: POST("test/login"); // This returns "test"
>> B2: GET("test/action");
>>
>> On the last call, from another browser, I get my alert showing up, but
>> as I
>> understand it (obviously I'm wrong) the code must be sent to B1,
>> because I'm
>> using the Broadcaster saved in the login method and broadcasting using
>> it.
>> I've also tried to do "bc.broadcast(script);" but no luck either.
>
> You are right. Let me install the test and see what's hapenning
>
>
>>
>> Could someone explain it to me? Basically what I'm trying to do right
>> now is
>> suspend a browser, store its broadcaster, and later retrieve it to
>> send some
>> information to that browser from another browser or directly my server
>> (that's just comet, isn't it :P)
>>
>> Thanks a lot in advance, and sorry if I didn't get to the point this
>> time,
>> again xD
>
> No that's crystal clear....let me re-create your sample and report back.
>
> Thanks a lot!
>
> --Jeanfrancois
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Á. Eduardo García

Re: Simple usage

Reply Threaded More More options
Print post
Permalink
At last! I was thinking I was going mad, because this is the very issue I was having a month ago when I had to left it in some half state to continue with other things, but now we really need push support to our project, so that's very good to hear.

I'm glad my simple example helped :). Thanks a lot!

2009/10/16 Jeanfrancois Arcand (via Nabble) <[hidden email]>
Salut,

I confirm there is an issue. The injected Broadcaster has a list of
empty AtmosphereResource...I will fix this soon :-)

Thanks for the test case!

-- Jeanfrancois

Jeanfrancois Arcand wrote:

> Salut,
>
> Á. Eduardo García wrote:
>> Sorry for the delay and all, I'll rephrase my questions, now that I've
>> taken
>> again this.
>
> Welcome back!
>
>>
>> I've a class with just this:
>> @Path("test")
>> @Singleton
>> public class test{
>>     @Suspend(scope = Suspend.SCOPE.REQUEST)
>>     @GET
>>     @Produces("text/html")
>>     public String pageLoad() {
>>         return "Hello";
>>     }
>>
>>     @Path("login")
>>     @Broadcast
>>     @POST
>>     @Produces("text/plain")
>>     public Broadcastable onLogin(@Context UserBroadcaster bc) {
>>         map.put("user", bc);
>>
>>         String m = "test";
>>         Broadcastable b = new Broadcastable(m, bc);
>>         return b;
>>     }
>>
>>     @Path("action")
>>     @Broadcast
>>     @GET
>>     @Produces("text/html")
>>     public Broadcastable onAction() {
>>         UserBroadcaster bc = uc.get("test");
>>
>>         String script = "<script>alert('COMET!');</script>";
>>         Broadcastable b = new Broadcastable(script, bc);
>>         return b;
>>     }
>> }
>>
>> Thats simple enough, I think. As you can see, it's almost the same as the
>> Twitter example. I have two browsers, B1 and B2, and I do this with Ajax
>> (jQuery):
>>
>> B1: GET("test"); // This gets suspended
>> B1: POST("test/login"); // This returns "test"
>> B2: GET("test/action");
>>
>> On the last call, from another browser, I get my alert showing up, but
>> as I
>> understand it (obviously I'm wrong) the code must be sent to B1,
>> because I'm
>> using the Broadcaster saved in the login method and broadcasting using
>> it.
>> I've also tried to do "bc.broadcast(script);" but no luck either.
>
> You are right. Let me install the test and see what's hapenning
>
>
>>
>> Could someone explain it to me? Basically what I'm trying to do right
>> now is
>> suspend a browser, store its broadcaster, and later retrieve it to
>> send some
>> information to that browser from another browser or directly my server
>> (that's just comet, isn't it :P)
>>
>> Thanks a lot in advance, and sorry if I didn't get to the point this
>> time,
>> again xD
>
> No that's crystal clear....let me re-create your sample and report back.
>
> Thanks a lot!
>
> --Jeanfrancois
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Jeanfrancois Arcand

(Application error) <was> Re: Simple usage

Reply Threaded More More options
Print post
Permalink
In reply to this post by Jeanfrancois Arcand

Salut,

the following line:

    @Suspend(scope = Suspend.SCOPE.REQUEST)

is causing the "problem" you are observing. Configuring a Broadcaster's
scope to request means tells Atmosphere to creates a Broadcaster per
request. In the current scenario, a newly Broadcaster will be created
when you define:

   public Broadcastable onLogin(@Context UserBroadcaster bc) {

To fix the issue, just do:

    @Suspend

and it will works like you described. I'm coying the test I was using:

> @Path("test")
> @Singleton
> public class ResourceChat{
>
>     ConcurrentHashMap<String,UserBroadcaster> map = new ConcurrentHashMap<String,UserBroadcaster>();
>
>     @Suspend
>     @GET
>     @Produces("text/html")
>     public String pageLoad() {
>         return "Hello";
>     }
>
>     @Path("login")
>     @Broadcast
>     @POST
>     @Produces("text/plain")
>     public Broadcastable onLogin(@Context UserBroadcaster bc) {
>         map.put("user", bc);
>
>         String m = "test";
>         Broadcastable b = new Broadcastable(m, bc);
>         return b;
>     }
>
>     @Path("action")
>     @Broadcast
>     @GET
>     @Produces("text/html")
>     public Broadcastable onAction() {
>         UserBroadcaster bc = map.get("user");
>
>         String script = "<script>alert('COMET!');</script>";
>         Broadcastable b = new Broadcastable(script, bc);
>         return b;
>     }
>
>
> }

Hope that help.

A+

-- Jeanfrancois




Jeanfrancois Arcand wrote:

> Salut,
>
> I confirm there is an issue. The injected Broadcaster has a list of
> empty AtmosphereResource...I will fix this soon :-)
>
> Thanks for the test case!
>
> -- Jeanfrancois
>
> Jeanfrancois Arcand wrote:
>> Salut,
>>
>> Á. Eduardo García wrote:
>>> Sorry for the delay and all, I'll rephrase my questions, now that
>>> I've taken
>>> again this.
>>
>> Welcome back!
>>
>>>
>>> I've a class with just this:
>>> @Path("test")
>>> @Singleton
>>> public class test{
>>>     @Suspend(scope = Suspend.SCOPE.REQUEST)
>>>     @GET
>>>     @Produces("text/html")
>>>     public String pageLoad() {
>>>         return "Hello";
>>>     }
>>>
>>>     @Path("login")
>>>     @Broadcast
>>>     @POST
>>>     @Produces("text/plain")
>>>     public Broadcastable onLogin(@Context UserBroadcaster bc) {
>>>         map.put("user", bc);
>>>
>>>         String m = "test";
>>>         Broadcastable b = new Broadcastable(m, bc);
>>>         return b;
>>>     }
>>>
>>>     @Path("action")
>>>     @Broadcast
>>>     @GET
>>>     @Produces("text/html")
>>>     public Broadcastable onAction() {
>>>         UserBroadcaster bc = uc.get("test");
>>>
>>>         String script = "<script>alert('COMET!');</script>";
>>>         Broadcastable b = new Broadcastable(script, bc);
>>>         return b;
>>>     }
>>> }
>>>
>>> Thats simple enough, I think. As you can see, it's almost the same as
>>> the
>>> Twitter example. I have two browsers, B1 and B2, and I do this with Ajax
>>> (jQuery):
>>>
>>> B1: GET("test"); // This gets suspended
>>> B1: POST("test/login"); // This returns "test"
>>> B2: GET("test/action");
>>>
>>> On the last call, from another browser, I get my alert showing up,
>>> but as I
>>> understand it (obviously I'm wrong) the code must be sent to B1,
>>> because I'm
>>> using the Broadcaster saved in the login method and broadcasting
>>> using it.
>>> I've also tried to do "bc.broadcast(script);" but no luck either.
>>
>> You are right. Let me install the test and see what's hapenning
>>
>>
>>>
>>> Could someone explain it to me? Basically what I'm trying to do right
>>> now is
>>> suspend a browser, store its broadcaster, and later retrieve it to
>>> send some
>>> information to that browser from another browser or directly my server
>>> (that's just comet, isn't it :P)
>>>
>>> Thanks a lot in advance, and sorry if I didn't get to the point this
>>> time,
>>> again xD
>>
>> No that's crystal clear....let me re-create your sample and report back.
>>
>> Thanks a lot!
>>
>> --Jeanfrancois
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Jeanfrancois Arcand

Re: (Application error) <was> Re: Simple usage

Reply Threaded More More options
Print post
Permalink
Actually I've removed the ConcurrentHashMap and instead injected a
BroadcasterLookup instance:

    * http://is.gd/4mSWD

> @Path("test")
> @Singleton
> public class ResourceChat{
>     @Suspend
>     @GET
>     @Produces("text/html")
>     public String pageLoad() {
>         return "Hello";
>     }
>
>     @Path("login")
>     @Broadcast
>     @POST
>     @Produces("text/plain")
>     public Broadcastable onLogin(@Context UserBroadcaster bc) {
>         bc.setName("user");
>
>         String m = "test";
>         Broadcastable b = new Broadcastable(m, bc);
>         return b;
>     }
>
>     @Path("action")
>     @Broadcast
>     @GET
>     @Produces("text/html")
>     public Broadcastable onAction(@Context BroadcasterLookup bcl) throws OutOfScopeException {
>         String script = "<script>alert('COMET!');</script>";
>         Broadcastable b = new Broadcastable(script, bcl.lookup("user"));
>         return b;
>     }
>
>
> }

That way you don't need to handle the life cycle of the HashMap. Now
discussing with Paul today about the Serializer API, we have found an
issue with the content-type/javax.ws.rs.ext.MessageBodyWriter. If you
look above, you do:

(1) Suspend -> content-type == text/html
(2) Broadcast -> content-type == text/plain
(3) Broadcast -> content-type == text/html

For the sample it works, but (2) would have failed to work properly if
you wanted to write some JSON or JAXB as the MessageBodyWriter was first
created for text/html.

I'm working on a fix for that part as well, but it will require some
Jersey modication.

Thanks!

-- Jeanfrancois

Jeanfrancois Arcand wrote:

>
> Salut,
>
> the following line:
>
>    @Suspend(scope = Suspend.SCOPE.REQUEST)
>
> is causing the "problem" you are observing. Configuring a Broadcaster's
> scope to request means tells Atmosphere to creates a Broadcaster per
> request. In the current scenario, a newly Broadcaster will be created
> when you define:
>
>   public Broadcastable onLogin(@Context UserBroadcaster bc) {
>
> To fix the issue, just do:
>
>    @Suspend
>
> and it will works like you described. I'm coying the test I was using:
>
>> @Path("test")
>> @Singleton
>> public class ResourceChat{
>>
>>     ConcurrentHashMap<String,UserBroadcaster> map = new
>> ConcurrentHashMap<String,UserBroadcaster>();
>>
>>     @Suspend
>>     @GET
>>     @Produces("text/html")
>>     public String pageLoad() {
>>         return "Hello";
>>     }
>>
>>     @Path("login")
>>     @Broadcast
>>     @POST
>>     @Produces("text/plain")
>>     public Broadcastable onLogin(@Context UserBroadcaster bc) {
>>         map.put("user", bc);
>>
>>         String m = "test";
>>         Broadcastable b = new Broadcastable(m, bc);
>>         return b;
>>     }
>>
>>     @Path("action")
>>     @Broadcast
>>     @GET
>>     @Produces("text/html")
>>     public Broadcastable onAction() {
>>         UserBroadcaster bc = map.get("user");
>>
>>         String script = "<script>alert('COMET!');</script>";
>>         Broadcastable b = new Broadcastable(script, bc);
>>         return b;
>>     }
>>
>>
>> }
>
> Hope that help.
>
> A+
>
> -- Jeanfrancois
>
>
>
>
> Jeanfrancois Arcand wrote:
>> Salut,
>>
>> I confirm there is an issue. The injected Broadcaster has a list of
>> empty AtmosphereResource...I will fix this soon :-)
>>
>> Thanks for the test case!
>>
>> -- Jeanfrancois
>>
>> Jeanfrancois Arcand wrote:
>>> Salut,
>>>
>>> Á. Eduardo García wrote:
>>>> Sorry for the delay and all, I'll rephrase my questions, now that
>>>> I've taken
>>>> again this.
>>>
>>> Welcome back!
>>>
>>>>
>>>> I've a class with just this:
>>>> @Path("test")
>>>> @Singleton
>>>> public class test{
>>>>     @Suspend(scope = Suspend.SCOPE.REQUEST)
>>>>     @GET
>>>>     @Produces("text/html")
>>>>     public String pageLoad() {
>>>>         return "Hello";
>>>>     }
>>>>
>>>>     @Path("login")
>>>>     @Broadcast
>>>>     @POST
>>>>     @Produces("text/plain")
>>>>     public Broadcastable onLogin(@Context UserBroadcaster bc) {
>>>>         map.put("user", bc);
>>>>
>>>>         String m = "test";
>>>>         Broadcastable b = new Broadcastable(m, bc);
>>>>         return b;
>>>>     }
>>>>
>>>>     @Path("action")
>>>>     @Broadcast
>>>>     @GET
>>>>     @Produces("text/html")
>>>>     public Broadcastable onAction() {
>>>>         UserBroadcaster bc = uc.get("test");
>>>>
>>>>         String script = "<script>alert('COMET!');</script>";
>>>>         Broadcastable b = new Broadcastable(script, bc);
>>>>         return b;
>>>>     }
>>>> }
>>>>
>>>> Thats simple enough, I think. As you can see, it's almost the same
>>>> as the
>>>> Twitter example. I have two browsers, B1 and B2, and I do this with
>>>> Ajax
>>>> (jQuery):
>>>>
>>>> B1: GET("test"); // This gets suspended
>>>> B1: POST("test/login"); // This returns "test"
>>>> B2: GET("test/action");
>>>>
>>>> On the last call, from another browser, I get my alert showing up,
>>>> but as I
>>>> understand it (obviously I'm wrong) the code must be sent to B1,
>>>> because I'm
>>>> using the Broadcaster saved in the login method and broadcasting
>>>> using it.
>>>> I've also tried to do "bc.broadcast(script);" but no luck either.
>>>
>>> You are right. Let me install the test and see what's hapenning
>>>
>>>
>>>>
>>>> Could someone explain it to me? Basically what I'm trying to do
>>>> right now is
>>>> suspend a browser, store its broadcaster, and later retrieve it to
>>>> send some
>>>> information to that browser from another browser or directly my server
>>>> (that's just comet, isn't it :P)
>>>>
>>>> Thanks a lot in advance, and sorry if I didn't get to the point this
>>>> time,
>>>> again xD
>>>
>>> No that's crystal clear....let me re-create your sample and report back.
>>>
>>> Thanks a lot!
>>>
>>> --Jeanfrancois
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Á. Eduardo García

Re: (Application error) <was> Re: Simple usage

Reply Threaded More More options
Print post
Permalink
Hi!

Good to know there is a fix for that! And thanks for the second advice, too, because I was going to do exactly what you were saying: giving text/html to one responses and application/json to others. I'm sure that "bug" would have driven me mad as well :) Obviously I don't know very much about the internals of Jersey / Atmosphere because I though the media type of the response was going to be added after every call and not that atmosphere was going to change any of that :P I'll give all methods an application/json response for now so I can use JSON.

I'll try this first thing in the morning tomorrow at work (hate to work on weekends...). Thanks again, keep the good job :)

2009/10/16 Jeanfrancois Arcand (via Nabble) <[hidden email]>
Actually I've removed the ConcurrentHashMap and instead injected a
BroadcasterLookup instance:

    * http://is.gd/4mSWD

> @Path("test")
> @Singleton
> public class ResourceChat{
>     @Suspend

>     @GET
>     @Produces("text/html")
>     public String pageLoad() {
>         return "Hello";
>     }
>
>     @Path("login")
>     @Broadcast
>     @POST
>     @Produces("text/plain")
>     public Broadcastable onLogin(@Context UserBroadcaster bc) {
>         bc.setName("user");
>
>         String m = "test";
>         Broadcastable b = new Broadcastable(m, bc);
>         return b;
>     }
>
>     @Path("action")
>     @Broadcast
>     @GET
>     @Produces("text/html")
>     public Broadcastable onAction(@Context BroadcasterLookup bcl) throws OutOfScopeException {
>         String script = "<script>alert('COMET!');</script>";
>         Broadcastable b = new Broadcastable(script, bcl.lookup("user"));
>         return b;
>     }
>
>
> }

That way you don't need to handle the life cycle of the HashMap. Now
discussing with Paul today about the Serializer API, we have found an
issue with the content-type/javax.ws.rs.ext.MessageBodyWriter. If you
look above, you do:

(1) Suspend -> content-type == text/html
(2) Broadcast -> content-type == text/plain
(3) Broadcast -> content-type == text/html

For the sample it works, but (2) would have failed to work properly if
you wanted to write some JSON or JAXB as the MessageBodyWriter was first
created for text/html.

I'm working on a fix for that part as well, but it will require some
Jersey modication.

Thanks!

-- Jeanfrancois

Jeanfrancois Arcand wrote:

>
> Salut,
>
> the following line:
>
>    @Suspend(scope = Suspend.SCOPE.REQUEST)
>
> is causing the "problem" you are observing. Configuring a Broadcaster's
> scope to request means tells Atmosphere to creates a Broadcaster per
> request. In the current scenario, a newly Broadcaster will be created
> when you define:
>
>   public Broadcastable onLogin(@Context UserBroadcaster bc) {
>
> To fix the issue, just do:
>
>    @Suspend
>
> and it will works like you described. I'm coying the test I was using:
>
>> @Path("test")
>> @Singleton
>> public class ResourceChat{
>>
>>     ConcurrentHashMap<String,UserBroadcaster> map = new
>> ConcurrentHashMap<String,UserBroadcaster>();
>>
>>     @Suspend
>>     @GET
>>     @Produces("text/html")
>>     public String pageLoad() {
>>         return "Hello";
>>     }
>>
>>     @Path("login")
>>     @Broadcast
>>     @POST
>>     @Produces("text/plain")
>>     public Broadcastable onLogin(@Context UserBroadcaster bc) {
>>         map.put("user", bc);
>>
>>         String m = "test";
>>         Broadcastable b = new Broadcastable(m, bc);
>>         return b;
>>     }
>>
>>     @Path("action")
>>     @Broadcast
>>     @GET
>>     @Produces("text/html")
>>     public Broadcastable onAction() {
>>         UserBroadcaster bc = map.get("user");
>>
>>         String script = "<script>alert('COMET!');</script>";
>>         Broadcastable b = new Broadcastable(script, bc);
>>         return b;
>>     }
>>
>>
>> }
>
> Hope that help.
>
> A+
>
> -- Jeanfrancois
>
>
>
>
> Jeanfrancois Arcand wrote:
>> Salut,
>>
>> I confirm there is an issue. The injected Broadcaster has a list of
>> empty AtmosphereResource...I will fix this soon :-)
>>
>> Thanks for the test case!
>>
>> -- Jeanfrancois
>>
>> Jeanfrancois Arcand wrote:
>>> Salut,
>>>
>>> Á. Eduardo García wrote:
>>>> Sorry for the delay and all, I'll rephrase my questions, now that
>>>> I've taken
>>>> again this.
>>>
>>> Welcome back!
>>>
>>>>
>>>> I've a class with just this:
>>>> @Path("test")
>>>> @Singleton
>>>> public class test{
>>>>     @Suspend(scope = Suspend.SCOPE.REQUEST)
>>>>     @GET
>>>>     @Produces("text/html")
>>>>     public String pageLoad() {
>>>>         return "Hello";
>>>>     }
>>>>
>>>>     @Path("login")
>>>>     @Broadcast
>>>>     @POST
>>>>     @Produces("text/plain")
>>>>     public Broadcastable onLogin(@Context UserBroadcaster bc) {
>>>>         map.put("user", bc);
>>>>
>>>>         String m = "test";
>>>>         Broadcastable b = new Broadcastable(m, bc);
>>>>         return b;
>>>>     }
>>>>
>>>>     @Path("action")
>>>>     @Broadcast
>>>>     @GET
>>>>     @Produces("text/html")
>>>>     public Broadcastable onAction() {
>>>>         UserBroadcaster bc = uc.get("test");
>>>>
>>>>         String script = "<script>alert('COMET!');</script>";
>>>>         Broadcastable b = new Broadcastable(script, bc);
>>>>         return b;
>>>>     }
>>>> }
>>>>
>>>> Thats simple enough, I think. As you can see, it's almost the same
>>>> as the
>>>> Twitter example. I have two browsers, B1 and B2, and I do this with
>>>> Ajax
>>>> (jQuery):
>>>>
>>>> B1: GET("test"); // This gets suspended
>>>> B1: POST("test/login"); // This returns "test"
>>>> B2: GET("test/action");
>>>>
>>>> On the last call, from another browser, I get my alert showing up,
>>>> but as I
>>>> understand it (obviously I'm wrong) the code must be sent to B1,
>>>> because I'm
>>>> using the Broadcaster saved in the login method and broadcasting
>>>> using it.
>>>> I've also tried to do "bc.broadcast(script);" but no luck either.
>>>
>>> You are right. Let me install the test and see what's hapenning
>>>
>>>
>>>>
>>>> Could someone explain it to me? Basically what I'm trying to do
>>>> right now is
>>>> suspend a browser, store its broadcaster, and later retrieve it to
>>>> send some
>>>> information to that browser from another browser or directly my server
>>>> (that's just comet, isn't it :P)
>>>>
>>>> Thanks a lot in advance, and sorry if I didn't get to the point this
>>>> time,
>>>> again xD
>>>
>>> No that's crystal clear....let me re-create your sample and report back.
>>>
>>> Thanks a lot!
>>>
>>> --Jeanfrancois
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Á. Eduardo García

Re: (Application error) <was> Re: Simple usage

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Good morning! (At least here :D)

Unfortunately, that didn't seem to work. Worst than that, I've managed to complete screw up Glassfish with this.
What I did exactly:

Using your code (but adding a "@FormParam String param1" to onLogin function, do this calls on two browsers:

I have a page that does:
B1: GET("test")
B1: POST("test/login?param1=undefined&param2=undefined&param3=undefined") // Doesn't know if this params-thing have any to do with the problem, but anyway that's what I did

Reload browser page at least 4 or 5 times

Now, in browser 2
B2: GET("test/action")

First time it usually works, now reload page a few times and I start to get junk. Oddly enough, if my reload sequence gets me "good - junk - junk - good" for example, it repeats itself no matter how may times I retry it.

And finally, if I stop Glassfish, I get a few exceptions in different places every time. Last time was:

SEVERE: java.lang.NullPointerException
SEVERE:         at com.sun.enterprise.deploy.shared.FileArchive.getDirectories(FileArchive.java:158)

...but every time it gets different.

Hope that helps!

On 16 Oct 2009, at 23:00, Á. Eduardo García (via Nabble) wrote:

Hi!

Good to know there is a fix for that! And thanks for the second advice, too, because I was going to do exactly what you were saying: giving text/html to one responses and application/json to others. I'm sure that "bug" would have driven me mad as well :) Obviously I don't know very much about the internals of Jersey / Atmosphere because I though the media type of the response was going to be added after every call and not that atmosphere was going to change any of that :P I'll give all methods an application/json response for now so I can use JSON.

I'll try this first thing in the morning tomorrow at work (hate to work on weekends...). Thanks again, keep the good job :)

2009/10/16 Jeanfrancois Arcand (via Nabble) <[hidden email]>
Actually I've removed the ConcurrentHashMap and instead injected a
BroadcasterLookup instance:

    * http://is.gd/4mSWD

> @Path("test")
> @Singleton
> public class ResourceChat{
>     @Suspend

>     @GET
>     @Produces("text/html")
>     public String pageLoad() {
>         return "Hello";
>     }
>
>     @Path("login")
>     @Broadcast
>     @POST
>     @Produces("text/plain")
>     public Broadcastable onLogin(@Context UserBroadcaster bc) {
>         bc.setName("user");
>
>         String m = "test";
>         Broadcastable b = new Broadcastable(m, bc);
>         return b;
>     }
>
>     @Path("action")
>     @Broadcast
>     @GET
>     @Produces("text/html")
>     public Broadcastable onAction(@Context BroadcasterLookup bcl) throws OutOfScopeException {
>         String script = "<script>alert('COMET!');</script>";
>         Broadcastable b = new Broadcastable(script, bcl.lookup("user"));
>         return b;
>     }
>
>
> }

That way you don't need to handle the life cycle of the HashMap. Now
discussing with Paul today about the Serializer API, we have found an
issue with the content-type/javax.ws.rs.ext.MessageBodyWriter. If you
look above, you do:

(1) Suspend -> content-type == text/html
(2) Broadcast -> content-type == text/plain
(3) Broadcast -> content-type == text/html

For the sample it works, but (2) would have failed to work properly if
you wanted to write some JSON or JAXB as the MessageBodyWriter was first
created for text/html.

I'm working on a fix for that part as well, but it will require some
Jersey modication.

Thanks!

-- Jeanfrancois

Jeanfrancois Arcand wrote:

>
> Salut,
>
> the following line:
>
>    @Suspend(scope = Suspend.SCOPE.REQUEST)
>
> is causing the "problem" you are observing. Configuring a Broadcaster's
> scope to request means tells Atmosphere to creates a Broadcaster per
> request. In the current scenario, a newly Broadcaster will be created
> when you define:
>
>   public Broadcastable onLogin(@Context UserBroadcaster bc) {
>
> To fix the issue, just do:
>
>    @Suspend
>
> and it will works like you described. I'm coying the test I was using:
>
>> @Path("test")
>> @Singleton
>> public class ResourceChat{
>>
>>     ConcurrentHashMap<String,UserBroadcaster> map = new
>> ConcurrentHashMap<String,UserBroadcaster>();
>>
>>     @Suspend
>>     @GET
>>     @Produces("text/html")
>>     public String pageLoad() {
>>         return "Hello";
>>     }
>>
>>     @Path("login")
>>     @Broadcast
>>     @POST
>>     @Produces("text/plain")
>>     public Broadcastable onLogin(@Context UserBroadcaster bc) {
>>         map.put("user", bc);
>>
>>         String m = "test";
>>         Broadcastable b = new Broadcastable(m, bc);
>>         return b;
>>     }
>>
>>     @Path("action")
>>     @Broadcast
>>     @GET
>>     @Produces("text/html")
>>     public Broadcastable onAction() {
>>         UserBroadcaster bc = map.get("user");
>>
>>         String script = "<script>alert('COMET!');</script>";
>>         Broadcastable b = new Broadcastable(script, bc);
>>         return b;
>>     }
>>
>>
>> }
>
> Hope that help.
>
> A+
>
> -- Jeanfrancois
>
>
>
>
> Jeanfrancois Arcand wrote:
>> Salut,
>>
>> I confirm there is an issue. The injected Broadcaster has a list of
>> empty AtmosphereResource...I will fix this soon :-)
>>
>> Thanks for the test case!
>>
>> -- Jeanfrancois
>>
>> Jeanfrancois Arcand wrote:
>>> Salut,
>>>
>>> Á. Eduardo García wrote:
>>>> Sorry for the delay and all, I'll rephrase my questions, now that
>>>> I've taken
>>>> again this.
>>>
>>> Welcome back!
>>>
>>>>
>>>> I've a class with just this:
>>>> @Path("test")
>>>> @Singleton
>>>> public class test{
>>>>     @Suspend(scope = Suspend.SCOPE.REQUEST)
>>>>     @GET
>>>>     @Produces("text/html")
>>>>     public String pageLoad() {
>>>>         return "Hello";
>>>>     }
>>>>
>>>>     @Path("login")
>>>>     @Broadcast
>>>>     @POST
>>>>     @Produces("text/plain")
>>>>     public Broadcastable onLogin(@Context UserBroadcaster bc) {
>>>>         map.put("user", bc);
>>>>
>>>>         String m = "test";
>>>>         Broadcastable b = new Broadcastable(m, bc);
>>>>         return b;
>>>>     }
>>>>
>>>>     @Path("action")
>>>>     @Broadcast
>>>>     @GET
>>>>     @Produces("text/html")
>>>>     public Broadcastable onAction() {
>>>>         UserBroadcaster bc = uc.get("test");
>>>>
>>>>         String script = "<script>alert('COMET!');</script>";
>>>>         Broadcastable b = new Broadcastable(script, bc);
>>>>         return b;
>>>>     }
>>>> }
>>>>
>>>> Thats simple enough, I think. As you can see, it's almost the same
>>>> as the
>>>> Twitter example. I have two browsers, B1 and B2, and I do this with
>>>> Ajax
>>>> (jQuery):
>>>>
>>>> B1: GET("test"); // This gets suspended
>>>> B1: POST("test/login"); // This returns "test"
>>>> B2: GET("test/action");
>>>>
>>>> On the last call, from another browser, I get my alert showing up,
>>>> but as I
>>>> understand it (obviously I'm wrong) the code must be sent to B1,
>>>> because I'm
>>>> using the Broadcaster saved in the login method and broadcasting
>>>> using it.
>>>> I've also tried to do "bc.broadcast(script);" but no luck either.
>>>
>>> You are right. Let me install the test and see what's hapenning
>>>
>>>
>>>>
>>>> Could someone explain it to me? Basically what I'm trying to do
>>>> right now is
>>>> suspend a browser, store its broadcaster, and later retrieve it to
>>>> send some
>>>> information to that browser from another browser or directly my server
>>>> (that's just comet, isn't it :P)
>>>>
>>>> Thanks a lot in advance, and sorry if I didn't get to the point this
>>>> time,
>>>> again xD
>>>
>>> No that's crystal clear....let me re-create your sample and report back.
>>>
>>> Thanks a lot!
>>>
>>> --Jeanfrancois
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]



Ángel Eduardo García Hernández




Á. Eduardo García

Re: (Application error) <was> Re: Simple usage

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Hello again.

What I thought it was junk was, in fact, the very same data I was sending, but it get's repeated. As I had gzip compression enabled, it turned out like junk.

I think this is some kind of issue with Jersey, because this repeated data is getting into some other endpoint responses not related to Atmosphere (I mean, no @Broadcast or @Resume on that ones, only @POST or @GET and @Produces).

I'm going to try a more recent version of Jersey (1.1.5-ea-SNAPSHOT) to see if I can fix this BIG problem.

I'll keep you posted!

On 17 Oct 2009, at 12:50, Á. Eduardo García (via Nabble) wrote:

Good morning! (At least here :D)

Unfortunately, that didn't seem to work. Worst than that, I've managed to complete screw up Glassfish with this.
What I did exactly:

Using your code (but adding a "@FormParam String param1" to onLogin function, do this calls on two browsers:

I have a page that does:
B1: GET("test")
B1: POST("test/login?param1=undefined&param2=undefined&param3=undefined") // Doesn't know if this params-thing have any to do with the problem, but anyway that's what I did

Reload browser page at least 4 or 5 times

Now, in browser 2
B2: GET("test/action")

First time it usually works, now reload page a few times and I start to get junk. Oddly enough, if my reload sequence gets me "good - junk - junk - good" for example, it repeats itself no matter how may times I retry it.

And finally, if I stop Glassfish, I get a few exceptions in different places every time. Last time was:

SEVERE: java.lang.NullPointerException
SEVERE:         at com.sun.enterprise.deploy.shared.FileArchive.getDirectories(FileArchive.java:158)

...but every time it gets different.

Hope that helps!

On 16 Oct 2009, at 23:00, Á. Eduardo García (via Nabble) wrote:

Hi!

Good to know there is a fix for that! And thanks for the second advice, too, because I was going to do exactly what you were saying: giving text/html to one responses and application/json to others. I'm sure that "bug" would have driven me mad as well :) Obviously I don't know very much about the internals of Jersey / Atmosphere because I though the media type of the response was going to be added after every call and not that atmosphere was going to change any of that :P I'll give all methods an application/json response for now so I can use JSON.

I'll try this first thing in the morning tomorrow at work (hate to work on weekends...). Thanks again, keep the good job :)

2009/10/16 Jeanfrancois Arcand (via Nabble) <[hidden email]>
Actually I've removed the ConcurrentHashMap and instead injected a
BroadcasterLookup instance:

    * http://is.gd/4mSWD

> @Path("test")
> @Singleton
> public class ResourceChat{
>     @Suspend

>     @GET
>     @Produces("text/html")
>     public String pageLoad() {
>         return "Hello";
>     }
>
>     @Path("login")
>     @Broadcast
>     @POST
>     @Produces("text/plain")
>     public Broadcastable onLogin(@Context UserBroadcaster bc) {
>         bc.setName("user");
>
>         String m = "test";
>         Broadcastable b = new Broadcastable(m, bc);
>         return b;
>     }
>
>     @Path("action")
>     @Broadcast
>     @GET
>     @Produces("text/html")
>     public Broadcastable onAction(@Context BroadcasterLookup bcl) throws OutOfScopeException {
>         String script = "<script>alert('COMET!');</script>";
>         Broadcastable b = new Broadcastable(script, bcl.lookup("user"));
>         return b;
>     }
>
>
> }

That way you don't need to handle the life cycle of the HashMap. Now
discussing with Paul today about the Serializer API, we have found an
issue with the content-type/javax.ws.rs.ext.MessageBodyWriter. If you
look above, you do:

(1) Suspend -> content-type == text/html
(2) Broadcast -> content-type == text/plain
(3) Broadcast -> content-type == text/html

For the sample it works, but (2) would have failed to work properly if
you wanted to write some JSON or JAXB as the MessageBodyWriter was first
created for text/html.

I'm working on a fix for that part as well, but it will require some
Jersey modication.

Thanks!

-- Jeanfrancois

Jeanfrancois Arcand wrote:

>
> Salut,
>
> the following line:
>
>    @Suspend(scope = Suspend.SCOPE.REQUEST)
>
> is causing the "problem" you are observing. Configuring a Broadcaster's
> scope to request means tells Atmosphere to creates a Broadcaster per
> request. In the current scenario, a newly Broadcaster will be created
> when you define:
>
>   public Broadcastable onLogin(@Context UserBroadcaster bc) {
>
> To fix the issue, just do:
>
>    @Suspend
>
> and it will works like you described. I'm coying the test I was using:
>
>> @Path("test")
>> @Singleton
>> public class ResourceChat{
>>
>>     ConcurrentHashMap<String,UserBroadcaster> map = new
>> ConcurrentHashMap<String,UserBroadcaster>();
>>
>>     @Suspend
>>     @GET
>>     @Produces("text/html")
>>     public String pageLoad() {
>>         return "Hello";
>>     }
>>
>>     @Path("login")
>>     @Broadcast
>>     @POST
>>     @Produces("text/plain")
>>     public Broadcastable onLogin(@Context UserBroadcaster bc) {
>>         map.put("user", bc);
>>
>>         String m = "test";
>>         Broadcastable b = new Broadcastable(m, bc);
>>         return b;
>>     }
>>
>>     @Path("action")
>>     @Broadcast
>>     @GET
>>     @Produces("text/html")
>>     public Broadcastable onAction() {
>>         UserBroadcaster bc = map.get("user");
>>
>>         String script = "<script>alert('COMET!');</script>";
>>         Broadcastable b = new Broadcastable(script, bc);
>>         return b;
>>     }
>>
>>
>> }
>
> Hope that help.
>
> A+
>
> -- Jeanfrancois
>
>
>
>
> Jeanfrancois Arcand wrote:
>> Salut,
>>
>> I confirm there is an issue. The injected Broadcaster has a list of
>> empty AtmosphereResource...I will fix this soon :-)
>>
>> Thanks for the test case!
>>
>> -- Jeanfrancois
>>
>> Jeanfrancois Arcand wrote:
>>> Salut,
>>>
>>> Á. Eduardo García wrote:
>>>> Sorry for the delay and all, I'll rephrase my questions, now that
>>>> I've taken
>>>> again this.
>>>
>>> Welcome back!
>>>
>>>>
>>>> I've a class with just this:
>>>> @Path("test")
>>>> @Singleton
>>>> public class test{
>>>>     @Suspend(scope = Suspend.SCOPE.REQUEST)
>>>>     @GET
>>>>     @Produces("text/html")
>>>>     public String pageLoad() {
>>>>         return "Hello";
>>>>     }
>>>>
>>>>     @Path("login")
>>>>     @Broadcast
>>>>     @POST
>>>>     @Produces("text/plain")
>>>>     public Broadcastable onLogin(@Context UserBroadcaster bc) {
>>>>         map.put("user", bc);
>>>>
>>>>         String m = "test";
>>>>         Broadcastable b = new Broadcastable(m, bc);
>>>>         return b;
>>>>     }
>>>>
>>>>     @Path("action")
>>>>     @Broadcast
>>>>     @GET
>>>>     @Produces("text/html")
>>>>     public Broadcastable onAction() {
>>>>         UserBroadcaster bc = uc.get("test");
>>>>
>>>>         String script = "<script>alert('COMET!');</script>";
>>>>         Broadcastable b = new Broadcastable(script, bc);
>>>>         return b;
>>>>     }
>>>> }
>>>>
>>>> Thats simple enough, I think. As you can see, it's almost the same
>>>> as the
>>>> Twitter example. I have two browsers, B1 and B2, and I do this with
>>>> Ajax
>>>> (jQuery):
>>>>
>>>> B1: GET("test"); // This gets suspended
>>>> B1: POST("test/login"); // This returns "test"
>>>> B2: GET("test/action");
>>>>
>>>> On the last call, from another browser, I get my alert showing up,
>>>> but as I
>>>> understand it (obviously I'm wrong) the code must be sent to B1,
>>>> because I'm
>>>> using the Broadcaster saved in the login method and broadcasting
>>>> using it.
>>>> I've also tried to do "bc.broadcast(script);" but no luck either.
>>>
>>> You are right. Let me install the test and see what's hapenning
>>>
>>>
>>>>
>>>> Could someone explain it to me? Basically what I'm trying to do
>>>> right now is
>>>> suspend a browser, store its broadcaster, and later retrieve it to
>>>> send some
>>>> information to that browser from another browser or directly my server
>>>> (that's just comet, isn't it :P)
>>>>
>>>> Thanks a lot in advance, and sorry if I didn't get to the point this
>>>> time,
>>>> again xD
>>>
>>> No that's crystal clear....let me re-create your sample and report back.
>>>
>>> Thanks a lot!
>>>
>>> --Jeanfrancois
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]



Ángel Eduardo García Hernández





Ángel Eduardo García Hernández




Viktor Klang

Re: (Application error) <was> Re: Simple usage

Reply Threaded More More options
Print post
Permalink

I saw duplicates when I had manually added the Jersey atmosphere filter, atmosphere now injects its jersey config automatically, so please verify that you're not adding the filter as well.

On Oct 18, 2009 2:02 PM, "Á. Eduardo García" <[hidden email]> wrote:

Hello again.

What I thought it was junk was, in fact, the very same data I was sending, but it get's repeated. As I had gzip compression enabled, it turned out like junk.

I think this is some kind of issue with Jersey, because this repeated data is getting into some other endpoint responses not related to Atmosphere (I mean, no @Broadcast or @Resume on that ones, only @POST or @GET and @Produces).

I'm going to try a more recent version of Jersey (1.1.5-ea-SNAPSHOT) to see if I can fix this BIG problem.

I'll keep you posted!

On 17 Oct 2009, at 12:50, Á. Eduardo García (via Nabble) wrote: > Good morning! (At least here :D...

Á. Eduardo García

Re: (Application error) <was> Re: Simple usage

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Hi, and thanks!

Unfortunately, this isn't the case. I already removed filters when migrating, and I don't get duplicates, exactly. I get the same output 3, 4 or more times, depending on what you do. Also, other queries to other endpoints returns with the PUSHed data appended to them, it's all very strange. I'm going to try with the latest Jersey as I said, I'll shout if I get something.

On 18 Oct 2009, at 14:48, Viktor Klang (via Nabble) wrote:

I saw duplicates when I had manually added the Jersey atmosphere filter, atmosphere now injects its jersey config automatically, so please verify that you're not adding the filter as well.


On Oct 18, 2009 2:02 PM, "Á. Eduardo García" <[hidden email]> wrote:

Hello again.

What I thought it was junk was, in fact, the very same data I was sending, but it get's repeated. As I had gzip compression enabled, it turned out like junk.

I think this is some kind of issue with Jersey, because this repeated data is getting into some other endpoint responses not related to Atmosphere (I mean, no @Broadcast or @Resume on that ones, only @POST or @GET and @Produces).

I'm going to try a more recent version of Jersey (1.1.5-ea-SNAPSHOT) to see if I can fix this BIG problem.

I'll keep you posted!

On 17 Oct 2009, at 12:50, Á. Eduardo García (via Nabble) wrote: > Good morning! (At least here :D...



Ángel Eduardo García Hernández




Á. Eduardo García

Re: (Application error) <was> Re: Simple usage

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Ok, I've done two things that have stopped this issue, at least that's what I think, but I don't know which one is the "good" one.

I've used Jersey 1.1.5 (but I don't know if it's in use, because Glassfish itself has Jersey 1.1.3 in it's own libraries, and when I start the server it says something like:

INFO: Initiating Jersey application, version 'Jersey: 1.1.3-ea 10/06/2009 05:16 PM'

...so I don't really know which libraries are really in use.

Another thing I've done is calling an unload endpoint to @Resume the connection at every refresh of the page.

Anyway, now it's working. I'll have to further investigate this issue, too, because I cannot risk having it on a production server.

Bye!

On 18 Oct 2009, at 16:02, Á. Eduardo García (via Nabble) wrote:

Hi, and thanks!

Unfortunately, this isn't the case. I already removed filters when migrating, and I don't get duplicates, exactly. I get the same output 3, 4 or more times, depending on what you do. Also, other queries to other endpoints returns with the PUSHed data appended to them, it's all very strange. I'm going to try with the latest Jersey as I said, I'll shout if I get something.

On 18 Oct 2009, at 14:48, Viktor Klang (via Nabble) wrote:

I saw duplicates when I had manually added the Jersey atmosphere filter, atmosphere now injects its jersey config automatically, so please verify that you're not adding the filter as well.


On Oct 18, 2009 2:02 PM, "Á. Eduardo García" <[hidden email]> wrote:

Hello again.

What I thought it was junk was, in fact, the very same data I was sending, but it get's repeated. As I had gzip compression enabled, it turned out like junk.

I think this is some kind of issue with Jersey, because this repeated data is getting into some other endpoint responses not related to Atmosphere (I mean, no @Broadcast or @Resume on that ones, only @POST or @GET and @Produces).

I'm going to try a more recent version of Jersey (1.1.5-ea-SNAPSHOT) to see if I can fix this BIG problem.

I'll keep you posted!

On 17 Oct 2009, at 12:50, Á. Eduardo García (via Nabble) wrote: > Good morning! (At least here :D...



Ángel Eduardo García Hernández





Ángel Eduardo García Hernández




Jeanfrancois Arcand

Re: (Application error) <was> Re: Simple usage

Reply Threaded More More options
Print post
Permalink
In reply to this post by Viktor Klang


Viktor Klang wrote:
> I saw duplicates when I had manually added the Jersey atmosphere filter,
> atmosphere now injects its jersey config automatically, so please verify
> that you're not adding the filter as well.

Oh!!! I need to add this information in the Migration Document!!!

Nice catch!

-- Jeanfrancois


>
>> On Oct 18, 2009 2:02 PM, "Á. Eduardo García" <[hidden email]
>> <mailto:[hidden email]>> wrote:
>>
>> Hello again.
>>
>> What I thought it was junk was, in fact, the very same data I was
>> sending, but it get's repeated. As I had gzip compression enabled, it
>> turned out like junk.
>>
>> I think this is some kind of issue with Jersey, because this repeated
>> data is getting into some other endpoint responses not related to
>> Atmosphere (I mean, no @Broadcast or @Resume on that ones, only @POST
>> or @GET and @Produces).
>>
>> I'm going to try a more recent version of Jersey (1.1.5-ea-SNAPSHOT)
>> to see if I can fix this BIG problem.
>>
>> I'll keep you posted!
>>
>> On 17 Oct 2009, at 12:50, Á. Eduardo García (via Nabble) wrote: > Good
>> morning! (At least here :D...
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Jeanfrancois Arcand

Re: (Application error) <was> Re: Simple usage

Reply Threaded More More options
Print post
Permalink
In reply to this post by Á. Eduardo García


Á. Eduardo García wrote:

> Ok, I've done two things that have stopped this issue, at least that's
> what I think, but I don't know which one is the "good" one.
>
> I've used Jersey 1.1.5 (but I don't know if it's in use, because
> Glassfish itself has Jersey 1.1.3 in it's own libraries, and when I
> start the server it says something like:
>
> INFO: Initiating Jersey application, version 'Jersey: 1.1.3-ea
> 10/06/2009 05:16 PM'
>
> ...so I don't really know which libraries are really in use.
>
> Another thing I've done is calling an unload endpoint to @Resume the
> connection at every refresh of the page.
>
> Anyway, now it's working. I'll have to further investigate this issue,
> too, because I cannot risk having it on a production server.


I think I've already asked you, but can you share privately your sample?
I really want (at least) to understand what's happening and why you are
seeing duplicata. The NPE you pointed out usually happens when GF runs
out of file descriptor.

Thanks!

-- Jeanfrancois


>
> Bye!
>
> On 18 Oct 2009, at 16:02, Á. Eduardo García (via Nabble) wrote:
>
>> Hi, and thanks!
>>
>> Unfortunately, this isn't the case. I already removed filters when
>> migrating, and I don't get duplicates, exactly. I get the same output
>> 3, 4 or more times, depending on what you do. Also, other queries to
>> other endpoints returns with the PUSHed data appended to them, it's
>> all very strange. I'm going to try with the latest Jersey as I said,
>> I'll shout if I get something.
>>
>> On 18 Oct 2009, at 14:48, Viktor Klang (via Nabble) wrote:
>>
>>> I saw duplicates when I had manually added the Jersey atmosphere
>>> filter, atmosphere now injects its jersey config automatically, so
>>> please verify that you're not adding the filter as well.
>>>
>>>
>>>> On Oct 18, 2009 2:02 PM, "Á. Eduardo García" <[hidden email]
>>>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3844223&i=0>>
>>>> wrote:
>>>>
>>>> Hello again.
>>>>
>>>> What I thought it was junk was, in fact, the very same data I was
>>>> sending, but it get's repeated. As I had gzip compression enabled,
>>>> it turned out like junk.
>>>>
>>>> I think this is some kind of issue with Jersey, because this
>>>> repeated data is getting into some other endpoint responses not
>>>> related to Atmosphere (I mean, no @Broadcast or @Resume on that
>>>> ones, only @POST or @GET and @Produces).
>>>>
>>>> I'm going to try a more recent version of Jersey (1.1.5-ea-SNAPSHOT)
>>>> to see if I can fix this BIG problem.
>>>>
>>>> I'll keep you posted!
>>>>
>>>> On 17 Oct 2009, at 12:50, Á. Eduardo García (via Nabble) wrote: >
>>>> Good morning! (At least here :D...
>>>>
>>>
>>
>> Ángel Eduardo García Hernández
>> [hidden email]
>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3844453&i=1>
>>
>>
>>
>>
>
> Ángel Eduardo García Hernández
> [hidden email]
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3845270&i=1>
>
>
>
>
>
> ------------------------------------------------------------------------
> View this message in context: Re: (Application error) Re: Simple usage
> <http://n2.nabble.com/Simple-usage-tp3617675p3845270.html>
> Sent from the Atmosphere users mailling list mailing list archive
> <http://n2.nabble.com/Atmosphere-users-mailling-list-f2493822.html> at
> Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Á. Eduardo García

Re: (Application error) <was> Re: Simple usage

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Today I'm in a big rush, because I've a demo in a few hours (I've replaced Comet with polling, because I'm having a lot of problems besides that, but I'll give you a detailed report in a few hours, a day tops) but I'll compile my test and send you my code later if I have the time. I don't think I'm doing anything fancy, but what I really think is that I'm using Atmosphere in some non-intended way :P

Anyway, thanks a lot for your concerns!!

On 19 Oct 2009, at 15:51, Jeanfrancois Arcand (via Nabble) wrote:



Á. Eduardo García wrote:

> Ok, I've done two things that have stopped this issue, at least that's
> what I think, but I don't know which one is the "good" one.
>
> I've used Jersey 1.1.5 (but I don't know if it's in use, because
> Glassfish itself has Jersey 1.1.3 in it's own libraries, and when I
> start the server it says something like:
>
> INFO: Initiating Jersey application, version 'Jersey: 1.1.3-ea
> 10/06/2009 05:16 PM'
>
> ...so I don't really know which libraries are really in use.
>
> Another thing I've done is calling an unload endpoint to @Resume the
> connection at every refresh of the page.
>
> Anyway, now it's working. I'll have to further investigate this issue,
> too, because I cannot risk having it on a production server.

I think I've already asked you, but can you share privately your sample?
I really want (at least) to understand what's happening and why you are
seeing duplicata. The NPE you pointed out usually happens when GF runs
out of file descriptor.

Thanks!

-- Jeanfrancois


>
> Bye!
>
> On 18 Oct 2009, at 16:02, Á. Eduardo García (via Nabble) wrote:
>
>> Hi, and thanks!
>>
>> Unfortunately, this isn't the case. I already removed filters when
>> migrating, and I don't get duplicates, exactly. I get the same output
>> 3, 4 or more times, depending on what you do. Also, other queries to
>> other endpoints returns with the PUSHed data appended to them, it's
>> all very strange. I'm going to try with the latest Jersey as I said,
>> I'll shout if I get something.
>>
>> On 18 Oct 2009, at 14:48, Viktor Klang (via Nabble) wrote:
>>
>>> I saw duplicates when I had manually added the Jersey atmosphere
>>> filter, atmosphere now injects its jersey config automatically, so
>>> please verify that you're not adding the filter as well.
>>>
>>>
>>>> On Oct 18, 2009 2:02 PM, "Á. Eduardo García" <[hidden email]
>>>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3844223&i=0>>
>>>> wrote:
>>>>
>>>> Hello again.
>>>>
>>>> What I thought it was junk was, in fact, the very same data I was
>>>> sending, but it get's repeated. As I had gzip compression enabled,
>>>> it turned out like junk.
>>>>
>>>> I think this is some kind of issue with Jersey, because this
>>>> repeated data is getting into some other endpoint responses not
>>>> related to Atmosphere (I mean, no @Broadcast or @Resume on that
>>>> ones, only @POST or @GET and @Produces).
>>>>
>>>> I'm going to try a more recent version of Jersey (1.1.5-ea-SNAPSHOT)
>>>> to see if I can fix this BIG problem.
>>>>
>>>> I'll keep you posted!
>>>>
>>>> On 17 Oct 2009, at 12:50, Á. Eduardo García (via Nabble) wrote: >
>>>> Good morning! (At least here :D...
>>>>
>>>
>>
>> Ángel Eduardo García Hernández
>> [hidden email]
>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3844453&i=1>
>>
>>
>>
>>
>
> Ángel Eduardo García Hernández
> [hidden email]
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3845270&i=1>
>
>
>
>
>
> ------------------------------------------------------------------------
> View this message in context: Re: (Application error) Re: Simple usage
> <http://n2.nabble.com/Simple-usage-tp3617675p3845270.html>
> Sent from the Atmosphere users mailling list mailing list archive
> <http://n2.nabble.com/Atmosphere-users-mailling-list-f2493822.html> at
> Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]


Ángel Eduardo García Hernández




Viktor Klang

Re: (Application error) <was> Re: Simple usage

Reply Threaded More More options
Print post
Permalink
In reply to this post by Jeanfrancois Arcand


On Mon, Oct 19, 2009 at 3:49 PM, Jeanfrancois Arcand <[hidden email]> wrote:


Viktor Klang wrote:
I saw duplicates when I had manually added the Jersey atmosphere filter, atmosphere now injects its jersey config automatically, so please verify that you're not adding the filter as well.

Oh!!! I need to add this information in the Migration Document!!!

Nice catch!

Ah, sorry, completely forgot about it until Eduardo mentioned it :(
 

-- Jeanfrancois




On Oct 18, 2009 2:02 PM, "Á. Eduardo García" <[hidden email] <mailto:[hidden email]>> wrote:

Hello again.

What I thought it was junk was, in fact, the very same data I was sending, but it get's repeated. As I had gzip compression enabled, it turned out like junk.

I think this is some kind of issue with Jersey, because this repeated data is getting into some other endpoint responses not related to Atmosphere (I mean, no @Broadcast or @Resume on that ones, only @POST or @GET and @Produces).

I'm going to try a more recent version of Jersey (1.1.5-ea-SNAPSHOT) to see if I can fix this BIG problem.

I'll keep you posted!

On 17 Oct 2009, at 12:50, Á. Eduardo García (via Nabble) wrote: > Good morning! (At least here :D...


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]




--
Viktor Klang

Blog: klangism.blogspot.com
Twttr: viktorklang
Wave: [hidden email]
Code: github.com/viktorklang

AKKA Committer - akkasource.org
Lift Committer - liftweb.com
Atmosphere Committer - atmosphere.dev.java.net
SoftPub founder: http://groups.google.com/group/softpub
Jeanfrancois Arcand

Re: (Application error) <was> Re: Simple usage

Reply Threaded More More options
Print post
Permalink
In reply to this post by Á. Eduardo García


Á. Eduardo García wrote:
> Today I'm in a big rush, because I've a demo in a few hours (I've
> replaced Comet with polling, because I'm having a lot of problems
> besides that, but I'll give you a detailed report in a few hours, a day
> tops) but I'll compile my test and send you my code later if I have the
> time. I don't think I'm doing anything fancy, but what I really think is
> that I'm using Atmosphere in some non-intended way :P
>
> Anyway, thanks a lot for your concerns!!

Thanks! I will wait for doing the release just to make sure nothing
trivial is broken. I will play on my side with the sample I've written
last week. I need to enable GZIp, right? I think that's the issue as
this Grizzly Filter might not work with Comet (who wrote that!!! :-) :-))

A+

-- Jeanfrancois


>
> On 19 Oct 2009, at 15:51, Jeanfrancois Arcand (via Nabble) wrote:
>
>>
>>
>> Á. Eduardo García wrote:
>>
>> > Ok, I've done two things that have stopped this issue, at least that's
>> > what I think, but I don't know which one is the "good" one.
>> >
>> > I've used Jersey 1.1.5 (but I don't know if it's in use, because
>> > Glassfish itself has Jersey 1.1.3 in it's own libraries, and when I
>> > start the server it says something like:
>> >
>> > INFO: Initiating Jersey application, version 'Jersey: 1.1.3-ea
>> > 10/06/2009 05:16 PM'
>> >
>> > ...so I don't really know which libraries are really in use.
>> >
>> > Another thing I've done is calling an unload endpoint to @Resume the
>> > connection at every refresh of the page.
>> >
>> > Anyway, now it's working. I'll have to further investigate this issue,
>> > too, because I cannot risk having it on a production server.
>>
>> I think I've already asked you, but can you share privately your sample?
>> I really want (at least) to understand what's happening and why you are
>> seeing duplicata. The NPE you pointed out usually happens when GF runs
>> out of file descriptor.
>>
>> Thanks!
>>
>> -- Jeanfrancois
>>
>>
>> >
>> > Bye!
>> >
>> > On 18 Oct 2009, at 16:02, Á. Eduardo García (via Nabble) wrote:
>> >
>> >> Hi, and thanks!
>> >>
>> >> Unfortunately, this isn't the case. I already removed filters when
>> >> migrating, and I don't get duplicates, exactly. I get the same output
>> >> 3, 4 or more times, depending on what you do. Also, other queries to
>> >> other endpoints returns with the PUSHed data appended to them, it's
>> >> all very strange. I'm going to try with the latest Jersey as I said,
>> >> I'll shout if I get something.
>> >>
>> >> On 18 Oct 2009, at 14:48, Viktor Klang (via Nabble) wrote:
>> >>
>> >>> I saw duplicates when I had manually added the Jersey atmosphere
>> >>> filter, atmosphere now injects its jersey config automatically, so
>> >>> please verify that you're not adding the filter as well.
>> >>>
>> >>>
>> >>>> On Oct 18, 2009 2:02 PM, "Á. Eduardo García" <[hidden email]
>> >>>>
>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3844223&i=0 
>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3844223&i=0>>>
>> >>>> wrote:
>> >>>>
>> >>>> Hello again.
>> >>>>
>> >>>> What I thought it was junk was, in fact, the very same data I was
>> >>>> sending, but it get's repeated. As I had gzip compression enabled,
>> >>>> it turned out like junk.
>> >>>>
>> >>>> I think this is some kind of issue with Jersey, because this
>> >>>> repeated data is getting into some other endpoint responses not
>> >>>> related to Atmosphere (I mean, no @Broadcast or @Resume on that
>> >>>> ones, only @POST or @GET and @Produces).
>> >>>>
>> >>>> I'm going to try a more recent version of Jersey (1.1.5-ea-SNAPSHOT)
>> >>>> to see if I can fix this BIG problem.
>> >>>>
>> >>>> I'll keep you posted!
>> >>>>
>> >>>> On 17 Oct 2009, at 12:50, Á. Eduardo García (via Nabble) wrote: >
>> >>>> Good morning! (At least here :D...
>> >>>>
>> >>>
>> >>
>> >> Ángel Eduardo García Hernández
>> >> [hidden email]
>> >> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3844453&i=1 
>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3844453&i=1>>
>> >>
>> >>
>> >>
>> >>
>> >
>> > Ángel Eduardo García Hernández
>> > [hidden email]
>> > <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3845270&i=1 
>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3845270&i=1>>
>> >
>> >
>> >
>> >
>> >
>> >
>> ------------------------------------------------------------------------
>> > View this message in context: Re: (Application error) Re: Simple usage
>> > <http://n2.nabble.com/Simple-usage-tp3617675p3845270.html>
>> > Sent from the Atmosphere users mailling list mailing list archive
>> > <http://n2.nabble.com/Atmosphere-users-mailling-list-f2493822.html> at
>> > Nabble.com.
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3849128&i=0>
>> For additional commands, e-mail: [hidden email]
>> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3849128&i=1>
>>
>
> Ángel Eduardo García Hernández
> [hidden email]
> <http://n2.nabble.com/user/SendEmail.jtp?type=node&node=3849148&i=1>
>
>
>
>
>
> ------------------------------------------------------------------------
> View this message in context: Re: (Application error) Re: Simple usage
> <http://n2.nabble.com/Simple-usage-tp3617675p3849148.html>
> Sent from the Atmosphere users mailling list mailing list archive
> <http://n2.nabble.com/Atmosphere-users-mailling-list-f2493822.html> at
> Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]