Dynamic Web Services

Dynamic Web Services

Dynamic Web Services

 Five years back one of my co-developer always asks me this question, wouldn't life will lot easier if we have a way to deploy code at runtime on production/staging??? 

Back then deploying app on production/staging/qa itself was hell job and today condition is just improved but still ... problem :) 

So the discussion is how can we deploy code on server runtime. Back then we talked couple of approach but result was not expected!

Today, I decided to write something. Approach to test/deploy piece of code on qa/staging/production runtime without shutting down the server.

I decided to write POC, here it is: https://github.com/nileshdarade/dynamicws

Basically use case is:

Server is running on staging/production and you want to quick release of API but scared to make change and release it as you need to take server down to test it. This is the scary part, People hate down time. You don't want server to down for testing! Isn't better you can test an API in production before release it on production!

If you know what I mean developers, here is way you can test your API on production before releasing on production :)

Here is the code:

 Background: We have REST service GET http://host/library which returns the default book name.

now you want new feature you want new API which return something which new feature, you developed this feature but you can not test it on production without restarting :) we created new project book1.1which has dependency on our existing project which is dynamicws. we wrote new logic inside new book1.1 project class BookImpl_1_1  which is same class as BookImpl.

package com.nilesh.dynamicws;

public class BookImpl_1_1 implements Book{

   @Override

   public String getName() {

      return "I'm dynamic book1";

    }

}

We build this jar add to the parallel to the jar which is running on staging/production,

http://host/library?jarName=book1.1.jar&className=com.nilesh.dynamicws.BookImpl_1_1

and wollah you get new jar response will be :) "I'm dynamic book1" the one which you just developed.

Finally we created dynamic webservice so can call http://host/library and http://host/library?jarName=book1.1.jar&className=com.nilesh.dynamicws.BookImpl_1_1

and get two different responses.

Clone https://github.com/nileshdarade/dynamicws build/run and enjoy!

To view or add a comment, sign in

Others also viewed

Explore content categories