Java EE and application servers - what can I do?

I decided it was time for me to delve into Java EE as a whole. I use EE with some methods in Java SE, such as JPA or JMS, but I still messed around with Java SE, and I believe that Java EE and the application server will solve some of my problems that I have.

BUT: I have some questions after reading some articles on the Internet.

1st: Am I limited to request-response applications? I have an application that processes XML documents via HTTP. All delivered objects are added to the queue, which will be sent to another thread. Some checking is done for these objects, including opening sockets on a remote computer (I heard that EJ-Beans are not allowed to do this, is that true?). So, is it possible to do this on the application server?

2nd: I know there is a message with beans message, is it possible to send JMS messages to MDB from outside the application server? I have a service that sends JMS messages but starts as an outdated system, and not inside the same application server.

3rd: How can a system administrator or user configure my application? I know that some things, such as database connections, are configured on the application server, and my application can search for them through JNDI or receive through DI. But what about a specific application configuration?

Yes, these are pretty unnecessary questions, but maybe someone has time to explain to me how it all works. :)

Regards, Posix

PS:

4th: It seems that EJBs cannot do anything with files, so Java EE does not seem to be an option for a Service that receives files, pushes them to different systems and wants them to write to Socket (see question 1)?

+4
source share
5 answers

I can say that Java EE can be used without any doubt in your case. Let me tell you a little more about your specific issues:

  • You can open a socket connection from your EJB. Nothing prevents you from doing this. However, this type of work is not recommended for Java EE applications. In my opinion, the best option is to implement the Java EE Connector (JCA), which will manage the socket pool in your proprietary system. This is a model way to implement such integration in accordance with the specification.

  • Yes! It is possible to receive messages sent from an external application / system (outside the AS). This is the main idea of ​​integration using messaging :) In many cases, your Java EE application receives messages via MDB from the JMS channel, but JMS is only an API and can be implemented by any messaging system, for example. IBM MQ. In this architecture, the external system puts the MQ message in the queue, and your Java EE application that listens for the queue receives the message through the JMS API!

  • Generally speaking, Application Server provides administrators with excellent tools for managing Java EE resources such as data sources, JMS connections, JMS destinations, JTA transaction manager, etc. If you require the ability to modify your specific Java EE application, the best options seem to be JMX. Just implement several MBeans, export them to the JMX server built into your Application Server, and you're done. This task is really trivial, say, in JBoss, but most modern application servers nowadays offer extensive JMX capabilities.

  • At first glance, EJB is not suitable for working with files. But remember that the implementation of your EJBs is still written in pure Java, so nothing prevents you from reading / streaming files and so on. I have experience with large Java EE applications that process large files as input files and can assure you that Java EE is a good technology choice :)

+2
source

Here are the limitations on the EJB 1.1 specification.

Here are my answers to your questions:

  • I believe that EJB can open a socket on a remote machine, but I would say that open sockets are too low a level of operation. I would think about exposing what this socket does for you, like another EJB.
  • An MDB is only a listener that registers in a particular topic or queue. He does not say anything about sending. If your client knows how to get a message in the queue, this is possible. They just need to know the queue url and be able to create a connection.
  • The administrator sets up connection pools, JNDI names, etc. - everything. They do this using the admin console for the application server.
0
source

I would suggest applying each technology to the appropriate points where you are in pain right now. As for your specific points,

  • In the context of EE, you add messages to a JMS queue that has MDBs that will do the actual processing. As for managing the HTTP request / response life cycle, you will manage it the same way as now, or use the existing library if necessary for you. By going to the EE application server, you allow the application server to manage flows, transactions, etc. Instead of manually managing it.

  • As stated in duffymo, MDBs are responsible for receiving messages, they don’t care where the message came from.

  • The system administrator can configure the application server as specified by duffymo. In addition, you can open JMX beans for other systems or for the end user so that they can configure services if you want to.

0
source
  1. This is a violation of the EE specification in order to do anything with files (so that the EE application is portable and redistributable). However, since this is just plain Java code, yopu can choose whatever you want. As long as you know what your target environment looks like (for example, the system is intended for internal use), I would not hesitate to modify the files just because the specification says so.
0
source
  • On an application server such as Tomcat (others may also be possible, but I have never worked with them), you can not only do things after receiving the request, but also do something (including starting long threads) when the server starts. Basically, you can do everything you can with "normal" Java. In fact, you can put a regular Java application on the application server by simply adding a piece of code that calls the corresponding main () when the server starts.
0
source

All Articles