File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes EJB3.0 - JBoss - How to send JMS message to an MDB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "EJB3.0 - JBoss - How to send JMS message to an MDB" Watch "EJB3.0 - JBoss - How to send JMS message to an MDB" New topic
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: 162
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: 106
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
(SCEA/OCMJEA) in progress.....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB3.0 - JBoss - How to send JMS message to an MDB
 
Similar Threads
ejb3 and mdb
Durable topic in JBoss
mdb doesn't catch messages in point2point
MDB onMessage not invoked
Jboss Remote Connection JMS