Solace MQ – how to check destination is up or not

I have written below utility code to check whether Solace MQ destination is up or not without sending any message to destination.


try {

env = new Hashtable<String, Object>();
env.put(InitialContext.INITIAL_CONTEXT_FACTORY, "com.solacesystems.jndi.SolJNDIInitialContextFactory");
env.put(InitialContext.PROVIDER_URL, urlStr);
env.put(Context.SECURITY_PRINCIPAL, principalStr);
env.put(Context.SECURITY_CREDENTIALS, pwdStr);

initialContext = new InitialContext(env);
cf = (SolConnectionFactory) initialContext.lookup(jndiname);

connection = cf.createConnection();

SolDestination dest = (SolDestination) initialContext.lookup(destString);

System.out.println("Successfully connected.")

} catch (Exception e) {
    System.out.println("Failed to connect.")

Do I need to add something or will it validate the destination?

The code snippet you’ve provided establishes a client connection, then does a JNDI lookup for the queue.

This will successfully check if the queue exists and is provisioned as a JNDI object in the JNDI store on the router.

This does not necessarily indicate of a Solace queue is ‘up’. A queue can exist in the JNDI store but still be down for a number of reasons, such as being administratively shut down, or if the router is not active for guaranteed messaging. You will need to create a consumer in order to check if a queue is up and accessible.