0

I have Java EE applications (ear) running on separate JBoss instances and on different hardware. I want to call from

  1. one application to another which is in another server JBOSS.
  2. Same JBOSS, between two ear.
  3. Same Server, between two JBOss.

The communication data types can be any type. For instance; JSON or Objects. I want to know what lightweight, Open source Java web frameworks I can use to call from one to another? Here some of them. But I don't have any experience from them. Commonly, SOAP and RESTful services are used and there are many implementation frameworks of them.

Please suggest me know from your experience what are the available frameworks which suit for my requirement? Let me have source which explain any comparison. My concerns are that, the communication methodology should be light weight, should support to transfer any type of data, there should not be much configurations, or standards. The framework should support to transfer simply (all communications are done in my applications. so no need well structured, standardized weight configurations) and securely. and it should be in Java. I use Java 7.

cassiomolin
  • 124,154
  • 35
  • 280
  • 359
Débora
  • 5,816
  • 28
  • 99
  • 171

5 Answers5

2

From my understanding of your situation, I think ESB would be a good solution for your problem.

http://en.wikipedia.org/wiki/Enterprise_service_bus

The one from WSO2 is a pretty light-weight open-source ESB and has a good active community. http://wso2.com/products/enterprise-service-bus/

Vinay Rao
  • 1,284
  • 9
  • 13
  • 1
    Thanks Vanay. It is a good point. But it sense that it is a architecture of deploying to facilitate the communication. " describing implementation of loosely-coupled software components" . The weight for all integration for my application could be high. – Débora May 01 '14 at 14:27
2

This is a typical integration problem. For integrating, mediating, proxying etc. different services and even transferring data, use Apache Camel. For a short answer what Camel is, see What exactly is Apache Camel?

In Camel you define routes using a Java DSL or a XML Spring DSL. Proxying a web service is described here. Using the XML Spring DSL, the route would look as follows:

<route>
    <from uri="jetty:http://0.0.0.0:8080/myapp?matchOnUriPrefix=true"/>
    <to uri="jetty:http://realserverhostname:8090/myapp?bridgeEndpoint=true&amp;throwExceptionOnFailure=false"/>
</route>

Using the Java DSL, this would become:

from("jetty:http://0.0.0.0:8080/myapp?matchOnUriPrefix=true"
    .to("jetty:http://realserverhostname:8090/myapp?bridgeEndpoint=true&amp;throwExceptionOnFailure=false")

There are many different protocols that are supported by Camel such as JSM, SOAP WS, RESTful WS, plain HTTP, TCP. Have a look at https://camel.apache.org/components.html for all possibilities.

The next example shows you how easy it is to define a RESTful server using the Restlet component:

from("restlet:http://localhost:8400/orders/{id}?restletMethod=post")
    .process(new Processor() {
        @Override
        public void process(final Exchange exchange) throws Exception {
            final String res = "received [" + exchange.getIn().getBody(String.class) + "] with order id = " + exchange.getIn().getHeader("id");
            exchange.getIn().setBody(res);
        }
   });

The corresponding client looks as follows:

 from("direct:start")
     .setBody(constant("Hello, world!!"))
     .to("http://localhost:8400/orders/22?restletMethod=post")
     .log("order: direct start body result = ${bodyAs(String)}")

That said, Camel supports a plentitude of enterprise integration patterns such as splitter, aggregator etc. that can be used for your needs. Have a look at http://camel.apache.org/enterprise-integration-patterns.html for more information about that.

You can just use "normal" Java classes for transforming data and hook them into the routes. Beside that there are many integrated type converter for transforming one data type to another. These converters can easily be extended. See https://camel.apache.org/type-converter.html.

You could use Camel as your base integration framework and add e.g. JMS/ActiveMQ for the communication. However, it is also possible to use ActiveMQ as your base and add Camel for transforming the data, see https://activemq.apache.org/broker-camel-component.html: "The broker camel component makes this even easier - which intercepts messages as they move through the broker itself, allowing them to be modified and manipulated before they are persisted to the message store or delivered to end consumers." However, I prefer to use Camel as the base and add JMS/ActiveMQ for the asynchronous communication (e.g. if message persistence is needed or if the communication has to occur between different hosts).

Camel supports a huge amount of different protocols and formats. However, you don't have to use them, if you don't need them. Just add the dependencies to your pom.xml if you need them. Apache Camel is a small library (11.2 MB) with minimal dependencies for easy embedding in any Java application. Camel runs standalone, in a Servlet engine, or in an OSGI container such as Karaf/ServiceMix/JBoss Fuse ESB. You can start small and the application can grow, if your needs are growing.

For starting using Camel, read the excellent book by Claus Ibsen: http://www.manning.com/ibsen/.

Community
  • 1
  • 1
Peter Keller
  • 7,526
  • 2
  • 26
  • 29
  • Peter, thanks your reply. Using Camel is a good point. But I feel that that it could be heavy for my application. – Débora May 01 '14 at 13:29
  • 1
    @Débora Camel supports a huge amount of different protocols and formats. However, you don't have to use it, if you don't need it. Just add the dependency to your `pom.xml` if you need it. Apache Camel is a small library with minimal dependencies for easy embedding in any Java application. Camel runs standalone, in a Servlet engine, or in an OSGI container such as Karaf/ServiceMix/JBoss Fuse ESB. You can start small and the application can grow, if your needs are growing. – Peter Keller May 01 '14 at 15:37
  • @Débora Apache camel is literally a 11.2MB download. It is anything but heavy as a matter of fact is is extremely lightweight. – Namphibian May 01 '14 at 23:16
  • Once again I should thank and appreciate you for your further explanation. I took a look at Camel. As of their design, Camel uses JMS for messaging. Then what if I Use JMS (ActiveMQ) for communication. Because I don't need to manage other API s and EIP which are done by Camel. Here my main concern is communication among applications.Therefore What would you think if I use JMS (which Camel use for messaging ) instead whole Camel? – Débora May 02 '14 at 06:03
  • @Débora It is also possible to use ActiveMQ as your base and add Camel for transfering the data, see https://activemq.apache.org/broker-camel-component.html. I enhanced my answer accordingly. – Peter Keller May 02 '14 at 08:05
  • @Peter . I highly appreciate your explanation. There is one more confusion. I am not familiar with Camel. How ever,ActiveMq which is used by Camel, is supposed to transfer data. But your statement is not clear " use ActiveMQ as your base and add Camel for transfering the data, " . why we use camel again to transfer data because ActiveMq does the job ? – Débora May 02 '14 at 08:21
  • @Débora I should have written "transforming" instead of "transfering", i.e. I meant changing the data not sending it over the wire. – Peter Keller May 02 '14 at 08:24
  • @Peter. One more thing please. What if I use Jax-RS ? One application becomes the client, and make request using apache HttpClient ? – Débora May 04 '14 at 02:09
  • @Débora You can choose between two components that support RESTful services: http://camel.apache.org/cxfrs.html and https://camel.apache.org/restlet.html. Both can be used on client and server side. – Peter Keller May 04 '14 at 08:32
  • @Débora I added a RESTful example to my answer – Peter Keller May 04 '14 at 10:12
  • @Peter, I appreciate your support :) . If I am not disturbing you, would you simply give me your idea about similar scenario problem. Just forget my question's scenario. And just assume, 3 jee applications running and all have same kind of objects in their application context.Therefore,I remove all those objects from applications, and all functions(validations,data processings)are put into another 4th application.This 4th app only does storing common objects and some other functions relevant to those objects.When ever those objects are needed,those 3 applications call the 4th app and get.... – Débora May 04 '14 at 11:44
  • .... them. Those objects are stored into 4th by those first 3 applications them selves. For this 4th application, I'm to suppose use Tomcat. In this scenario, 3 applications send object type data to 4th app and vise versa. For this scenario, what would be a good solution. Only a JMS, JAX-RS or still Camel ? My main question is not related to this. – Débora May 04 '14 at 11:49
  • @Débora Either JMS, JAX-RS or Camel are valid options. Or all together! There are different drivers: synchronous versus asynchronous communication, possible future client implementations (Java, JavaScript, .NET), known technologies (development operation), new requirements (transformations, other protocols), security constraints etc. – Peter Keller May 04 '14 at 16:07
  • The problem with Camel is the complexity. If you have tons of configuration elements defining the magic glue the average developer basically tilts. I have seen plenty of projects suffer from it and once I was allowed to remove Camel and do simple explicit rather than magic everyone was happy again. For me Camel is like AspectJ. A solution that makes sense but can not be maintained well by the human brain. Messaging and event based architectures.. same. Everything beyond simple is dead on arrival. – Martin Kersten Nov 29 '17 at 19:59
1

you could use jax-ws to provide the webservices from your JBoss and call them using javax.xml.soap. What i dont know is if its possible to send object data, maybe you have to serialize from and to xml end send it encoded as base64 string.

Another way might be jms.

JPhil
  • 68
  • 6
  • Thanks for your attention. As far as I read until now, if I use jax-ws, I have to go with standards and much more. Upto now I have discovered and considering, REST or the JMS. – Débora May 01 '14 at 13:27
1

If all of the other solutions listed here do not fit your needs, you could interact with the applications by sending JSON or XML data over HTTP.

Spark is a micro web framework for Java that lets you quickly create web endpoints.

By default, Spark runs on an embedded server, but it can easily run on an existing JBoss server instead. Here is a sample that I put together a few months ago to demonstrate how it works and how to get it working with JBoss.

You can have each application that needs to receive data expose a HTTP endpoint and have the calling applications send a simple HTTP request.

dMcNavish
  • 627
  • 6
  • 12
0

Simple and open win. You can expose objects remotely in many different ways, but Java RMI and EJB limit you to Java only clients.

The most open, easiest way to do it is to use HTTP as your protocol and web services, either SOAP or REST (my preference). These will interact easily with any client, even those that aren't Java. Clients need not know or care that you chose Java and JBOSS to implement your server logic.

duffymo
  • 305,152
  • 44
  • 369
  • 561