@ Override public void initWithDefaultProperties ( Properties properties ) throws ConnectorInitException { log . debug ( "Starting to initWithDefaultProperties RabbitMQ connector in php plugin..." ) ; ConnectionFactory factory = new ConnectionFactory ( ) ; factory . setHost ( properties . getProperty ( "connector.host" ) ) ; factory . setPort ( Integer . valueOf ( properties . getProperty ( "connector.port" ) ) ) ; factory . setUsername ( properties . getProperty ( "connector.username" ) ) ; factory . setPassword ( properties . getProperty ( "connector.password" ) ) ; try { connection = factory . newConnection ( ) ; channel = connection . createChannel ( ) ; channel . queueDeclare ( properties . getProperty ( "connector.queue-name" ) , false , false , false , null ) ; channel . basicConsume ( properties . getProperty ( "connector.queue-name" ) , true , new MoskitoPHPConsumer ( channel ) ) ; enabledInTimestamp = System . currentTimeMillis ( ) ; } catch ( IOException | TimeoutException e ) { deinit ( ) ; throw new ConnectorInitException ( "Failed to open connection to RabbitMQ" , e ) ; } }
Opens connection and channel to listen configured queue for incoming data