| Author |
Making calls outside the container
|
Benjamin Weaver
Ranch Hand
Joined: Apr 08, 2003
Posts: 161
|
|
|
I'm new to EJBs and have the following question. Can I make a socket call to a remote server from within an EJB? For example, can I make such a socket call from within the onMessage() method of a MessageDrivenBean? Or delegate to an object that can make the socket call?
|
 |
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
|
|
|
You can, but the specification strongly suggests you not to. I wouldn't be too afraid of doing this as long as you know that you're breaking the spec and accept the possibility of side effects.
|
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
|
 |
Pradeep bhatt
Ranch Hand
Joined: Feb 27, 2002
Posts: 8876
|
|
Socket clients are acceptable but not socket servers. The EJB architecture allows an enterprise bean instance to be a network socket client, but it does not allow it to be a network server. Allowing the instance to become a network server would conflict with the basic function of the enterprise bean-- to serve the EJB clients. [ August 28, 2003: Message edited by: Pradeep Bhat ]
|
Groovy
|
 |
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
|
|
|
That's correct. I was too strict in my wording.
|
 |
Benjamin Weaver
Ranch Hand
Joined: Apr 08, 2003
Posts: 161
|
|
|
Thanks! This is all very useful. Indeed I had a socket client in mind. As you remark, a socket server would be a redundancy.
|
 |
 |
|
|
subject: Making calls outside the container
|
|
|