New user - Unable to see broadcast responses

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

New user - Unable to see broadcast responses

erked
This post has NOT been accepted by the mailing list yet.
This post was updated on .
Hello,

Pardon for any violations of etiquette or formatting; I'm not sure what format characters to use for the code, so will leave it all plain text for now.

I'm using the Jersey integration for the first time, having previously used Atmosphere MeteorServlet, and I've been unable to get responses back on the client (a curl command line, which I also successfully used with MeteorServlet). I'll post my configuration and code, then add some questions and comments.

First, the bulk of my web.xml:
  <servlet>
    <servlet-name>ResourceOrientedService</servlet-name>
    <servlet-class>org.atmosphere.cpr.AtmosphereServlet</servlet-class>
    <init-param>
                <param-name>org.atmosphere.core.servlet-mapping</param-name>
                <param-value>/presenter</param-value>
        </init-param>
        <init-param>
                <param-name>org.atmosphere.jersey.servlet-mapping</param-name>
                <param-value>/presenter</param-value>
        </init-param>
    <init-param>
          <param-name>com.sun.jersey.config.property.packages</param-name>
          <param-value>comotion.presenters.transport.server.rest</param-value>
        </init-param>
    <load-on-startup>0</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>ResourceOrientedService</servlet-name>
    <url-pattern>/presenter/*</url-pattern>
  </servlet-mapping> 

Next, the relevant Jersey Resource code:
...
  @GET
  @Suspend(scope=SCOPE.REQUEST, resumeOnBroadcast=false)
  public Broadcastable startListening(@PathParam("presenterType") final String type,
                               @PathParam("uuid") final String uuid,
                               @Context Broadcaster broadcaster)
  {
    // get an internal context, which includes a unique session ID
    final IntentContext intentContext = getOrCreateSessionContext();
    // this method also registers listeners which end up calling
    final PresenterId presenterId = findOrCreatePresentation(intentContext,
        uuid, type);
    final Presentation presentation = intentContext.getPresenter(presenterId);
    broadcaster.setID(intentContext.getSessionId());
    return new Broadcastable("Connecting to " + type + " configured for UUID=" + uuid,
        broadcaster);
  }

  @Broadcast(writeEntity=true, resumeOnBroadcast=false)
  public Broadcastable broadcast(final Broadcaster broadcaster,
                                                 final IntentContext context,
                                                 final PresenterId presenterId,
                                                 final IonDelta change)
  {
    // These log messages are appearing, so we're getting here!
    LOGGER_.fine("broadcast", "Broadcasting, using Broadcaster ID=" + broadcaster.getID());
    LOGGER_.fine("broadcast", "Broadcaster has resources: " + broadcaster.getAtmosphereResources());
    // create the @XmlRootElement annotated representation, from the change
    PresenterUpdateRepresentation rep = new PresenterUpdateRepresentation(change);
    return new Broadcastable(rep, broadcaster);
  }

    /** This is the main callback, set up in the call to getOrCreateSessionContext() above */
    public void processUpdateRequest(IonDelta update, IntentContext context)
    {
      Broadcaster broadcaster = BroadcasterFactory.getDefault().lookup(JerseyBroadcaster.class, context.getSessionId());
      if (broadcaster != null)
      {
        broadcast(broadcaster, context, update.getPresenterId(), update);
      }
    }

...

Now the client call, and the output I see:
$ curl -v -u System http://localhost:8080/ions/presenter/SubjectPresenter/0x080e000001383357f40f0af1045a800c
* About to connect() to localhost port 8080 (#0)
*   Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 8080 (#0)
* Server auth using Basic with user 'System'
> GET /ions/presenter/SubjectPresenter/0x080e000001383357f40f0af1045a800c HTTP/1.1
> Authorization: Basic SGVscGRlc2s6SGVscGRlc2s=
> User-Agent: curl/7.20.1 (i686-pc-cygwin) libcurl/7.20.1 OpenSSL/0.9.8r zlib/1.2.5 libidn/1.18 libssh2/1.2.5
> Host: localhost:8080
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Set-Cookie: JSESSIONID=054C39B3691DE23F79850F7D0241F9A2; Path=/ions
< Expires: -1
< Cache-Control: no-store, no-cache, must-revalidate
< Pragma: no-cache
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Credentials: true
< Content-Type: application/json
< Transfer-Encoding: chunked
< Date: Thu, 19 Jul 2012 19:48:46 GMT
<
!-- ---------------------------------------------------------------- http://github.com/Atmosphere -------------------------------------------------------------
----------- -->
!-- Welcome to the Atmosphere Framework. To work with all the browsers when suspending connection, Atmosphere must output some data to makes WebKit based browser working.-->
!-- ---------------------------------------------------------------------------
--------------------------------------------------------------------------------
...
[and I never see anything in the response, except these boilerplate comments - the connection stays open, but nothing I try to broadcast gets back to the client, as far as I can tell]

Finally, some comments:
- I know that the internal callback, processUpdateRequest(), is getting invoked by the internal machinery. I make a change that affects the database, and the listeners do call into that method, which then calls into broadcast().
- In my logs, I see this log entry showing the AtmosphereResource to which the Broadcaster is going to send:
FINE: Broadcaster has resources: [AtmosphereResourceImpl{, hasCode-1943228248,
 action=org.atmosphere.cpr.AtmosphereServlet$Action@6607cbc2,
 broadcaster=org.atmosphere.jersey.JerseyBroadcaster,
 cometSupport=org.atmosphere.container.BlockingIOCometSupport@9d261e3,
 serializer=null,
 isInScope=true,
 useWriter=true,
 listeners=[]}]

I'm a bit confused by the precise meaning of writeEntity on both the @Suspend method and the @Broadcast method, but have tried all the combinations I can think to try.

I'd appreciate any advice at all. Thank you!

- Eric
Reply | Threaded
Open this post in threaded view
|

Re: New user - Unable to see broadcast responses

jfarcand
Administrator
This post has NOT been accepted by the mailing list yet.
Wrong mailing list: atmosphere-framework@googlegroups.com
Reply | Threaded
Open this post in threaded view
|

Re: New user - Unable to see broadcast responses

erked
This post has NOT been accepted by the mailing list yet.
Thanks - I'll have to do it from home (Google Groups is blocked from work). I was just going through the standard new user setup, and haven't used a Nabble site before. The mailing list registration email had an error - some unrouteable address problem.

Thanks again!