List of usage examples for com.rabbitmq.client ConnectionFactory getClientProperties
public Map<String, Object> getClientProperties()
From source file:net.echinopsii.ariane.community.messaging.rabbitmq.Client.java
License:Open Source License
/** * Initialize RabbitMQ connection with provided properties and this client ServiceFactory. * <br/>//from ww w.j av a 2 s . com * Following properties fields MUST be defined : * {@link net.echinopsii.ariane.community.messaging.api.MomClient#MOM_HOST} * {@link net.echinopsii.ariane.community.messaging.api.MomClient#MOM_PORT} * {@link net.echinopsii.ariane.community.messaging.api.MomClient#RBQ_VHOST} * <br/> * Following properties fields MAY be defined: * {@link net.echinopsii.ariane.community.messaging.api.MomClient#MOM_USER} * {@link net.echinopsii.ariane.community.messaging.api.MomClient#MOM_PSWD} * {@link net.echinopsii.ariane.community.messaging.api.MomClient#MOM_CLI_MSG_DEBUG_ON_TIMEOUT} * {@link net.echinopsii.ariane.community.messaging.api.MomClient#MOM_CLI_ROUTEES_NB_PER_SERVICE} * {@link net.echinopsii.ariane.community.messaging.api.MomClient#MOM_CLI_RPC_TIMEOUT} * {@link net.echinopsii.ariane.community.messaging.api.MomClient#MOM_CLI_RPC_RETRY} * {@link net.echinopsii.ariane.community.messaging.api.MomClient#RBQ_INFORMATION_KEY} * {@link net.echinopsii.ariane.community.messaging.api.MomClient#RBQ_PRODUCT_KEY} * {@link net.echinopsii.ariane.community.messaging.api.MomClient#RBQ_PLATFORM_KEY} * {@link net.echinopsii.ariane.community.messaging.api.MomClient#RBQ_COPYRIGHT_KEY} * {@link net.echinopsii.ariane.community.messaging.api.MomClient#RBQ_VERSION_KEY} * {@link net.echinopsii.ariane.community.messaging.api.MomClient#ARIANE_APP_KEY} * {@link net.echinopsii.ariane.community.messaging.api.MomClient#ARIANE_CMP_KEY} * {@link net.echinopsii.ariane.community.messaging.api.MomClient#ARIANE_OSI_KEY} * {@link net.echinopsii.ariane.community.messaging.api.MomClient#ARIANE_OTM_KEY} * {@link net.echinopsii.ariane.community.messaging.api.MomClient#ARIANE_PGURL_KEY} * {@link net.echinopsii.ariane.community.messaging.api.MomClient#ARIANE_PID_KEY} * @param properties configuration properties * @throws IOException if problems to join NATS server */ @Override public void init(Dictionary properties) throws IOException { if (properties.get(MomClient.RBQ_INFORMATION_KEY) != null) super.setClientID((String) properties.get(MomClient.RBQ_INFORMATION_KEY)); if (properties.get(MOM_CLI_MSG_DEBUG_ON_TIMEOUT) != null && (((String) properties.get(MOM_CLI_MSG_DEBUG_ON_TIMEOUT)).toLowerCase().equals("true"))) super.setMsgDebugOnTimeout(true); if (properties.get(MOM_CLI_ROUTEES_NB_PER_SERVICE) != null) super.setRouteesCountPerService(new Integer((String) properties.get(MOM_CLI_ROUTEES_NB_PER_SERVICE))); try { if (Class.forName("akka.osgi.ActorSystemActivator") != null && MessagingAkkaSystemActivator.getSystem() != null) super.setActorSystem(MessagingAkkaSystemActivator.getSystem()); else super.setActorSystem(ActorSystem.create("MySystem")); } catch (ClassNotFoundException e) { super.setActorSystem(ActorSystem.create("MySystem")); } ConnectionFactory factory = new ConnectionFactory(); factory.setHost((String) properties.get(MOM_HOST)); factory.setPort(new Integer((String) properties.get(MOM_PORT))); if (properties.get(RBQ_VHOST) != null) factory.setVirtualHost((String) properties.get(RBQ_VHOST)); if (properties.get(MOM_USER) != null) factory.setUsername((String) properties.get(MOM_USER)); if (properties.get(MOM_PSWD) != null) factory.setPassword((String) properties.get(MOM_PSWD)); Map<String, Object> factoryProperties = factory.getClientProperties(); if (properties.get(MomClient.RBQ_PRODUCT_KEY) != null) factoryProperties.put(RBQ_PRODUCT_KEY, properties.get(MomClient.RBQ_PRODUCT_KEY)); if (properties.get(MomClient.RBQ_INFORMATION_KEY) != null) factoryProperties.put(RBQ_INFORMATION_KEY, super.getClientID()); if (properties.get(MomClient.RBQ_PLATFORM_KEY) != null) factoryProperties.put(RBQ_PLATFORM_KEY, properties.get(MomClient.RBQ_PLATFORM_KEY)); else factoryProperties.put(RBQ_PLATFORM_KEY, "Java " + System.getProperty("java.version")); if (properties.get(MomClient.RBQ_COPYRIGHT_KEY) != null) factoryProperties.put(RBQ_COPYRIGHT_KEY, properties.get(MomClient.RBQ_COPYRIGHT_KEY)); if (properties.get(MomClient.RBQ_VERSION_KEY) != null) factoryProperties.put(RBQ_VERSION_KEY, properties.get(MomClient.RBQ_VERSION_KEY)); Enumeration keys = properties.keys(); while (keys.hasMoreElements()) { Object key = keys.nextElement(); if (key instanceof String && ((String) key).startsWith(MomClient.ARIANE_KEYS)) factoryProperties.put((String) key, properties.get((String) key)); } connection = factory.newConnection(); super.setServiceFactory(new ServiceFactory(this)); }
From source file:org.springframework.amqp.rabbit.connection.SSLConnectionTests.java
License:Apache License
@Test @Ignore//from w w w . ja v a 2s . c om public void test() throws Exception { RabbitConnectionFactoryBean fb = new RabbitConnectionFactoryBean(); fb.setUseSSL(true); fb.setSslPropertiesLocation(new ClassPathResource("ssl.properties")); fb.setClientProperties(Collections.<String, Object>singletonMap("foo", "bar")); fb.afterPropertiesSet(); ConnectionFactory cf = fb.getObject(); assertEquals("bar", cf.getClientProperties().get("foo")); Connection conn = cf.newConnection(); Channel chan = conn.createChannel(); chan.close(); conn.close(); }
From source file:org.thingsboard.rule.engine.rabbitmq.TbRabbitMqNode.java
License:Apache License
@Override public void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException { this.config = TbNodeUtils.convert(configuration, TbRabbitMqNodeConfiguration.class); ConnectionFactory factory = new ConnectionFactory(); factory.setHost(this.config.getHost()); factory.setPort(this.config.getPort()); factory.setVirtualHost(this.config.getVirtualHost()); factory.setUsername(this.config.getUsername()); factory.setPassword(this.config.getPassword()); factory.setAutomaticRecoveryEnabled(this.config.isAutomaticRecoveryEnabled()); factory.setConnectionTimeout(this.config.getConnectionTimeout()); factory.setHandshakeTimeout(this.config.getHandshakeTimeout()); this.config.getClientProperties().forEach((k, v) -> factory.getClientProperties().put(k, v)); try {// ww w.ja v a 2 s . c o m this.connection = factory.newConnection(); this.channel = this.connection.createChannel(); } catch (Exception e) { throw new TbNodeException(e); } }