This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB3.0 - JBoss - How to send JMS message to an MDB

 
Andor Nemeth
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Andor Nemeth
Greenhorn
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 16
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 204
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 162
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 108
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ..
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic