I have a system which contains the data of the employee and this system has exposed many web-services and RMI through which any other system can request for data. Now I have a web application hosted on JBOSS. Here the problem is, now I want to get the data from the system to JBOSS in real-time fashion. Though that system has sevral webservice and RMI services through which JBOSS/web-applications can request data but that is on-demand. I looking for a way thorugh which if there is any change in the system, JBOSS get notify at that moment. One solution to it is, I should make process which will call the webservice to know if there is any change in the employee data within a time-interval. What is the other way to notify the JBOSS in real-time?
One way is to have a job/separate process which polls your employee application periodically, and sends "data has changed events" to JBoss using JMS.
In JBoss you could have a message driven bean (MDB) whichs listens to these events, and stores them in a database.
Another possibility is to have this job running in JBoss which just stores the events/results in memory (search for Quartz, for example have a look at this tutorial).
Related
I am creating a web application. Same application will run from different machine, but
they will use common database. When application starts it will get all data from database.
But when I update data from one application, how other running application will know that data
has been updated, I want when I update database form any application, other running
application will get notification immediately, and they should update their data.
One possible solution is I can take all applications URL in a list, then after updating value
I will send request to all application, but how to do this using send Redirect. Is it correct way ? or is their any other easiest way to do this. Please help me.
Is it a requirement that data is loaded once on startup? If it's not than you can just read directly from the database with a low cache invalidation time.
In case your apps need to be synchronized "almost immediately" I would do it like this:
You can set up a messaging server which would create a JMS topic. All of the clients will listen to messages from that topic. When one of the apps update something in the DB it will send a message to the topic. The rest of the apps will get the message and update.
I have a problem and I am wondering what the best way of solving it is.
Basically I have two web apps in a clustered environment (weblogic 11g).
The first web application is for uploading "documents" and managing these web applications as viewable (or not) in the second web app. The documents are stored in a database which both web applications can read
The second web application can be thought of as a document viewer.
Because loading these documents can be very slow. I'd like to load them as soon as I can rather waiting for a request.
A pull model where the web application periodically checks the database for new/removed/updated documents doesn't seem to be very practical.
What would be the best way of signalling when an user (admin) of the first webapp has updated a document, so that the second webapp can retrieve the document from the database?
My first thoughts were to use a JMS Server, but that seems a little heavy for such a simple signalling system.
What would be the best fit for this scenario?
A JMS Server for the cluster?
A JNDI Object?
Why is JMS heavy? You already use an application server with integrated JMS.
You could use one queue dedicated to each cluster node.
On upload you could post one message in each queue
On each cluster node there is a job which acts as QueueReceiver which in turn updates it's local cache
As an alternative you could try to have a servlet/web service which is called for each cluster node (which again updates the local cache).
Please suggest what are different ways of achieving load balance on database while more than one tomcat is accessing the same database?
Thanks.
This is a detailed example of using multiple tomcat instances and an apache based loadbalancing control
Note, if you have a hardware that would make a load balancing, its even more preferable way as to me (place it instead of apache).
In short it works like this:
A request comes from some client to apache web server/hardware loadbalancer
the web server determines to which node it wants to redirect the request for futher process
the web server calls Tomcat and tomcat gets the request
the Tomcat process the request and sends it back.
Regarding the database :
- tomcat itself has nothing to do with your Database, its your application that talks to DB, not a Tomcat.
Regardless your application layer you can establish a cluster of database servers (For example google for Oracle RAC, but its entirely different story)
In general, when implementing application layer loadbalancing please notice that the common state of the application gets replicated.
The technique called "sticky session" partially handles the issue but in general you should be aware of it.
Hope this helps
Could someone help me on this,
I have created simple web services using axis2 , apache and tomcat. This web service has a queue that keeps xml files sent from a client, so whenever a client calls a method on the webservice, the webservice loads this xml to its queue. Now I want to have a thread running in the webservice which monitors this queue, and if there are items in the queue takes some action.
But my problem is that the webservice is invoked only if a client calls one of the methods on its interface. But I need this thread to be running on webserbice. Could someone tell me is there are is a way to do this?
When a client invokes a method on the webservice, it does not consider previous method invocations. This means that it does not keep track of data in the queue, for each invocation it creates new queue.
If you need background threads in a web application you must manage them inside a ContextListener registered in web.xml. You are then notified when your web application is started and stopped.
Sounds like the perfect use case for JMS/message driven beans. Spring JMS provides these facilities without having to use a full-blown J2EE container, so tomcat will fit here. Active MQ can provide the messaging engine.
Essentially, your web service would put a message on a queue and a message driven bean (or message driven pojo) would read them off the queue and process. Using JMS would have the advantage that you'd be able to reconfigure the message driven bean to sit on a separate host if you're load on the server grows. It'll also mean you'll be able to move to different app servers with ease as JMS is a standardised solution.
In a very popular ecommerce store, I'd imagine the actual processing of the credit card would be moved to some sort of dedicated application server, and made into more of a asynchronous process.
What sort of java application type would that be? i.e. a service that would take a message of the queue, and start processing the request and update some db table once finished.
In .net, I guess one would use a windows service. What would you use in the java world?
It is typically a J2EE application that uses a HTTP web service interface or a JMS messaging interface. HTTP interfaces are accessible via a URL, and JMS connects to a queue to pick up messages that are sent to it. The app can run on any one of the major commercial (WebSphere, Weblogic, Oracle) or free (Glassfish, JBoss) servers.
In Java you already have great open source projects that do all this for you like Glassfish, Tomcat etc.
For a mission critical system, you might want something like IBM MQ series as the middleware, and a straight Java application that uses the MQ interface to process the requests.
At a few banks that I know of, this is their architecture. Originally the application servers were written in C, as was the middleware. They were able to switch to java because the code that was actually doing the critical work (sending and receiving messages, assuring guaranteed delivery, protecting against interruptions if a component went down) were the IBM MQ's.
In our case we use an application server from Sybase that can house Java components. They are pretty much standard Java classes that have public methods that are exposed for calling via CORBA. Components can also be scheduled to run constantly or on a schedule (like a service) to look for work to do (via items in a database table, an Oracle AQ queue, or a JMS queue). All of this is contained in the app server and the app server provides transaction management, resource management, and database connection pooling for us.
Or use an OSGI environment.