Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Bind the server IP to the EJB JNDI name  RSS feed

 
Shai Ben-Hur
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a question regarding EJB3 JNDI names.

I have 5 different servers. Each server contains one common ear called infra.
I have an EJB located in the infra that has a function � activate().

In each server I have a property file specifying all the application servers IP's (So I know who is my local EJB and which remote servers EJB's I have to call).

Now, all I have to do is to call all the server's infra EJB's and activate there function.
The question is � how I can bind the server IP to the EJB JNDI name?

Is there any xml file which I can change via shell script that will do this task?

As far as I red there is a way to write it inside the persisntent.xml, is this the only way?

Thank,

Shai
 
Shai Ben-Hur
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry - ment ejb-jar.xml not persistence.xml
 
Reza Rahman
author
Ranch Hand
Posts: 580
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shai,

You have three choices:

1. Read your config file, connect to the remote JNDI context of each server at runtime and invoke your EJB manually.
2. Dynamically generate an XML DD with the fully resolved JNDI name/remote EJB name for each of your servers. Loop through these EJB references at runtime and invoke them.
3. Re-write the EJBs instances on each server as MDBs. Have these MDBs listen to single, centralized JMS topic. You can then trigger all the MDBs by sending a single "activate" message to this single JMS topic.

If you can use JMS, I recommend option 3, it is the most robust and loosely coupled design. If you cannot, I would go for option 1. It is simpler and more flexible.

Regards,
Reza
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how I can bind the server IP to the EJB JNDI name?


Why would you ever want to do this? What benefits are associated with having an IP address as part of a JNDI name?

Better to use "abstract" names, e.g. Remote, Local, rather than some machines IP address, in my opinion.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!