what is the benefit of using JNDI for the JMS connection setup

rayleeustc_ll
rayleeustc_ll Member Posts: 7 ✭✭

solace doc suggestion to destination object is configured on the JNDI store on the event broker, and JMS application can perform a destination lookup for obtaining an InitialContext, what is the benefit to do this than setup the JMS connection to solace server directly from solace client.

Comments

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 955 admin

    Hi @rayleeustc_ll,
    Great question! The benefit of using JNDI is essentially to not hard code items that may differ per environment. By using JNDI to look up your JMS objects (such as Connection Factory and Destinations) it allows for these JMS objects to be tuned on an environment by environment, or broker by broker basis without you needing to change the code. This gives your solace (or other JMS provider) administrators the flexibility to create and configure these objects based on the resources available to them while allowing your app to be portable between objects. For example, your app just tries to lookup the "MY.QUEUE" queue via JNDI and doesn't need to know its access type, message quota, max consumer count, or many other things that the administrator can tune under the covers.

    -Marc

  • nram
    nram Member, Employee Posts: 80 Solace Employee

    Great points @marc . If I may add my 2c...
    @rayleeustc_ll , JNDI provides an abstraction between your application and the message broker. Its not uncommon to use an external JNDI service (such as LDAP) where you can store the mapping from logical name space (used by your application) and the physical name space (used by message broker). In the case of Solace, the JNDI service is running on the broker itself.

    Use of JNDI is also supposed to shield the application when moving across message brokers. This however, doesn't always work since the JNDI provides name mapping, but the properties mapping is left to the message providers. Solace for eg, stores a rich set of properties where as other vendors may not.

    JNDI sometimes makes accessing vendor specific features little hard in the code. Most vendors also allow JMS connection bypassing JNDI completely with proprietary APIs. Pl also see this link: https://docs.solace.com/Solace-JMS-API/Obtaining-Connection-Fac.htm#establishing_connections_577400906_326490

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 955 admin

    Thanks for adding your 2c @nram 👍