Finally we have all the basics that are needed for building an Autocomplete service and now comes the juicy part. From now on we are looking at how to make it fast and robust. In the current approach we open a new Data base connection for every HTTP request. This needs quite some time to lock the data base (at least when using neo4j in the embedded mode) and then also to run the query without having any opportunities to use the caching strategy of the data base.

In this tutorial I will introduce you to the concept of a ContextListener. This is roughly spoken a way of storing objects in the Java Servlet global memory using key value pairs. Once we understand this the roadmap is very clear. We can store objects like data base connections or search indices in the memory of our web server. As from what I currently understand this could also be used to implement some server side caching. I did not do any benchmarking yet testing how fast retrieving objects from context works in tomcat. Also this method of caching does not scale horizontally well as using memcached.

Anyway have fun learning about the context listener.

If you have any suggestions, comments or thoughts or even know of some solid benchmarks about caching using the ServletContext (I did a quick web search for a view minutes and didn’t find any) feel free to contact me and discuss this!

If you like this post, you might like these related posts:

  1. Building an Autocompletion on GWT with RPC, ContextListener and a Suggest Tree: Part 0 Over the last weeks there was quite some quality programming...
  2. Building an Autocomplete Service in GWT screencast Part 4: Integrating the neo4j Data base In this screencast of my series I explain at a...
  3. Building an Autocompletion on GWT screencast Part 1: Getting Warm – Reviewing remote procedure calls Quite a while ago I promised to create some screencasts...
  4. Building an Autocompletion on GWT screencast Part 2: Invoking The Remote Procedure Call Hey everyone after posting my first screencast in this series...
  5. Building an Autocomplete Service in GWT screencast Part 3: Getting the Server code to send a basic response In this screencast of my series on building an autocomplete...


Tags: , , , , , , , , ,

1 Comment on GWT + database connection in Servlet ContextListener – Auto Complete Video Tutorial Part 5

Leave a Reply



Subscribe to my newsletter

You don't like mail?