title: Atmosphere integration with Spring MVC framework:
body: <p>I succeeded to make simple and small example which integrates between Spring MVC and Atmosphere framework. It works very well, but it behaves the way I'm failing to understand:</p>
  
  <p>In my try example i'm trying to broadcust <code>Date</code> string every 10 seconds, so If I start my app  at 10:10:20 the next message will be 10:10:30, etc.... </p>
  
  <p>but instead of it I have 4 callbacks within this period of time so my message flow looks like this: 10:10:20, 10:10:21, 10:10:22, 10:24, 10:10:30. This behavior occurs sequentially with the same perion of time:</p>
  
  <p>Why do I have 4 callbacks in 10 seconds instead of single one every 10 seconds?</p>
  
  <p>My relevant code is:</p>
  
  <pre><code> @RequestMapping(value="/websockets", method=RequestMethod.GET)
   @ResponseBody
   public void websockets(final AtmosphereResource&lt;HttpServletRequest,HttpServletResponse&gt; event) {
  
        final HttpServletRequest  req = event.getRequest();
          final HttpServletResponse res = event.getResponse();
          event.suspend();
  
          final Broadcaster bc = event.getBroadcaster();
          bc.scheduleFixedBroadcast(new Callable&lt;String&gt;() {
  
              public String call() throws Exception {
  
                  return (new Date()).toString();
              }
          }, 10, TimeUnit.SECONDS);
   }
  </code></pre>
  
  <p>and on my client code I'm doing the following:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  $(document).ready(function() {
       var callbackAdded = false;
  
            function callback(response)
            {
  
                $.atmosphere.log('info', ["response.state: " + response.state]);
                $.atmosphere.log('info', ["response.transport: " + response.transport]);
  
                if (response.transport != 'polling' &amp;&amp; response.state != 'connected' &amp;&amp; response.state != 'closed') {
                    $.atmosphere.log('info', ["response.responseBody: " + response.responseBody]);
                    if (response.status == 200) {
                        var data = response.responseBody;
  
                        if (data) {
                            $("#date").text(data);
                        }
                    }
                }
            }
            $.atmosphere.subscribe("websockets",
                    !callbackAdded? callback : null,
            $.atmosphere.request = {transport: 'websocket'});
            connectedEndpoint = $.atmosphere.response;
            callbackAdded = true;
  });
  &lt;/script&gt;
  </code></pre>