0 Replies Latest reply on Apr 16, 2012 3:53 AM by nick pomfret

    Getting started with a cluster

    nick pomfret Newbie

      I'm looking for an example of the most basic programatic configuration of a hornetq cluster using an EmbeddedJMS server.  I've tried (code below) but it's not quite working. There are no exceptions, but the client isn't joining the cluster, and I can't even tell if the servers are talking to each other.  Is there a decent example out there of the simplest most basic configuration possible? Or perhaps someone could point out the errors in the following...

       

      My servers are configured with:

       

            Configuration configuration = new ConfigurationImpl();

       

       

              final String groupAddress = "231.7.7.8";

              final int groupPort = 9878;

       

       

              Map<String, Object> acceptorParams = new HashMap<String, Object>();

              acceptorParams.put(PORT_PROP_NAME, messagingServiceConfig.messagingPort());

              acceptorParams.put(USE_NIO_PROP_NAME, false);

       

       

              TransportConfiguration acceptorConfig = new TransportConfiguration(NettyAcceptorFactory.class.getName(), acceptorParams);

       

       

              TransportConfiguration connectorConfig = new TransportConfiguration(NettyConnectorFactory.class.getName(), acceptorParams);

       

       

              CoreQueueConfiguration queueConfig = new CoreQueueConfiguration(

                  "some-core-queue",

                  "some-name",

                  null,

                  false);

       

       

              ClusterConnectionConfiguration clusterConnectionConfig = new ClusterConnectionConfiguration(

                  CLUSTER_NAME,

                  queueConfig.getAddress(),

                  "netty",

                  1000,

                  false,

                  false,

                  1,

                  1024,

                  DISCOVERY_NAME);

       

       

              List<String> connectorInfos = new ArrayList<String>();

              connectorInfos.add("netty");

              BroadcastGroupConfiguration broadcastGroupConfig = new BroadcastGroupConfiguration(

                  DISCOVERY_NAME,

                  null,

                  -1,

                  groupAddress,

                  groupPort,

                  250,

                  connectorInfos);

       

       

              DiscoveryGroupConfiguration discoveryGroupConfig = new DiscoveryGroupConfiguration(

                  DISCOVERY_NAME,

                  null,

                  groupAddress,

                  groupPort,

                  1000,

                  1000);

       

       

              configuration.setSecurityEnabled(false);

              configuration.setJMXManagementEnabled(true);

              configuration.setClustered(true);

              configuration.getClusterConfigurations().add(clusterConnectionConfig);

              configuration.getAcceptorConfigurations().add(acceptorConfig);

              configuration.getConnectorConfigurations().put("netty", connectorConfig);

              configuration.getQueueConfigurations().add(queueConfig);

              configuration.getDiscoveryGroupConfigurations().put(DISCOVERY_NAME, discoveryGroupConfig);

              configuration.getBroadcastGroupConfigurations().add(broadcastGroupConfig);

       

       

              configuration.setPersistenceEnabled(false);

              configuration.setAddressesSettings(queueSpecificSettings.toAddressSettings());

              configuration.setThreadPoolMaxSize(ConfigurationImpl.DEFAULT_THREAD_POOL_MAX_SIZE * 2);

              configuration.setLogDelegateFactoryClassName(Log4jLogDelegateFactory.class.getName());

              configuration.setBindingsDirectory(subdirectoryInMessagingDirectory("bindings"));

              configuration.setJournalDirectory(subdirectoryInMessagingDirectory("journal"));

              configuration.setLargeMessagesDirectory(subdirectoryInMessagingDirectory("largemessages"));

              configuration.setPagingDirectory(subdirectoryInMessagingDirectory("paging"));

              JMSConfiguration jmsConfig = new JMSConfigurationImpl();

       

       

              server = new EmbeddedJMS();

              server.setConfiguration(configuration);

              server.setJmsConfiguration(jmsConfig);

              server.start();

       

      And the clients are configured with:

       

              final String groupAddress = "231.7.7.8";

              final int groupPort = 9878;

       

       

              DiscoveryGroupConfiguration discoveryGroupConfig = new DiscoveryGroupConfiguration(

                  HornetQBroker.DISCOVERY_NAME,

                  null,

                  groupAddress,

                  groupPort,

                  1000,

                  1000);

       

       

              HornetQConnectionFactory factory = HornetQJMSClient.createConnectionFactoryWithoutHA(discoveryGroupConfig, JMSFactoryType.CF);

       

       

              prefetchMode.apply(factory);

       

       

              factory.setClientFailureCheckPeriod(DEFAULT_CLIENT_FAILURE_CHECK_PERIOD);

              factory.setRetryInterval(DEFAULT_RETRY_INTERVAL);

              factory.setRetryIntervalMultiplier(1.5);

              factory.setMaxRetryInterval(10000);

              factory.setReconnectAttempts(-1);

              // NAM: A bit of a hack to disable large messages

              factory.setMinLargeMessageSize(Integer.MAX_VALUE);

       

      Any help would be appreciated.