All Downloads are FREE. Search and download functionalities are using the official Maven repository.

generator.server.springboot.broker.pulsar.PulsarProperties.mustache Maven / Gradle / Ivy

There is a newer version: 1.22.0
Show newest version
package {{packageName}}.wire.pulsar.infrastructure.config;

import java.util.HashMap;
import java.util.Map;
import org.apache.pulsar.client.impl.conf.ClientConfigurationData;
import org.apache.pulsar.client.impl.conf.ConsumerConfigurationData;
import org.apache.pulsar.client.impl.conf.ProducerConfigurationData;
import org.apache.pulsar.shade.com.fasterxml.jackson.core.JsonProcessingException;
import org.apache.pulsar.shade.com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConfigurationProperties(prefix = "pulsar")
public class PulsarProperties {

  public static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
  private Map client = new HashMap<>();
  private Map consumer = new HashMap<>();
  private Map producer = new HashMap<>();

  public Map getClientProps() {
    return client;
  }

  public void setClient(ClientConfigurationData clientConfig) throws JsonProcessingException {
    String json = OBJECT_MAPPER.writeValueAsString(clientConfig);
    this.client = OBJECT_MAPPER.readerForMapOf(Object.class).readValue(json);
  }

  public Map getConsumerProps() {
    return consumer;
  }

  public void setConsumer(ConsumerConfigurationData consumerConfig) throws JsonProcessingException {
    String json = OBJECT_MAPPER.writeValueAsString(consumerConfig);
    this.consumer = OBJECT_MAPPER.readerForMapOf(Object.class).readValue(json);
  }

  public Map getProducerProps() {
    return producer;
  }

  public void setProducer(ProducerConfigurationData producerConfig) throws JsonProcessingException {
    String json = OBJECT_MAPPER.writeValueAsString(producerConfig);
    this.producer = OBJECT_MAPPER.readerForMapOf(Object.class).readValue(json);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy