Google AppEngine Java Channel API Basic Example

Hi all ,

Currently  i’m working on Google App Engine with Channel API. I just needed basic socket example. I’ll show you how to create basic example.


  1. Setup Eclipse Google App Engine Plugin
  2. Send Message From Servlet to Client
  3. Client Listener
  4. Deploy..

How to Install Google App Engine Eclipse Plugin

Note : When you downloading Eclipse choose the EE version. Check your Eclipse version under the eclipse directory in “.eclipseproduct”. If your version is under 3.8 you’ll be able to install from local archive. Please Check the plugin that corresponds to your version of Eclipse. I’m using Kepler 4.3:

  • Help->Install New Software  add your location and install SDK. (I only need this for socket example)
  • Restart Eclipse
  • File->New->Web Application Project
  • Done!!

Basic Java Servlet

Message Sender Servlet

package com.mtigdemir;


import javax.servlet.http.*;


public class ServletTest extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
	ChannelService channelService = ChannelServiceFactory.getChannelService();
	channelService.sendMessage(new ChannelMessage("logger", "Connection Testing.. "));



<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi=""
	xmlns="" xmlns:web=""


Basic Client

Channel API Javascript Socket Listener

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.List" %>
<%@ page import="" %>
<%@ page import="" %>
<%@ page import="" %>
<%@ page import="com.bumin.model.Todo" %>
<%@ page import="com.bumin.dao.Dao" %>

<%@ page import="" %>
<%@ page import="" %>
<%@page import="java.util.ArrayList"%>


ChannelService channelService = ChannelServiceFactory.getChannelService();
String token = channelService.createChannel("logger");


<!DOCTYPE html>
        <script src='//'></script>
        <script src="/_ah/channel/jsapi"></script>
    var token ="<%=token %>";// This will creaete unique identifier(some id created by google api + ur key)

	channel = new goog.appengine.Channel('<%=token%>');    
	    socket =;    
	socket.onopen = function() {$('#messages').append('<p>Connected!</p>'); };
    socket.onmessage = function(message) {
    console.log('message' + message); 
    	$('#messages').append('<p>' + + '</p>');
    socket.onerror = function() { $('#messages').append('<p>Connection Error!</p>'); };
    socket.onclose = function() { $('#messages').append('<p>Connection Closed!</p>'); };        
		LOG Messages
		<p id="messages"></p>


Sign In with your Google Account

Until you want to deploy your project to Google Server this step isn’t necesary. But live is better and also free until charge limits :))

Daily Quata limits can be change day by day

Resource Free Default Limit Billing Enabled Default Limit
Daily Limit Maximum Rate Daily Limit Maximum Rate
Channel API Calls 657,000 calls 3,000 calls/minute 91,995,495 calls 32,000 calls/minute
Channels Created 100 channels 6 creations/minute Based on your budget 60 creations/minute
Channel Hours Requested 200 hours 12 hours requested/minute Based on your budget 180 hours requested/minute
Channel Data Sent Up to the Outgoing Bandwidth quota 22 MB/minute 1 TB 740 MB/minute
  • Right click your project Google-> Deploy to App Engine that’s it!!


Let’s run at local http://localhost:8888/Logger.jsp http://localhost:8888/test?message=mymessage    open together.

Channel API Final
Channel API Final

You’ll see push notification when get the “/test” route. parameter is “message”There is my Live Application :’t Forget the open

Muharrem Tığdemir


Muharrem Tığdemir

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.