views:

449

answers:

5

Hi everyone!

I decided that it is time for me to dig into the whole Java EE stuff. I am using EE some techniques whithin Java SE like JPA or JMS, but i still messing around with Java SE and i believe Java EE and an application server will solve some of my problems i have.

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

1st: Am i limited to request-response applications? I have an application which serves XML documents via HTTP. All delivered objects are added to a queue which will be dispatched in a different thread. Some validation is made for this objectes, including the opening of sockets to a remote machine (I heard EJ-Beans are not allowed to do this, is this true?). So, is is possible to do this within an application server?

2nd: I know there are Message driven beans, is it possible to send JMS messages to a MDB from outside of the application server? I have a service which sends JMS messages, but runs, as a legacy system, not inside the same application server.

3rd: How can the System Adminstrator or User configure my application? I know that some things like database connections are configured within the application server and my application can lookup them via JNDI or get them via DI. But what about application specific configuration?

Yeah, these are quite noobish questions, but maybe someone has the time to explain me how all this stuff is working. :)

regards, Posix

PS:

4th: It seems EJBs are not allowed to do anything with files, so Java EE seems to be no option for a Service which receives Files, pushes them around to different systems and want them to write to a Socket (see question 1)?

A: 

Here are the restrictions on EJB 1.1 spec.

Here's my take on your questions:

  1. I believe an EJB can open a socket on a remote machine, but I would say that opening sockets is too low level an operation. I'd think about exposing whatever that socket is doing for you as another EJB.
  2. An MDB is just a listener that's registered with a particular topic or queue. It doesn't say anything about sending. If your client knows how to get a message to the queue it's possible. They just have to know the queue URL and be able to create a connection.
  3. The admin sets up connection pools, JNDI names, etc. - everything. They do it using the admin console for the app server.
duffymo
A: 

I would suggest applying each technology to the appropriate points where you are currently feeling pain. Regarding your specific points,

  1. In an EE context, you would add the messages to a JMS queue, that has MDBs which would do the actual processing. Regarding the management of the HTTP request/response lifecycle, you would manage this the same way you do now, or use an existing library to do if for you. By moving to an EE app server, you would allow the app server to manage the threading, transactions, etc. instead of having to manage it manually.

  2. As duffymo stated, MDBs are responsible for receiving messages, they do not care where the message originated from.

  3. The system administrator can configure the app server as duffymo stated. Additionally, you can expose JMX beans to other systems or to the end user to allow them to configure services if you so desire.

Rich Kroll
A: 
  1. It's a violation of the EE spec to do anything with files (to ensure that an EE app is portable and distributable). However since it's all just plain Java code, yopu can choose to do anything that you want. As long as you know how your target environment looks (eg the system is for internal use) I wouldn't hesitate modifying files just because the spec says so.
Jigglypuff
A: 
  1. In an application server like Tomcat (others too, probably, but I've never worked with them) you can not only execute things upon receiving a request, but also do things (including starting long running threads) on server startup. Basically you can do anything that you can with "normal" Java. In fact, you could put a normal Java app in application server if you just include a piece of code which calls the appropriate main() on server startup.
Bart van Heukelom
+1  A: 

I can say that Java EE can be used without any doubts in your case. Let me drill a little bit more into your specific questions:

  1. You can open socket connection from your EJB. There is nothing that prevents you from doing that. However this kind of operation is not advised for Java EE applications. In my opinion the better option is to implement Java EE Connector (JCA) that would manage pool of socket connections to your proprietary system. This is the model way to implement such a integration as per specification.

  2. Yes! It is perfectly possible to receive messages send from external application/system (outside the AS). This is main idea of integration using messaging :) In many cases your application being Java EE application receives messages via MDB from JMS channel, but JMS is only an API and can be implemented by any messaging system e.g. IBM MQ. In this architecture the external system puts an MQ message onto the queue and your Java EE application that listens to the very queue receives the message via JMS API!

  3. Generally speaking Application Server gives the Administrator great tools to manage Java EE resources i.e. data sources, JMS connection factories, JMS destinations, JTA transaction manager, etc. If you require the ability to change your specific Java EE application the best options seems to be JMX. Just implement a few MBeans, export those to the JMX server embedded within your Application Server and you are done. This task is really trivial in, say, JBoss, but most of the modern Application Servers offer extensive JMX capabilities these days.

  4. For the first glance, EJB doesn't seem to be the best for dealing with files. But remember that 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 are handling large files as input files and can assure you that Java EE is is a good technology choice :)

pregzt
The point about files is that files are not clusterable or scailable (that is, if there is a failover scenario, you lose the file), so it would make sense, if you need that kind of scailability and fault tollerance, you need to isolate the file processor on to some other kind of context than a J2EE container. If you just run in a simple single instance J2EE container and the app server allows it, it will be just fine.
Yishai
Yoshai, scalability and fault-tolerance is the matter of file system of choice. It is possible to use modern fault-tolerant (parallel) distributed file system that gives you lots. The things that you loose dealing with files and sockets within JEE application are transactions managed by Application Server (JTA). An from my experience the transactions (especially XA infrastructure) are one of the key features of relaible JEE applications.
pregzt