Guest User

Untitled

a guest
Apr 29th, 2015
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.83 KB | None | 0 0
  1. package activemq.test;
  2.  
  3. import java.util.HashMap;
  4. import java.util.HashSet;
  5. import java.util.Map;
  6.  
  7. import org.apache.activemq.api.core.TransportConfiguration;
  8. import org.apache.activemq.core.config.Configuration;
  9. import org.apache.activemq.core.config.impl.ConfigurationImpl;
  10. import org.apache.activemq.core.remoting.impl.netty.NettyAcceptorFactory;
  11. import org.apache.activemq.core.server.ActiveMQServer;
  12. import org.apache.activemq.core.server.ActiveMQServers;
  13.  
  14. public class Server {
  15.     public static void main(final String arg[]) throws Exception
  16.     {
  17.         try
  18.         {
  19.             // Step 1. Create the Configuration, and set the properties accordingly
  20.             Configuration configuration = new ConfigurationImpl();
  21.             //we only need this for the server lock file
  22.             configuration.setJournalDirectory("target/data/journal");
  23.             configuration.setPersistenceEnabled(false);
  24.             configuration.setSecurityEnabled(false); // http://activemq.apache.org/security.html
  25.             /**
  26.              * this map with configuration values is not necessary (it configures the default values).
  27.              * If you want to modify it to run the example in two different hosts, remember to also
  28.              * modify the client's Connector at {@link EmbeddedRemoteExample}.
  29.              */
  30.             Map<String, Object> map = new HashMap<String, Object>();
  31.             map.put("host", "localhost");
  32.             map.put("port", 61616);
  33.  
  34.            
  35.             TransportConfiguration transpConf = new TransportConfiguration(NettyAcceptorFactory.class.getName(),map);
  36.  
  37.             HashSet<TransportConfiguration> setTransp = new HashSet<TransportConfiguration>();
  38.             setTransp.add(transpConf);
  39.  
  40.             configuration.setAcceptorConfigurations(setTransp);
  41.  
  42.             // Step 2. Create and start the server
  43.             ActiveMQServer server = ActiveMQServers.newActiveMQServer(configuration);
  44.             server.start();
  45.         }
  46.         catch (Exception e)
  47.         {
  48.             e.printStackTrace();
  49.             throw e;
  50.         }
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment