Count the server calls from my application - java

I am working on a desktop application that connects to a repository and perform CRUD operations using CMIS API. CMIS API uses http communication internally. How can I know, the number of server calls performed by the desktop application.

If you are using OpenCMIS, set the log level of org.apache.chemistry.opencmis.client.bindings.spi.http.DefaultHttpInvoker to debug. It logs every URL that is called by the client.

Related

Hosting Neo4j in GCP Compute engine

I want to host a Neo4j web service for a Wikipedia graph of pages and categories and basically get some recommendations out via cypher queries.
I have already created and populated the database.
How do I “ideally” setup such a service ?
Should I keep 1 dedicated instance for the Neo4j server and separate
instances for running Tomcat or Jetty which receive the client’s
requests and then forward the request to the Neo4j server instance
via the REST API ?
Or directly send requests (cypher via REST) from the client to the 1 neo4j instance ?
Or should I choose unmanaged extensions provided my Neo4j ?
Or is there any other way to set it up keeping scaling in mind?
I do plan to run load balancing and HA clusters in the future.
The web service will be accessed by browsers and mobile apps.
I have never hosted such a web service before so it would be great if someone helps me out :)
I would recommend that you create an API app that sits between your clients and Neo4j. Your clients would make requests to the API server, which would then make a Cypher request to Neo4j (could be one instance or an HA cluster).
The benefits of this include being able to implement caching at the API layer, authenticate requests before they hit your database server, being able to instantly update Cypher queries by deploying to the API server (imagine if the Cypher logic lived in your mobile app - you would be at the mercy of app store / user upgrades), and easily scaling your API by deploying more API servers.
I've skipped this layer and just used unmanaged extensions to extend the Neo4j REST API and have clients access Neo4j directly which works OK for rapidly implementing a prototype, but you lose many of the benefits listed above with one additional downside that you will have to restart your database in order to deploy new versions of the unmanaged extension.

Communicating local server and remote server programmatically in play framework

I have an app that has been developed using java and play framework. i have build two app one for the local and one for the remote to view its report data online. Actually i want to synchronize local database with remote database. The question is, how can i communicate and response data between two server programmatically in thread.
To communication between 2 PlayFramework Aps you can use standard REST WS on first App, and WS API on seccond one: https://www.playframework.com/documentation/2.4.x/JavaWS
But, for operations on two databases you should consider using xa-transactions: https://dzone.com/articles/play-20-framework-and-xa

How to create objects in server application and be able to call them from client application

I am learning to program Java. My objective is to create client server application based on Java and MySQL.
That would have following.
Server Application where all admin controls would be available to configure.
server application will be the only to have access rights to MySQL.
Server will have all functions and objects that clients will require and call and get that functionality. (Reason for that is "I don't want to share MySQL credentials to client apps or rather i don't want MySQL credentials to be transmitted on the network to clients"). As it would increase maintenance tough and it could be a security loop hole.
An analogy of functionality could be: client calls to server telling to add an Order such addOrder(order_id, payment,..,...,..) and so on.
What are the method in practice for such kind of application these days? A example code/or material to get in right direction would suffice
These days the universal way to expose a service remotely is via a web service. This solution was preferred by the industry over time due to its simplicity and ease of integration to the point that binary based protocols like CORBA are now seldom used.
Take the example of Android applications, they are native application mostly using REST web services.
A REST web service can be easilly integrated in the same way with a desktop application, a mobile application or a web application, even if the clients are written in different native platforms and languages.
As sample code, have a look at tutorials on the Spring stack. For the server see this tutorial for building an hello word REST web service. For the client, consider the REST template.
For security, see this Spring security hello world example. Using the Spring stack in Java will likelly give you the largest number of tutorials and online support.
This sounds like a good place to use RMI, which Java has built in support for. RMI will allow your client to call server-side methods on a local object that corresponds to the server, where all messages/commands get transparently sent to the actual server, where you have your DB access stuff and logic.

How to publish a java web-service publicly?

In my java based web application (struts 2 and hibernate 3). I have made a web-service using apache axis.
The web-service has to return data from the database which will be used by the android application.
Now, that service obviously has to be published on a public ip so that I can access it in the android app.
What are the options to publish it on free public ip's or domains ?
Would it be better if I use REST instead of apache-axis to make a web-service? What is JAX?
And for android developers , How a web service is consumed in android?
Please answer its urgent and important.
In order to publish on the web you need to put it on a web enabled server, you can do it in several ways:
Turn your computer to a server (thuis is one article, just search in google "how to turn my computer to web server").
Upload your files to a free host
Upload your files to a paid host (usually for a very small fee)
REST vs SOAP (apache-axis):
I would recommend going with REST as it is more lighweight and more flexible (it enables you to get a response as xml,json,html while soap is usually just XML).
JAX-RS id java API for creating REST web services. Look at the jersey framework.
AJAX is a way to send/get data asynchronously and is used wideley in web applications.
How a web service is consumed in android can wideley vary depending on the technology you are using.

How do I manage HTTP communication between a Apache web server and Google App Engine?

I am currently developing a web application in the Google App Engine using Java and PrimeFaces. I have to access a remote MySQL server, my clients website's database. This website contains all the data which my application requires.
I have searched the web and found out that there is no direct method to access any database with Google app engine.
So I decided to create a PHP script on the web server which will accept SQL queries as HTTP requests on behalf of the MySQL server and send the returned data as a HTTP response. (Encrypted of course!)
How can I send a large result set over HTTP from a PHP web server to Google App Engine?
The problem I am facing here is that, although I can manage to get a HTTP request via GET in PHP. How do I send them back, just flushing wont do, and how do I redirect them back to the Google App Engine's my application specifically.
Thanks!
You can use the UrlFetch api to send requests from appengine to your MySQL server. You'll get a response, and can parse it directly in appengine.
You can set up servlets in your appengine app that your MySQL server can trigger with requests. Your MySQL server can send a request (your php GET function) to yourapp.appspot.com/servletpath, which will start your appengine servlet. Appengine can return a response from there.
If dataset is too big to be transferred in one lump then just split it over several requests by adding a range limit to your query. Also make use of task queue to split this job over several tasks. It is common practice on appengine to split everything what takes too long/too big into several tasks. Divide and conquer.

Categories

Resources