/** * 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; }
/** * Establish connection based on provided credentials */ public void establishConnection(PublisherCredentials credentials) { try { // setup factory ConnectionFactory factory = new ConnectionFactory(); factory.setUsername(credentials.getPublisherUsername()); factory.setPassword(credentials.getPublisherPassword()); factory.setHost(credentials.getPublisherHost()); factory.setPort(credentials.getPublisherPort()); factory.setVirtualHost(credentials.getPublisherVirtualHost()); factory.setAutomaticRecoveryEnabled(true); // establish connection connection = factory.newConnection(); dispatchChannel = connection.createChannel(); broadcastChannel = connection.createChannel(); // declare exchange to be used (we want it to be durable and based on routing key) dispatchChannel.exchangeDeclare(dispatchExchange, "direct", true); broadcastChannel.exchangeDeclare(broadcastExchange, "fanout", true); logger.trace(String.format("RabbitMQ Publisher connected to %s:%d", credentials.getPublisherHost(), credentials.getPublisherPort())); logger.trace(String.format("RabbitMQ Publisher will dispatch to \"%s\" and broadcast to \"%s\" exchanges", dispatchExchange, broadcastExchange)); } catch (Exception e) { logger.error(String.format("RabbitMQ Publisher couldn't be created: %s", e.getMessage())); // remove hanging connections stop(); } }
public RabbitMQPublisher() { PublisherCredentials credentials = Loader.getSettings().getPublisherCredentials(); dispatchExchange = credentials.getPublisherDispatchExchange(); broadcastExchange = credentials.getPublisherBroadcastExchange(); establishConnection(credentials); }
/** * Establish connection based on provided credentials */ public void establishConnection(PublisherCredentials credentials) { try { // setup factory ConnectionFactory factory = new ConnectionFactory(); factory.setUsername(credentials.getPublisherUsername()); factory.setPassword(credentials.getPublisherPassword()); factory.setHost(credentials.getPublisherHost()); factory.setPort(credentials.getPublisherPort()); factory.setVirtualHost(credentials.getPublisherVirtualHost()); factory.setAutomaticRecoveryEnabled(true); // establish connection connection = factory.newConnection(); dispatchChannel = connection.createChannel(); broadcastChannel = connection.createChannel(); // declare exchange to be used (we want it to be durable and based on routing key) dispatchChannel.exchangeDeclare(dispatchExchange, "direct", true); broadcastChannel.exchangeDeclare(broadcastExchange, "fanout", true); logger.trace(String.format("RabbitMQ Publisher connected to %s:%d", credentials.getPublisherHost(), credentials.getPublisherPort())); logger.trace(String.format("RabbitMQ Publisher will dispatch to \"%s\" and broadcast to \"%s\" exchanges", dispatchExchange, broadcastExchange)); } catch (Exception e) { logger.error(String.format("RabbitMQ Publisher couldn't be created: %s", e.getMessage())); // remove hanging connections stop(); } }
public RabbitMQPublisher() { PublisherCredentials credentials = Loader.getSettings().getPublisherCredentials(); dispatchExchange = credentials.getPublisherDispatchExchange(); broadcastExchange = credentials.getPublisherBroadcastExchange(); establishConnection(credentials); }
/** * 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; }
/** * Establish connection based on provided credentials */ public void establishConnection(PublisherCredentials credentials) { try { // setup factory ConnectionFactory factory = new ConnectionFactory(); factory.setUsername(credentials.getPublisherUsername()); factory.setPassword(credentials.getPublisherPassword()); factory.setHost(credentials.getPublisherHost()); factory.setPort(credentials.getPublisherPort()); factory.setVirtualHost(credentials.getPublisherVirtualHost()); factory.setAutomaticRecoveryEnabled(true); // establish connection connection = factory.newConnection(); dispatchChannel = connection.createChannel(); broadcastChannel = connection.createChannel(); // declare exchange to be used (we want it to be durable and based on routing key) dispatchChannel.exchangeDeclare(dispatchExchange, "direct", true); broadcastChannel.exchangeDeclare(broadcastExchange, "fanout", true); logger.trace(String.format("RabbitMQ Publisher connected to %s:%d", credentials.getPublisherHost(), credentials.getPublisherPort())); logger.trace(String.format("RabbitMQ Publisher will dispatch to \"%s\" and broadcast to \"%s\" exchanges", dispatchExchange, broadcastExchange)); } catch (Exception e) { logger.error(String.format("RabbitMQ Publisher couldn't be created: %s", e.getMessage())); // remove hanging connections stop(); } }
public RabbitMQPublisher() { PublisherCredentials credentials = Loader.getSettings().getPublisherCredentials(); dispatchExchange = credentials.getPublisherDispatchExchange(); broadcastExchange = credentials.getPublisherBroadcastExchange(); establishConnection(credentials); }
/** * 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; }
/** * Establish connection based on provided credentials */ public void establishConnection(PublisherCredentials credentials) { try { // setup factory ConnectionFactory factory = new ConnectionFactory(); factory.setUsername(credentials.getPublisherUsername()); factory.setPassword(credentials.getPublisherPassword()); factory.setHost(credentials.getPublisherHost()); factory.setPort(credentials.getPublisherPort()); factory.setVirtualHost(credentials.getPublisherVirtualHost()); factory.setAutomaticRecoveryEnabled(true); // establish connection connection = factory.newConnection(); dispatchChannel = connection.createChannel(); broadcastChannel = connection.createChannel(); // declare exchange to be used (we want it to be durable and based on routing key) dispatchChannel.exchangeDeclare(dispatchExchange, "direct", true); broadcastChannel.exchangeDeclare(broadcastExchange, "fanout", true); logger.trace(String.format("RabbitMQ Publisher connected to %s:%d", credentials.getPublisherHost(), credentials.getPublisherPort())); logger.trace(String.format("RabbitMQ Publisher will dispatch to \"%s\" and broadcast to \"%s\" exchanges", dispatchExchange, broadcastExchange)); } catch (Exception e) { logger.error(String.format("RabbitMQ Publisher couldn't be created: %s", e.getMessage())); // remove hanging connections stop(); } }
public RabbitMQPublisher() { PublisherCredentials credentials = Loader.getSettings().getPublisherCredentials(); dispatchExchange = credentials.getPublisherDispatchExchange(); broadcastExchange = credentials.getPublisherBroadcastExchange(); establishConnection(credentials); }
/** * 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; }