Jhipster Inter Server Communication - java

First of all I know i need to write service that does not depend on each other but i have to cause of some requirements from the client.
So now the problem is I have no idea how to request the data from one service to another service, I have 2 services lets call service1 and middlewareService, so the middleware service gets the details from some third party api, and the middleware is not linked to the database. so now I need to call a function in the middleware and get the details from service1 so that I can put save in the database and send it back to our application users.
I understand that this can be done through feginClients but I have no Idea on how to do it? can anybody help?
Thank you for your assistance, ;)

IT is fine i figured out how to achieve this using fegin client, thank you stackoverflow.

Related

Stateless api with real time chat

So I have a REST api. I want to keep it stateless, but at the sametime I need to make a real time chat.
The only way I can imagine a real time chat, is with websockets. The problem accurs that websockets, to my knowledge, seems pretty statefull.
Is there another way to create a real time chat?
My stack is Spring boot (java)
React frontend
Mongodb for database.
Plan for hosting would be AWS
And normally I would just ignore the 100% stateless or statefull, but this is for a school project, and I would look good in my report, to say I am 100% stateless.
the correct way achieving real time chats beside websockets would be to use firebase which is very common since usually the clients connected to your server will use android/iOS.
obviously an app connected to firebase is maintaining a stateful connection to firebase.
in general i dont think it is possible to provide push functionalities without state , as the server must reach the connected clients thus it must maintain those connections. if not using firebase, using websocket seems a reasonable approach.
I know two ways of implementation this. Easiest - websockets. Hardest - backend is calling frontend.
More about second solution. In normal world, we are calling backend using frontend, here will be visa versa. When backend will receive a message (from another user), it will tell frontend that message was received ant it should show it.

Can I put an HTTP proxy service in my java app to intercept all HTTP requests and change the headers?

I am writing an android app in java, and would like to intercept all HTTP traffic from its outgoing requests and change the user agent from the header. I know there are tools to do this from separate apps/programs like Charles' Proxy, but can I do this from within the app itself? Would I be able to register a service in my app for this? If so, do you have any links I can reference to get started or have any tips? I am a novice coder, so anything at all is appreciated. Thank you.
Do you use OkHttp to make requests? If so, the library has a powerful mechanism of interceptors to do exactly what you want.

RESTful service and login?

I'm currently working with Jersey/Jackson and I'm having a hard time understanding how should I approach the sign-up/login for my app's users. What kind of things should I take in mind when developing such a service? (it's very important that it will be secure)
Thank you.
One easy way to get session with a RESTful Service,
you could create a sign-up/login site which returns something like a Session-UUID. The client just has to send the UUID with every subsequent request.
To enhance security, you should invalidate the UUIDs after some time.
Edit:
See Session Managment with Jersey

Asynchronous web services problem

i need one answer. I am calling Asynchronous web services and ofcourse it want Asynchronous response. Must webservice somehow call my client or how is implemented response.
I read this and many other pages but i do not know if web service need to call me back for response.
http://www.mastertheboss.com/web-interfaces/111-asynchronous-web-services-with-jboss-ws.html
regards
You need to think it as a 3rd party service which you dont have any access to its source.
You need to handle asyn calls yourself for your side.
java.util.concurrent package contains what you want
see below link
http://www.scribd.com/doc/17369778/Java-Concurrent-Package-tutorial

Using Spring in Java swing app

We are seeing Spring in school right now but we don't have the time to wait till the end of the semester to start developing an application. We continue using an app we made last year, and are writing the service layer right now.
The problem is our "client" wants to have a desktop client and a webpart, which used the same dtatabase. This would be no problem if we hook up a server that can handle RMI. So basically we want to be able to retrieve/send data to the server that runs our service layer, and use the objects on the client side as well.
I have no idea where to start digging in Spring to figure out how to do this, so some help would be appreciated.
PS: At this point I do not need MVC yet. MVC is handled from within the desktop app where we have views and controllers.The model is the same from the one on the service layer. How do we use the same model without copying it?
Check out spring remoting: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/remoting.html
It's easy to expose your spring beans remotely, using a variety of protocols.
You might want to take a look at the REST paradigms. With this in mind you could have a web server running your server part of the application and communicating with clients through the HTTP protocol. A simple client could be a webpage in the browser which gets the corresponding HTML pages from the server, or a Swing client which communicates over JSON with the server.
The server can implement different methods for JSON or HTML communication and the server can decide what implementation to use by looking at the Accept Header of the Request objects sent to it, that's what they call Content Negotiation
JSR-311 is implemented as Project Jersey which is a framework for RESTful webservices. You might want to take a look at that.
hope that helped

Categories

Resources