Copyright: I don’t have anything. This is only my resume to OCMJEA 6 study based on Bambara’s book (an excellent one, if you can, buy it here). All the images are from the book and from Google Images. Personal use only. Sorry for english errors. Sergio Figueras (sergio@yourecm.com).
JMS provides a standard way to implement Message Oriented Middleware loosely coupled application communications. It can create, send, receives and read messages using Java.
- Easy integration of incompatible systems
- Support for message acknowledgement
- Support for transactions (JTA)
Asynchronous messages:
– As transaction volumes increases, asynchronous messages can queue requests until they can be processed.
–Asynchronous messages are less impacted by network, hardware and software failures.
- When processing capabilities are exceeded, information is not lost, it’s delayed.
- Not recommended for non Java integrations (legacy systems).
- Requires support for message based integration
JCA exposes legacy applications functionalities to be consumed by JavaEE projects.
Exposes resources in generic / highlevel way
Require resources vendor connector implementation.
Tightly coupled between EIS and application.
API to build webservices between clients that exchange XML data.
Addresses Security and Reliability to enterprise services
Can interoperate with other WebServices
Support for HTTP/HTTPS and SMTP protocols
XML data only.
Big XMLs transportation (XML envelopes are too big)
No support for async messages.
API to build webservices that uses REST as default communication method.
Is embedded in JavaEE 6 containers and up. In earlier versions we need to configure web.xml
Uses annotations
HTTP methods can easy represent CRUD methods (CREATE, PUT, DELETE, GET, etc)
Supports JSON
Supports only HTTP/HTTPS methods.
No automatic support for WS Security.
Doesn't support directly asynchronous communications.
Provides database interaction and is widespread technology in Java platform.
Mature technology
Some performance issues must be resolved with JDBC instead of JPA.
A drive for every database vendor is required.
Code needed to map tables and columns.
Logic is normally featured in SQL code.
No notion of objects. You translate your result set into Java Objects
Use of @Annotations to translate database metadata
Can be used outside EJB.
Some tasks cannot be solved efficiently.
Performance may be affected if you use multiple layers between your app and your database.
Language independent object distributable pattern defined by OMG. The center of CORBA is the Object Request Broker (ORB). ORB is the distributed programming service that enables objects to locate and iterate with others. CORBA objects have interfaces (IDL). Then the client makes calls to those interfaces as they were running locally. CORBA objects interacts with ORB either through an ORB interface or an Object Adapter.
Heterogeneous objects are supported.
IIOP guarantees interoperability between vendors.
Very well documented.
Objects are not passed by value. Only arguments data is passed.
The server/client need to reconstitute objects using the data.
Only supported data types can be passed unless CORBA 2.3 is used.
Java Implementation of RPC (Remote Procedure Call).
Object oriented, objects can be passed.
The datatype can be any Java Object.
Must use Java on local and remote objects.
Arguments must implement Serializable interface or extends java.rmi.Object
Message-driven beans are message consumers that can send and receive messages asynchronously. They’re called by EJB container when a Message is received and that bean is registered to this type of message. MDB can receives messages because they implements javax.jms.MessageListener interface. They receive JMS objects in the same manner as any JMS service object. MDBs don’t maintain session states. They call the onMessage() method when receives messages.
The person which is responsible to assign MDBs to a destination in deploy time is called EJB deployer.
- Life cycle of a MDB:
1. Container invokes newInstance() on the MDB
2. Creates an instance of javax.ejb.MessageDrivenContext()
3. Set the messageDrivenContext() to the MDB through setMessageDrivenContext(context)
4. Call ejbCreate() method before put this MDB into the list of available MDB.
5. Container sets the MDB to available pool.
6. If the MDB throws any exception, the MDB is removed from available pool and the container rollback any transaction started by the container or MDB.
MDBs cannot invoke methods of acknowledge, as acknowledge() or rollback(), they are permitted for the container only.
AUTO_ACKNOWLEDGE permits the message to be delivered once.
DUPS_OK_ACKNOWLEDGE permits the message to be delivered duplicated after failure.
Are services provided by an EJB container:
– Handles all communication for JMS services
– Checks the availability of which MDB must be used.
– Enables a propagation of the Security Context associating the role from Deployment Descriptor to the appropriate security thread.
– Creates transactional context if is specified in Deployment Descriptor.
– Passes the message into onMessage() method, according with the type of the message.
– Reallocates the MDB to the pool of resources.
The application Server (AS) provides connection, security and transaction management. The application’s component contract via JCA resource is provided by Common Client Interface (CCI) that is consistent with accessing other resources like JDBC and JMS.
SOAP is a protocol to exchange data between applications. It uses XML and transports in HTTP/HTTPS protocols, but can also be found in SMTP, TCP and JMS. SOAP messages have the following elements:
- Envelope: defines what is in the message and how treat those informations.
- Header: contains application specific information.
- Body: contains the SOAP message
- Fault: Contains the error messages describing faults on the processing. If present, it will appear as a child element of the body.
A SOAP based design must include the following characteristics:
- A formal contract must be estabilished to describe the service. WSDL is a kind of formal contract that include messages, operations, bindings, and the location of the Web Service. You can also process SOAP messages in JAX-WS without a WSDL.
- The architecture must provide complex non functional requirements. Such security, transactions, addressing, trust, etc.
Requirements for JAX-WS Endpoints
– Must start with annotation javax.jws.WebService or javax.jws.WebServiceProvider
- The business methods must be declared public and not static or final.
- Exposed methods must be annotated with @WebMethod annotation.
- Exposed methods must have compatible parameters and return type.
- The implementing class can't be declared as final and abstract.
- The implementing class must have a default public constructor.
- Can use @PostConstruct and @PreDestroy annotations.
The major problem in this approach is because if the requirements starts to getting bigger, the message will also be bigger and requires more CPU to parse the message.
XML format describing the service functionalities and params for each of them.
A XML Schema definition is a XML format language to define if a given XML is valid according their rules.
Best suited for basic, ad hoc integration scenarios. Integrates better with HTTP than XML Web Services because it doesn't need XML configurations, a WSDL, and other stuff. Project Jersey is the project-ready implementation for JAX-RS specification. The following conditions specify a good set of requirements to build RESTful web services:
- Completely stateless environment. A good test of it is consider wether the interaction can survive a restart of the server.
- A caching infrastructure can be levaraged for performance. If the data suited by the server is not dinamically generated, caching infrastructure can be generated with the resouces that web servers already provides. You must take care because these caches are limited to HTTP GET method.
- You don't have schemas to describe the data, so, both of producer and consumer must know the context they're talking. Basically, you don't have how to describe your data. Most of REST providers delivers development kit with each description of features.
- RESTful is a good option in cases of limited bandwidth. PDAs and Mobile phones for example, doesn't have a good bandwidth and the XML payload of a SOAP requisition is not a good option.
- Improves the developers production because it's easier than JAX-WS web services and you can consume them in your web pages without refactoring.
- @Produces: indicates the mimetype of the content generated of that method
- @Consumes: indicates the mimetype consumed by that method
- The ability to reuse functionalities across multiple projects
- Easy integration across platforms.
- Use of standards, agile approach.