How to configure Reactor for distributed services? - java

I have numerous services distributed on a private network and there is a service which has to broadcast a message to all other services(e.g. the expiration of authentication token). My application is based on java Spring framework and ever since I have started to get acquainted with an architecture that satisfy my condition, I found that it is called Event Driven Architecture and two famous frameworks related to this architecture are AKKA and Reactor. But reading the reactor tutorial (which integrates with spring much better than AKKA) I found that all services including Producer, And Consumer must submit into a Reactor class within the same context. Now I wonder if there is a way of distributing the services on multiple machines.

Related

What is the best way to communicate between microservices in vertx, by web client or some middleware?

I have not done much in vert.x microservices, but I ran into the doubt of knowing the best way to communicate with each other miscroservices vert.x, using some middleware or web client, I do not know, or any other way that vert.x allows me.
There's an infinite of possibilities to allow vert.x microservices to communicate between them, each with pros and cons and with more or less relevance depending on the context.
Here is 3 common ways :
1) Using the native vert.x eventBus (
asynchronous logic) : https://vertx.io/docs/vertx-core/java/#event_bus (and you can use the Hazelcast Cluster Manager using the -cluster option when you need to handle communication between different JVM pids : https://vertx.io/docs/vertx-hazelcast/java/ ).
2) Using a messages broker system like Apache Kafka (
sometimes you need persistent message queues with replay mechanisms, which I think is more powerful than the vert.x's event bus, sometimes you need to communicate with multiple languages written microservices and the vert.x event bus is not relevant to do that) or an old fashion JMS compliant system like ActiveMQ, RabbitMQ & cie.
3) Sometimes it's more relevant to expose simple Restful api, so you can use the vertx-web extension to do that : https://vertx.io/docs/vertx-web/java/

JMX Notifications design

We have a number of related Java Spring applications running on our servers. Lets call them App1, App2 & App3. As is standard all these use the common code in our-common-utils.jar
I want these applications(App1, App2 & App3) to broadcast their state to one or more remote listeners. For e.g.
App1: I failed to read file abc.
App2: I am using more than 90% of my heap space etc.
The listener/s of these events will take specific actions such as send emails to support and/or clients based on the notifications received.
The best solution I can think of is to have a NotificationSender JMX enabled(implements NotificationBroadcasterSupport) bean in our-common-utils.jar. This will have a thread consuming from a queue of Notifications and firing off sendNotification() to the listeners for each Notification. This will be done by each of the Apps in our eco system but using common code from common-utils.
Do you see any flaws in this design? Any more efficient ways/frameworks of doing it?
Many Thanks :)
Alternative solution is to use any distributed coordination service zookeeper for example. I used it in my very first micro service project. As I can see you are using spring. Spring cloud provides necessary solutions that you can use in declarative way. I would pay your attention to #FeignClient. It is very simple in use and flexible in spring world.
If I would work on this issue now, I would use spring hystrix based solution. To simplify integration between your java services I would recommend to check service-registration-and-discovery.
Ignore my opinion if spring is not general engine part in your projects (may be you need other vendor solutions, there are a lot of alternatives). I concentrate my attention on spring solutions because spring is not restricted in my projects and I can use anything I wish if it's reasonable.

Spring Integration : Multiple Application Integration using Spring Integration

I have some doubts regarding Spring Integration :
Can we integrate more than two applications using Spring Integration framework?
Is it point to point intergration or middleware oriented integration?
In client-server architecture If both (client & server) are java based applications, then what should we use for synchronous communication ? means, should we go for Spring Integration or JAX-RPC ? Which one will be faster for synchronous communication ?
Spring Integration is a lightweight integration framework. It does not use or need a central broker (many see that as a benefit).
It is not just point to point; you can configure a many-to-many environment, but no broker is required. You can, of course, use a middleware broker if you wish (e.g. RabbitMQ or JMS).
There are many ways to perform synchronous (request/reply) integration. In Spring Integration, the components usually used for that are called gateways (outbound on the client, inbound on the server).
One of the benefits of this is the application doesn't have to know what technique is being used. With simple configuration changes, you can change the actual protocol used to whatever you want, with zero changes to the application itself.
Many techniques are provided out of the box, including ReST (http), SOAP WebServices, JMS, AMQP, TCP/IP, ...).
It's best not to think of synchronous integration as RPC - it's all about loose coupling using request/response messaging, with the message content being the contract, not the API.
One-way integration is achieved using channel-adapters rather than gateways.
I suggest you take a look at the reference documentation... http://static.springsource.org/spring-integration/reference/html/

Architecture advice on integrating.net & java application

In one of our recent projects, we have decided to use a message based solution to integrate an existing .Net app to a new JAVA based application. There is a requirement to not use a Application Server. So I am trying to look into some alternative options. Currently we are planning to use ActiveMQ as the JMS provider. Also the Java application needs to interact with an backend database. So, when trying to figure out options, I found that the Spring framework would be quite helpful. It appears that Spring may need some additional components (e.g, Atomikos) to provide transaction support for JMS & JDBC operations.
I am trying to limit the user of additional components as much as possible.
So, Is this the right approach to use ActiveMQ with Spring. If so, can I just use the built-in transaction module available in Spring to support transactions?
Any advice would be very helpful?
Leo
Use WebSphere MQ .NET interface (.NET native or XMS .NET) for sending/receiving messages from your .NET application. At the Java app end use MQ JMS interface. MQ JMS interface supports two phase commit, so you can synchronize your message gets and database updates.
Keep the integration through MQ and WS. More tight coupling may lead to problems and complexity.
I'd go with a messagequeue that has good .NET and Java clients - e.g. RabbitMQ That builds on AMQP. As well as serialization technology that has good cross-language capabilities (Thrift, Protocol-buffers etc.)

Multiple instances of a java web application sharing a resource

I have a web service, that takes an input xml message, transforms it, and then forwards it to another web service.
The application is deployed to two web logic app servers for performance, and resilience reasons.
I would like a single website monitoring page that allows two things
ability to stop/ start forwarding of messages
ability to monitor throughput of number of messages in the last hour etc. Number of different senders into the webservice etc.
I was wondering what the best way to implement this was.
My current idea is to have an in memory database (eg Debry or HSQL) replicating data to share the information between the two (or more) instances of my application that are running in different instances of the app server. I imagine I would have to setup some sort of master/ slave configuration.
I would love a link to an article that discusses how to solve this problem.
(Note, this is a simple spring application using spring MVC)
thanks,
David.
This sounds like a good match for Java Management Extensions (JMX)
JMX allows you to expose certain operations (eg: start/stop forwarding messages)
JMX allows you to monitor certain performance indicators (eg: moving average of messages processed)
Spring has good support for exposing beans as JMX MBeans. See here for more information.
Then you could use an open-source web-based JMX console, such as jManage
Hope this helps.
Sounds like you are looking for a Message Queue, some MDBs and a configurable design would let you do all these. Spring has support for JMS Queues if I'm not wrong
I think you are looking for a message queue. If you need additional monitoring, using a web service as the end point may not suffice - with regards to stop/start or forwarding of messages; monitoring http requests to web service is more cumbersome than tracking messages to a queue (even though you can do it).
If you are exposing this service to third party, then the web service will sit on top of the message queue and delegate to to it.
In my experience, RabbitMQ is a fine messaging queue service with a relatively simple learning curve.

Categories