I have large number of http REST based API implemented in java being reused by multiple services and web/mobile clients.
I have been told that services are connecting based on point to point integration, in other words, if an orchestration service A wants to use rest based service B and C, it uses their load balanced IP. I can esily add more service instances behind the load balancer. So, what would i gain by using ESB?
ESB is more intelligent than a load balancer. Many ESBs offer load balancer capabilites too.
ESB comes into play when you want to connect to services that adhere to different message formats. Say, you have a service that is REST based and can process http payload. But you have a client that sends only jms messages with that payload. An ESB can handle this case. It acts as an integrator accepting the jms messages and converts it to payload.
You might want an ESB even if you are connecting to services talking the same message format. ESB can inspect and transform the message too.
Related
I'm using Spring Eureka as discovery server in my application which is implemented using microservices architecture. The services are mostly created with PHP, and they register themselves on start-up using Eureka REST endpoints and each one of them sends a heartbeat every 30 seconds and everything works well.
Now, imagine service A wants to talk to service B. How does the discovery happen?
Currently I think service A should send a GET request to http://localhost:8761/eureka/apps/service-B endpoint, retrieve the list of current instances of service B and choose between them. Is it the right approach?
What about load-balancing? Should I implement that in my services to ask for a different instance every time? Or choose between them randomly?
Any help would be greatly appreciated.
Update: Take a look at this library.
There is an easy way to do this with Spring Cloud Netflix Sidecar: http://cloud.spring.io/spring-cloud-static/Camden.SR7/#_polyglot_support_with_sidecar
If you want to continue to implementing this yourself you have several options. With client side load balancing you could retrieve all instances from Eureka and then choose one randomly at the consuming side. If you want server side load balancing you will be needing an extra component, like Zuul, and let it do the load balancing and routing. Zuul uses the eureka configuration so it is easy to integrate it.
I've learned a respectable amount about networking protocols in Grad School and in professional experience and sent HTTP requests programmatically using AJAX and such.
The project on which I work professionally uses JMS to communicate and I'm curious about how it works.
When using REST (for instance) one makes an HTTP request with parameters in either the URI or the message header in order to invoke a service and further describe its needs.
A mentor of mine at work and I were discussing how JMS works and I'm struggling to understand at an application level how messages are actually sent. As far as I understand JMS in general (I realize there are many implementations of JMS) it is a specification for how to format data being sent.
Is the message itself still sent via HTTP(S)? Could it be SMTP?
Without going excruciatingly deep I would like to understand how one would, at a code level, send a JMS message from one service to another?
Am I even thinking about this correctly?
Can it be done any number of different ways?
Is there a convention that's used in the industry?
If someone could shed some light on JMS for me I would appreciate it.
Thanks!
JMS is not a protocol, it's an API specification. It's not something like TCP or HTTP protocol. Simply put the JMS specification defines signature of messaging APIs. How the APIs are internally implemented and what protocols they use to communicate with the messaging provider is vendor specific.
The vendor specific JMS implementations know how to communicate with their own messaging provider, but not with any other vendors messaging providers. For example IBM's MQ JMS implementation uses it's own protocol to communicate with IBM MQ Queue Manager, similarly Oracle JMS, Active MQ implementations with their own messaging provider.
Hope this helped.
In my company we are starting to use web services. My plan is to provide access to services via 2 protocols, http and jms. Any external access (clients outside company network) to services will be typically via http and json through a restful URL, but internally if the service needs to invoke another service, it will do it via jms, mainly to decouple the service from each other.
My question is following
Can camel provide abstraction so that i can write my service code without http, json and jms dependencies? I would like camel to handle http to java, json to java and jms to java conversion through some mediation and invocation of my service should be simply through a java method with accepts a java object as a request. Keep in mind that although http is synchronous model, jms would have to simulate request-response. If yes, can you please point me towards an example which demonstrates this setting.
Likewisely, i would like camel to convert the response from my service, which would be a java object, into json and return the response back to the client.
Lastly, how can i scale in this model. For JMS, it is easy to startup multiple instances and have them listen to a queue. How can i leverage same instances to loadbalance across http interfaces? I would like services to have location transparency, hence, they should not have to care about invoking "jms" specific cluster vs "http" specific cluster?
I think you can achieve all of this with Camel.
Marshalling between different object representations is handled through data formats. You can call POJOs from within Camel routes that can encapsulate your services.
See data formats.
Camel comes with clustering and load-balancing support. But if you only have HTTP type endpoints to load balance, then my personal opinion is that you should use a more http-centric approach, like using httpd as a reverse proxy/load balancer.
I am looking for a simplest solution to create a client-server network architecture using Spring 3 framework. The architecture woill have many clients and multiple servers. Each client can connnect to each server. Each client can define a set of services that would have to be generated during runtime by the server.
Communication protocol:
Client says hello to one of 5 servers.
Server gather its local metadata about stored data and send it to client
Client pick some of this info and send the metadata subset to server deciding which data it will need later.
Server basing on the metadata choice, picked by the client, generates dynamically services that will be made available to the client supplying him with data pointed by the requested (step 3) config (eg in form serialized JSON)
Client get the information about generated services and use it for future calls to those services.
The biggest issue is that client doesn't know nothing about server resources to be served until it receives answer and server has no services since it get request from client.
I considered Spring 3:
HTTP Invokers
JMS
Netty (joined with spring)
But as far as I tried the above it's ether hard to provide the dynamic service generation requirement or the amount of code (Netty) is big.
I have rejected SOAP due to its heavy nature.
On the other hand REST does not bring here as far as I know any benefits. It is just a way of serving data and it require some kind of servlet container like Tomcat as it uses HTTP. #Timmmm 's great and simple answer to REST fashion
What I am after:
as simple as possible
dynamic generation of services based on client choice
keep server lightweight i.e. no additional server instance (it would be nice to eliminate tomcat; but ts not crucial)
spring based
What technology would you recommend?
It is quiet hard to accomplish this task with the requirement of configuration based service generation during runtime.
I do NOT want to base on properties files, services must be generated on the fly based on the client request.
Thank you in advance for answers and tips.
I would look at RESTful architecture. Some of its principals is what you are after, including discovery.
Spring provides easy integration with REST.
I'm looking for an example of how to set up a very simple Mule configuration to route a SOAP web service call from a client to a service provider. Initially, there will just be one provider, and then I will want to add multiple service providers and a round-robin routing strategy in Mule.
Most of the examples on the Mule site have the service provider running within the Mule container. I want mine to be completely external.
If you don't need to decompose message arguments use HTTP pass-through, which is more light-weight and a lot simpler. For the round-robin implementation you could use a filter router with a groovy-based filter expression.
See here:
Create pass through with Mule ESB 2.2.1
http://www.mulesoft.org/documentation/display/MULE2USER/Outbound+Routers#OutboundRouters-Filters