1

I have two web app that runs on the same machine. Both web apps on the same machine need to call each other but without going into HTTP.

One web app is the REST Servlet and the other one is the DATABASE servlet.

The DATABASE servlet running have methods within it's codebase:

 <T> Map<String, Comparable> getFirstEntity(
      String instance,
      String namespace,
      final String kind,
      final String propertyKey,
      final Comparable<T> propertyVal,
      Class<T> clazz);

and

  boolean createEntity(
      String instance,
      String namespace,
      String entityType,
      String entityId,
      Map<String, Comparable> comparableMap,
      final String[] read,
      final String[] write,
      final Boolean publicRead,
      final Boolean publicWrite,
      final EntityMetadata metadata);

Obviously, the "REST Servlet" can call these methods if it exposed as HTTP endpoints, but as mentioned, the two servlet must be able to communicate without going through exposing these methods as HTTP endpoints.

What's the best way for the "REST Servlet" to be able to "invoke" these methods?

E.g. calling it like:

Map<String, Comparable> comparableMap = buildEntity();
databaseAppProxy.createEntity(instance, DEFAULT, entityType, "1-0", comparableMap, null, null, false, false, metadata);

As well as,

Map<String, Comparable> result = databaseAppProxy.getFirstEntity(instance, DEFAULT, entityType, "age", 40, Integer.class);

These calls will then be "proxied" then from the DATABASE servlet running it will be executed.

quarks
  • 33,478
  • 73
  • 290
  • 513
  • 1
    https://stackoverflow.com/questions/10942427/how-to-have-2-jvms-talk-to-one-another – OldProgrammer Sep 20 '20 at 21:25
  • Normally you put the REST servlet and the database servlet in the same app. Trying to put these in separate apps sounds just plain weird. However JEE supports libraries, maybe you should put your database utilities in a library and install it for all applications on your server? – markspace Sep 20 '20 at 21:49
  • @markspace Yes it sounds weird, but my SO posts with tagged [xodus] explains the reasoning behind this, e.g. this https://stackoverflow.com/questions/63887544/strategies-for-scaling-applications-vertically-or-horizontally – quarks Sep 20 '20 at 22:47

0 Answers0