| Author |
EJB3.0 - JBoss - How to send JMS message to an MDB
|
Andor Nemeth
Greenhorn
Joined: Jul 06, 2007
Posts: 16
|
|
Hi all, I have an MDB. It has been successfuly deployed in JBoss: I have trouble writting a client. How can I locate the JMS destination and send messages to it from a regular java client application?! [ July 22, 2007: Message edited by: Andor Nemeth ]
|
SCJP 5<br />SCBCD 5 (next target)
|
 |
Andor Nemeth
Greenhorn
Joined: Jul 06, 2007
Posts: 16
|
|
I've solved this problem. So, if you're using JBoss you have to get jbossall-client.jar into your CLASSPATH! (Be careful to import the right one, there's also a jboss-client.jar!) Here's the client code I've used to send a message to the JMS queue destination: [ July 22, 2007: Message edited by: Andor Nemeth ]
|
 |
James Frankman
Greenhorn
Joined: Jun 01, 2006
Posts: 12
|
|
Andor, Thanks for the example. I am new at MDBs so forgive my ignorance. If the client is on a remote host, how does the client know where the server is? Is this done in the initialcontext. Is there some setting file you need to setup?
|
 |
Andor Nemeth
Greenhorn
Joined: Jul 06, 2007
Posts: 16
|
|
Originally posted by James Frankman: If the client is on a remote host, how does the client know where the server is? Is this done in the initialcontext. Is there some setting file you need to setup?
Hi James! Yes, it's done in the InitialContext. If you look at the InitialContext, it can take a Properties object with information about your remote server as an argument. These settings aren't the same for every app. server, so you should consult your container vendor's manual. Actually you're locating a remote JNDI service this way. Here's an example client code for JBoss: I've omitted exception handling in this example. "YOUR_SERVER_IP_COMES_HERE" could be also: localhost! Andor [ August 08, 2007: Message edited by: Andor Nemeth ]
|
 |
michael yue
Ranch Hand
Joined: Nov 20, 2003
Posts: 204
|
|
Hi, Just a simple question. How do you define the lookup string below? jndiContext.lookup("YourSuperbEJB/remote"); Is the default structure like YourSuperbEJB/remote ? What if I have different application ear with similar ejb names? Thanks
|
 |
Bennet Xavier
Ranch Hand
Joined: Jun 19, 2008
Posts: 149
|
|
What a wonderful code it is, it worked nicely. thank you very much for superb example.
I might be little late in thanking, please don't mind.
Thanks,
Bennet Xavier.
|
 |
ankit kumar
Ranch Hand
Joined: Apr 28, 2008
Posts: 105
|
|
michael yue wrote:Hi,
Just a simple question. How do you define the lookup string below?
jndiContext.lookup("YourSuperbEJB/remote");
Is the default structure like YourSuperbEJB/remote ?
What if I have different application ear with similar ejb names?
Thanks
YourSuperbEJB is your @Stateless(name = "YourSuperbEJB ") which you write in your bean implementing class. And remote is that you are calling it on the remote , if you are on local you can write "YourSuperbEJB/local" ..
please correct me if I am wrong ..
|
Cleared SCJP 1.5 | Cleared SCWCD 5.0
SCBCD in progress.....
|
 |
 |
|
|
subject: EJB3.0 - JBoss - How to send JMS message to an MDB
|
|
|