Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class EmbeddedServer {
- public static void main(final String arg[]) throws Exception {
- try {
- // Step 1. Create the Configuration, and set the properties accordingly
- Configuration configuration = new ConfigurationImpl();
- //we only need this for the server lock file
- configuration.setJournalDirectory("target/data/journal");
- configuration.setPersistenceEnabled(false);
- configuration.setSecurityEnabled(false);
- /**
- * this map with configuration values is not necessary (it configures the default values).
- * If you want to modify it to run the example in two different hosts, remember to also
- * modify the client's Connector at {@link EmbeddedRemoteExample}.
- */
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("host", "localhost");
- map.put("port", 5445);
- TransportConfiguration transpConf = new TransportConfiguration(NettyAcceptorFactory.class.getName(), map);
- HashSet<TransportConfiguration> setTransp = new HashSet<>();
- setTransp.add(transpConf);
- configuration.setAcceptorConfigurations(setTransp);
- // Step 2. Create and start the server
- HornetQServer server = HornetQServers.newHornetQServer(configuration);
- server.start();
- ServerLocator serverLocator = HornetQClient.createServerLocatorWithoutHA(new TransportConfiguration(NettyConnectorFactory.class.getName(), map));
- ClientSessionFactory sf = serverLocator.createSessionFactory();
- // Step 4. Create a core queue
- ClientSession coreSession = sf.createSession(false, false, false);
- coreSession.createQueue(Properties.queueName, Properties.queueName, true);
- coreSession.close();
- } catch (Exception e) {
- e.printStackTrace();
- throw e;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement