Jboss Failover support without load balancing - java

I have two Jboss instances installed on different servers. My aim is to manage a failover recovery between these Jboss instances. Load balancing is not needed. This is customer requirement. Normally client is connected to JBoss 1, perform a failover, and which the client will automatically connect to JBoss 2.
As I said I want to serve only one Jboss instance at a time.
Actually I have a solution, but I don't know if it works. My aim was to write a service that checks if Jboss is running. When I catch a failover, I want to change jndi.properties of client, then other Jboss instance will start to serve client request. But I do not know this solution works. Also Jboss can provide me a service( or other property) to check a specific instance is running?
Do you think my solution can work? Or How can I do this? Do I have to install Apache ? Apache provides failover without load balancing.

Related

Wildfly remote EJB calls through outbound connection through loadbalancer

We have some Wildfly servers running in standalone mode.
Every single instance provides a bunch of stateless services that can be accessed through ejb remote calls (http-remoting) from some webapplications.
The outbound connection of the webapplication points to a http loadbalancer using round robin, no stickiness. This balancers checks the availability of the service applications before connecting.
This work so far, failover also.
The problem:
The number of standalone servers could vary. Once an outbound connection is established from one of the webapps it will never be closed. So always the same standalone server is reached until it would die.
The purpose that under heavy load we just start another VM running a standalone server that would also be used by the loadbalancer does not work, because no new connection is established from the webapps.
Question:
Is this a scenario that could work, and if, is it possible to configure the webapps to start a new connection after some time, requests counts, or whatever?
I tried no keep alives for tcp or http header in undertow and request idle time, but no success so far.
Kind regards
Marcus
There is no easy way to dynamically load balance ejb remote calls due to their binary nature. The JBoss EJB client enables specifications of multiple remote connections, that are invoked in round-robin fashion, but the list is still hardcoded in your client config.
Example jboss client config jboss-ejb-client.properties:
endpoint.name=client-endpoint
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=node1,node2
remote.connection.node1.host=192.168.1.105
remote.connection.node1.port = 4447
remote.connection.node1.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.node1.username=appuser
remote.connection.node1.password=apppassword
remote.connection.node2.host=192.168.1.106
remote.connection.node2.port = 4447
remote.connection.node2.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false
remote.connection.node2.username=appuser
remote.connection.node2.password=apppassword
I understand, that your web application is also java based. Is there any reason why not run both the EJB layer and Web on the same server within a single .ear deployment? That way you could use local access, or even inject #EJB beans directly into your web controllers without the need to serialize all calls into binary form for remote EJB with the benefit of much simpler configuration and better performance.
If your application is actually a separate deployment then the preferred way is to expose your backend functionality via REST API(JAX-RS). This way it would be accessible via HTTP, that you could simply access from your web app and you can load balance it just like you did with your web UI(you can choose to keep your API http context private - visible only locally for the services on the same network, or make it public e.g. for mobile apps) .
Hope that helps
You should be using the standalone-ha.xml or standalone-full-ha.xml profile. While you might not need the ha part to manage the state of stateful beans across your cluster, you need it for the ejbclient to discover the other nodes in your cluster automatically
In effect, the load balancing is done by the ejbclient, not a separate dedicated load balancer

Interest of using activeMQ resource adapter

I am creating a Java application in eclipse to let different devices communicate together using a publish/subscribe protocol.
I am using Jboss and ActiveMQ and I want to know if I should use an ActiveMQ resource adapter to integrate the broker in jboss in a standalone mode or I should just add dependencies in my pom.xml file and use explicit java code like indicated here http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html.
Here the documentation I found to integrate ActiveMQ within jboss in a standalone mode https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_A-MQ/6.1/html/Integrating_with_JBoss_Enterprise_Application_Platform/DeployRar-InstallRar.html
Could someone tell me what is the difference between the two approaches?
Here is the answer for my question:
The first approach starts a broker within your webapp itself. You can use a
normal consumer (not a message-driven bean - MDB), but only your webapp can
access it, via the VM transport (vm://).
The second approach lets the app server manage both the connection to the
broker and the creation of the broker, so it's probably also within the JVM
that runs your webapp and probably only accessible to your webapp, but
those details are hidden from you by the app server. You can only consume
messages via an MDB, but this provides a uniform interface that doesn't
need to change if you switch to another JMS provider in the future.
Since the standard way to integrate a JEE webapp with a JMS broker is via
the RA, I'd recommend using that approach simply for consistency and
standardization. That should also allow you to switch to a standalone
ActiveMQ broker (or another JMS product) in the future with minimal effort.

Fallback Load balancer with apache mod_jk, tomcat

I am able to achieve load balancing using Tomcat 7 and Apache mod_jk by running the same application from two different tomcat instances using load balancer configured in httpd.conf and worker.properties works fine.
httpd.conf
JkMount /myApp/* loadbalancer
worker.properties
worker.list= worker,worker1,loadbalancer
worker.worker1.port=8009
worker.worker1.host=IP
worker.worker1.type=ajp13
worker.worker.port=8009
worker.worker.host=IP
worker.Worker.type=ajp13
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=worker,worker1
However I am trying to have multiple load balancers so that in case single load balancer fails then in such a case we have a fallback load balancer as in this case there is only one load balancer. Is this possible with Apache mod_jk.
In the case you describe in your question, Apache httpd is the loadbalancer, which happens to use mod_jk to do the actual balancing job. If Apache httpd goes away, you'll no longer balance. Therefor the question "I'm trying to have multiple load balancers - is this possible with mod_jk" doesn't make sense to me...
You can have multiple loadbalancers, each of them using their own mod_jk. But it's got nothing to do with this.
Technically a correct answer to this question would be: Sure - just configure an identical Apache httpd and put it onto the same network, then configure whatever you need (IP failover, Round Robin DNS) to make sure that both loadbalancers now distribute the load. Make sure that the tomcat backends accept enough connections to now serve two loadbalancers.
But mod_jk has, IMHO, nothing to say in that question.

Can only tomcat be used as a load balancer(without Apache Http Server)

Background: In my application, I use ServiceMix instances to serve HTTP requests. To load balance these, we figured out(according to some requirement) that we need to use Tomcat.
Question: As I think it should be said that tomcat has its own http server built into it, can Tomcat and mod_jk(without Apache Http Server) be used as a load balancer?
My readings: I read few of the Tomcat domcumentation like Tomcat Clustering doc
, Tomcat JK load balancer (which wasn't quite helpful)
So I wonder is it even possible to use only Tomcat and mod_jk for the purpose of load balancing!!
Any help is appreciated.
To load balance your application you'll need to run two or more Tomcat instances with the same application. You could run two instances on the same machine on different ports (e.g. www.myapp.com:8080 and www.myapp.com:9090) or on different machines on the same port (e.g. www1.myapp.com:8080 and www2.myapp.com:8080). Usually the instances share the same backend data store. Each Tomcat is its own webserver, so you'll have multiple web servers running.
Because you now have two identical instances a user can use either of the two instances. They can also switch from one to the other if something happens to the machine they are currently using. But you don't want your users to have to choose a machine or swap manually. This is where a load balancer comes in.
A load balancer takes a request from the user and dynamically routes it to one of your load balanced instances. A load balancer is also a web server. It can be a hardware load balancer like a BIG-IP F5, or software like Apache, nginx or even another Tomcat server.
If you use an Apache web server to do the load balancing you'll need an Apache module to pass on the request to one of your Tomcat servers. Typically this is mod_jk or mod_proxy.
So the short answer is that if you use Apache as your load balancer then you have to use mod_jk (or mod_proxy). If you use another load balancer then you can't use mod_jk.
Also refer to Tomcat load balancer solutions
mod_jk runs inside of apache httpd server or some other server it is written in native code, Here are some configurations that will work.
Apache httpd or IIS with mod_jk load balances requests to tomcat server
A web server with reverse proxy support with and a load balancing feature can be used
A dedicated load balancer product can be used
For load balancing you need to make sure to determine weather you need sticky session routing or not.
Also you do don't need to configure tomcat clustered session manager in order to configure and use load balancing.
I am fairly certain that tomcat itself the java part does not ship with a built in load balancer it expect users to use one of the above options.

What do I need to realize notification using JMS?

I just need notification system. javax.jms.* - good solution I think, but I can't understand what do I need to use JMS?
I don't want to use any app. servers like GlassFish or Tomcat, I just would like to use standard jdk and myserver(very light) and myclient(very light too) and some MessageSystem to exchanging bitween myserver and myclient. As I understand to use JMS I need JMS Provider. For example: ActiveMQ. But I don't uderstand ActiveMQ needs any server?(GlassFish probably), and what kind of *.jar do I need from Java EE ?
JMS provider or more correctly a Message Broker can be a stand-alone application. Most of J2EE app servers include a broker inside them but yes we also have many very good stand alone JMS brokers, ActiveMQ is good, then there is OpenJMS and many others. And as they are stand alone they don't need another app server to run them. And they usually come with every needed jar as well :) SO you'll not need to copy any jar from other app-server to say ActiveMQ or OpenJMS.
ActiveMQ runs as a standalone server; it requires the Java VM like any Java application but nothing else beyond that.
Other stand alone JMS brokers (open source) which can be run standalone or even embedded in your Java application are Open Message Queue (OpenMQ) which is also included in GlassFish, and the new JBoss HornetQ message broker which will be the JMS implementation in JBoss application server.

Categories

Resources