I need to write a simple java class which send messages to a Sonic Topic. I can use the JNDI values for lookup. Here is the code.
Hashtable<String, String> properties = new Hashtable<>();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.sonicsw.jndi.mfcontext.MFContextFactory");
properties.put(Context.PROVIDER_URL, "tcp://Devserver:7002");
properties.put(Context.SECURITY_PRINCIPAL, "username");
properties.put(Context.SECURITY_CREDENTIALS, "password");
properties.put("com.sonicsw.jndi.mfcontext.domain", "dmDEV");
Context jndiContext = new InitialContext(properties);
ConnectionFactory connectionFactory = (ConnectionFactory) jndiContext.lookup("TopicConnectionFactory");
Topic topic = (Topic) jndiContext.lookup("testtopic");
This throws an error javax.naming.NameNotFoundException: /testtopic not found in the specified context
When I debug the code, I can see "connectionFactory" variable has following fields and values which are totally different from the values I specify above in properties.
brokerHostName "MyMachine" (id=55)
brokerPort 0
brokerProtocol "tcp" (id=59)
brokerURL "" (id=66)
clientID null
connectID null
defaultPassword "" (id=67)
defaultUserName "Administrator" (id=68)
I need to know how to write a simple Java client to connect to a Sonic topic.