• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ..
 
Pay attention! Tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic