jndiServer.setRmiPort(1098);
jndiServer.setRmiBindAddress("localhost");
jndiServer.start();
// Step 4. Create the JMS configuration
JMSConfiguration jmsConfig = new JMSConfigurationImpl();
// Step 5. Configure context used to bind the JMS resources to JNDI
Hashtable<String, String> env = new Hashtable<String, String>();
env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
env.put("java.naming.provider.url", "jnp://localhost:1099");
env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
Context context = new InitialContext(env);
jmsConfig.setContext(context);
// Step 6. Configure the JMS ConnectionFactory
TransportConfiguration connectorConfig = new TransportConfiguration(NettyConnectorFactory.class.getName());
ConnectionFactoryConfiguration cfConfig = new ConnectionFactoryConfigurationImpl("cf", connectorConfig, "/cf");
jmsConfig.getConnectionFactoryConfigurations().add(cfConfig);
// Step 7. Configure the JMS Queue
JMSQueueConfiguration queueConfig = new JMSQueueConfigurationImpl("queue1", null, false, "/queue/queue1");
jmsConfig.getQueueConfigurations().add(queueConfig);
// Step 8. Start the JMS Server using the HornetQ core server and the JMS configuration
JMSServerManager jmsServer = new JMSServerManagerImpl(hornetqServer, jmsConfig);
jmsServer.start();
System.out.println("Started Embedded JMS Server");