/** * Load Hibernate credentials * @return credentials */ private HibernateCredentials loadHibernateConfiguration() { HibernateCredentials hibernateCredentials = new HibernateCredentials(); hibernateCredentials.setHibernateURL(properties.getProperty("HibernateURL")); hibernateCredentials.setHibernateUsername(properties.getProperty("HibernateUsername")); hibernateCredentials.setHibernatePassword(properties.getProperty("HibernatePassword")); hibernateCredentials.setHibernateDriver(properties.getProperty("HibernateDriver")); hibernateCredentials.setHibernateDialect(properties.getProperty("HibernateDialect")); return hibernateCredentials; }
/** * Load Consumer (RabbitMQ) credentials * @return credentials */ private ConsumerCredentials loadConsumerCredentials() { ConsumerCredentials consumerCredentials = new ConsumerCredentials(); consumerCredentials.setConsumerHost(properties.getProperty("ConsumerHost")); consumerCredentials.setConsumerUsername(properties.getProperty("ConsumerUsername")); consumerCredentials.setConsumerPassword(properties.getProperty("ConsumerPassword")); consumerCredentials.setConsumerPort(Integer.parseInt(properties.getProperty("ConsumerPort"))); consumerCredentials.setConsumerVirtualHost(properties.getProperty("ConsumerVirtualHost")); consumerCredentials.setConsumeFromQueue(properties.getProperty("ConsumeFromQueue")); return consumerCredentials; }
/** * Load Publisher (RabbitMQ) credentials * @return credentials */ private PublisherCredentials loadPublisherCredentials() { PublisherCredentials publisherCredentials = new PublisherCredentials(); publisherCredentials.setPublisherHost(properties.getProperty("PublisherHost")); publisherCredentials.setPublisherUsername(properties.getProperty("PublisherUsername")); publisherCredentials.setPublisherPassword(properties.getProperty("PublisherPassword")); publisherCredentials.setPublisherPort(Integer.parseInt(properties.getProperty("PublisherPort"))); publisherCredentials.setPublisherVirtualHost(properties.getProperty("PublisherVirtualHost")); publisherCredentials.setPublisherDispatchExchange(properties.getProperty("PublisherDispatchExchange")); publisherCredentials.setPublisherBroadcastExchange(properties.getProperty("PublisherBroadcastExchange")); return publisherCredentials; }
/** * Load Database credentials * @return credentials */ private DatabaseCredentials loadDatabaseCredentials() { DatabaseCredentials databaseCredentials = new DatabaseCredentials(); try { databaseCredentials.setDatabasePort(Integer.parseInt(properties.getProperty("DatabasePort"))); } catch (Exception e) { databaseCredentials.setDatabasePort(DatabaseCredentials.DEFAULT_DATABASE_PORT); } try { databaseCredentials.setDatabasePageLimit(Integer.parseInt(properties.getProperty("DatabasePageLimit"))); } catch (Exception e) { databaseCredentials.setDatabasePageLimit(DatabaseCredentials.DEFAULT_DATABASE_PAGE_LIMIT); } try { databaseCredentials.setDatabaseConnections(Integer.parseInt(properties.getProperty("DatabaseConnections"))); } catch (Exception e) { databaseCredentials.setDatabaseConnections(DatabaseCredentials.DEFAULT_DATABASE_CONNECTIONS); } databaseCredentials.setDatabaseHost(properties.getProperty("DatabaseHost")); databaseCredentials.setDatabaseUsername(properties.getProperty("DatabaseUsername")); databaseCredentials.setDatabasePassword(properties.getProperty("DatabasePassword")); databaseCredentials.setDatabaseName(properties.getProperty("DatabaseName")); return databaseCredentials; }
/** * Load Consumer (RabbitMQ) credentials * @return credentials */ private ConsumerCredentials loadConsumerCredentials() { ConsumerCredentials consumerCredentials = new ConsumerCredentials(); consumerCredentials.setConsumerHost(properties.getProperty("ConsumerHost")); consumerCredentials.setConsumerUsername(properties.getProperty("ConsumerUsername")); consumerCredentials.setConsumerPassword(properties.getProperty("ConsumerPassword")); consumerCredentials.setConsumerPort(Integer.parseInt(properties.getProperty("ConsumerPort"))); consumerCredentials.setConsumerVirtualHost(properties.getProperty("ConsumerVirtualHost")); // consumer queue name String consumer = properties.getProperty("ConsumerDataQueue"); if (consumer != null && !consumer.isEmpty()) { consumerCredentials.setConsumerDataQueue(consumer); } else { consumerCredentials.setConsumerDataQueue(ConsumerCredentials.DEFAULT_DATA_QUEUE); } // commands queue name String commands = properties.getProperty("ConsumerCommandsQueue"); if (commands != null && !commands.isEmpty()) { consumerCredentials.setConsumerCommandsQueue(commands); } else { consumerCredentials.setConsumerCommandsQueue(ConsumerCredentials.DEFAULT_COMMANDS_QUEUE); } return consumerCredentials; }
/** * Initialise connection to RabbitMQ */ private void initialiseConnection(ConsumerCredentials credentials) { // connect to the RabbitMQ based on settings from Load ConnectionFactory factory = new ConnectionFactory(); factory.setUsername(credentials.getConsumerUsername()); factory.setPassword(credentials.getConsumerPassword()); factory.setHost(credentials.getConsumerHost()); factory.setPort(credentials.getConsumerPort()); factory.setVirtualHost(credentials.getConsumerVirtualHost()); factory.setAutomaticRecoveryEnabled(true); try { // create new connection connection = factory.newConnection(); logger.trace(String.format("RabbitMQ Consumer connected to %s:%d", credentials.getConsumerHost(), credentials.getConsumerPort())); } catch (Exception e) { logger.error(String.format("RabbitMQ Consumer couldn't be created: %s", e.getMessage())); connection = null; } }
public RabbitMQPublisher() { PublisherCredentials credentials = Loader.getSettings().getPublisherCredentials(); dispatchExchange = credentials.getPublisherDispatchExchange(); broadcastExchange = credentials.getPublisherBroadcastExchange(); establishConnection(credentials); }
public static Configuration createConfiguration(HibernateCredentials credentials) { Configuration conf = new Configuration(); // add annotated facts PersistedFacts.getListOfPersistedFactClasses().forEach(conf::addAnnotatedClass); // add mandatory hibernate classes conf.addAnnotatedClass(TemplateORM.class).addAnnotatedClass(InstanceORM.class); // now set properties conf.setProperty("hibernate.connection.driver_class", credentials.getHibernateDriver()) .setProperty("hibernate.connection.url", credentials.getHibernateURL()) .setProperty("hibernate.connection.username", credentials.getHibernateUsername()) .setProperty("hibernate.connection.password", credentials.getHibernatePassword()) .setProperty("hibernate.dialect", credentials.getHibernateDialect()) .setProperty("hibernate.hbm2ddl.auto", "update") .setProperty("show_sql", "false") .setProperty("hibernate.c3p0.min_size", "5") .setProperty("hibernate.c3p0.max_size", "20") .setProperty("hibernate.c3p0.timeout", "1800") .setProperty("hibernate.c3p0.max_statements", "50"); return conf; } }
public CDREndpoint() { pageLimit = Loader.getSettings().getDatabaseCredentials().getDatabasePageLimit(); }
public static boolean startConsumption() { RabbitMQListener listener = RabbitMQListener.getInstance(); logger.trace(String.format("Initiating RabbitMQ consumption with \"%s\" queue", consumerCredentials.getConsumeFromQueue())); return listener != null && listener.addConsumer(consumerCredentials.getConsumeFromQueue(), new FactsConsumer(), 1); }
/** * Load Publisher (RabbitMQ) credentials * @return credentials */ private PublisherCredentials loadPublisherCredentials() { PublisherCredentials publisherCredentials = new PublisherCredentials(); publisherCredentials.setPublisherHost(properties.getProperty("PublisherHost")); publisherCredentials.setPublisherUsername(properties.getProperty("PublisherUsername")); publisherCredentials.setPublisherPassword(properties.getProperty("PublisherPassword")); publisherCredentials.setPublisherPort(Integer.parseInt(properties.getProperty("PublisherPort"))); publisherCredentials.setPublisherVirtualHost(properties.getProperty("PublisherVirtualHost")); // publisher dispatch exchange name String dispatch = properties.getProperty("PublisherDispatchExchange"); if (dispatch != null && !dispatch.isEmpty()) { publisherCredentials.setPublisherDispatchExchange(dispatch); } else { publisherCredentials.setPublisherDispatchExchange(PublisherCredentials.DEFAULT_PUBLISHER_DISPATCH_EXCHANGE); } // publisher dispatch exchange name String broadcast = properties.getProperty("PublisherBroadcastExchange"); if (broadcast != null && !broadcast.isEmpty()) { publisherCredentials.setPublisherBroadcastExchange(broadcast); } else { publisherCredentials.setPublisherBroadcastExchange(PublisherCredentials.DEFAULT_PUBLISHER_BROADCAST_EXCHANGE); } return publisherCredentials; }
/** * Load Database credentials * @return credentials */ private DatabaseCredentials loadDatabaseCredentials() { DatabaseCredentials databaseCredentials = new DatabaseCredentials(); try { databaseCredentials.setDatabasePort(Integer.parseInt(properties.getProperty("DatabasePort"))); } catch (Exception e) { databaseCredentials.setDatabasePort(DatabaseCredentials.DEFAULT_DATABASE_PORT); } try { databaseCredentials.setDatabasePageLimit(Integer.parseInt(properties.getProperty("DatabasePageLimit"))); } catch (Exception e) { databaseCredentials.setDatabasePageLimit(DatabaseCredentials.DEFAULT_DATABASE_PAGE_LIMIT); } try { databaseCredentials.setDatabaseConnections(Integer.parseInt(properties.getProperty("DatabaseConnections"))); } catch (Exception e) { databaseCredentials.setDatabaseConnections(DatabaseCredentials.DEFAULT_DATABASE_CONNECTIONS); } databaseCredentials.setDatabaseHost(properties.getProperty("DatabaseHost")); databaseCredentials.setDatabaseUsername(properties.getProperty("DatabaseUsername")); databaseCredentials.setDatabasePassword(properties.getProperty("DatabasePassword")); databaseCredentials.setDatabaseName(properties.getProperty("DatabaseName")); return databaseCredentials; }
/** * Initialise connection to RabbitMQ */ private void initialiseConnection(ConsumerCredentials credentials) { // connect to the RabbitMQ based on settings from Load ConnectionFactory factory = new ConnectionFactory(); factory.setUsername(credentials.getConsumerUsername()); factory.setPassword(credentials.getConsumerPassword()); factory.setHost(credentials.getConsumerHost()); factory.setPort(credentials.getConsumerPort()); factory.setVirtualHost(credentials.getConsumerVirtualHost()); factory.setAutomaticRecoveryEnabled(true); try { // create new connection connection = factory.newConnection(); logger.trace(String.format("RabbitMQ Consumer connected to %s:%d", credentials.getConsumerHost(), credentials.getConsumerPort())); } catch (Exception e) { logger.error(String.format("RabbitMQ Consumer couldn't be created: %s", e.getMessage())); connection = null; } }
public RabbitMQPublisher() { PublisherCredentials credentials = Loader.getSettings().getPublisherCredentials(); dispatchExchange = credentials.getPublisherDispatchExchange(); broadcastExchange = credentials.getPublisherBroadcastExchange(); establishConnection(credentials); }
public UDREndpoint() { pageLimit = Loader.getSettings().getDatabaseCredentials().getDatabasePageLimit(); }
/** * Load Publisher (RabbitMQ) credentials * @return credentials */ private PublisherCredentials loadPublisherCredentials() { PublisherCredentials publisherCredentials = new PublisherCredentials(); publisherCredentials.setPublisherHost(properties.getProperty("PublisherHost")); publisherCredentials.setPublisherUsername(properties.getProperty("PublisherUsername")); publisherCredentials.setPublisherPassword(properties.getProperty("PublisherPassword")); publisherCredentials.setPublisherPort(Integer.parseInt(properties.getProperty("PublisherPort"))); publisherCredentials.setPublisherVirtualHost(properties.getProperty("PublisherVirtualHost")); publisherCredentials.setRoutingKeyPublishUDRCommand(properties.getProperty("RoutingKeyPublishUDRCommand")); // publisher dispatch exchange name String dispatch = properties.getProperty("PublisherDispatchExchange"); if (dispatch != null && !dispatch.isEmpty()) { publisherCredentials.setPublisherDispatchExchange(dispatch); } else { publisherCredentials.setPublisherDispatchExchange(PublisherCredentials.DEFAULT_PUBLISHER_DISPATCH_EXCHANGE); } // publisher dispatch exchange name String broadcast = properties.getProperty("PublisherBroadcastExchange"); if (broadcast != null && !broadcast.isEmpty()) { publisherCredentials.setPublisherBroadcastExchange(broadcast); } else { publisherCredentials.setPublisherBroadcastExchange(PublisherCredentials.DEFAULT_PUBLISHER_BROADCAST_EXCHANGE); } return publisherCredentials; }
/** * Load Database credentials * @return credentials */ private DatabaseCredentials loadDatabaseCredentials() { DatabaseCredentials databaseCredentials = new DatabaseCredentials(); try { databaseCredentials.setDatabasePort(Integer.parseInt(properties.getProperty("DatabasePort"))); } catch (Exception e) { databaseCredentials.setDatabasePort(DatabaseCredentials.DEFAULT_DATABASE_PORT); } try { databaseCredentials.setDatabasePageLimit(Integer.parseInt(properties.getProperty("DatabasePageLimit"))); } catch (Exception e) { databaseCredentials.setDatabasePageLimit(DatabaseCredentials.DEFAULT_DATABASE_PAGE_LIMIT); } try { databaseCredentials.setDatabaseConnections(Integer.parseInt(properties.getProperty("DatabaseConnections"))); } catch (Exception e) { databaseCredentials.setDatabaseConnections(DatabaseCredentials.DEFAULT_DATABASE_CONNECTIONS); } databaseCredentials.setDatabaseHost(properties.getProperty("DatabaseHost")); databaseCredentials.setDatabaseUsername(properties.getProperty("DatabaseUsername")); databaseCredentials.setDatabasePassword(properties.getProperty("DatabasePassword")); databaseCredentials.setDatabaseName(properties.getProperty("DatabaseName")); return databaseCredentials; }
public RabbitMQPublisher() { PublisherCredentials credentials = Loader.getSettings().getPublisherCredentials(); dispatchExchange = credentials.getPublisherDispatchExchange(); broadcastExchange = credentials.getPublisherBroadcastExchange(); establishConnection(credentials); }
public BillEndpoint() { pageLimit = Loader.getSettings().getDatabaseCredentials().getDatabasePageLimit(); }
public RabbitMQPublisher() { PublisherCredentials credentials = Loader.getSettings().getPublisherCredentials(); dispatchExchange = credentials.getPublisherDispatchExchange(); broadcastExchange = credentials.getPublisherBroadcastExchange(); establishConnection(credentials); }