27 Temmuz 2023 Perşembe

ActiveMQ ActiveMQConnectionFactory Sınıfı

Giriş
Şu satırı dahil ederiz
import org.apache.activemq.ActiveMQConnectionFactory;
constructor - brokerUrl
Broker adresini parametre olarak alır

Örnek - tcp
Şöyle yaparız
@Bean
public ConnectionFactory connectionFactory() {
  return new ActiveMQConnectionFactory("tcp://localhost:4444");
}
Örnek
Şöyle yaparız
ActiveMQConnectionFactory cf =
new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false")
Örnek
Şöyle yaparız. Yerel makinede çalıştırır.
import org.apache.activemq.ActiveMQConnectionFactory;
import static org.apache.activemq.ActiveMQConnection.DEFAULT_BROKER_URL;

ConnectionFactory connectionFactory = new ActiveMQConnectionFactory(DEFAULT_BROKER_URL);
constructor - user + password + brokerUrl
Örnek
Şöyle yaparız
@Configuration
@EnableJms
public class JmsConfig {

  @Value("${activemq.url}")
  private String brokerUrl;

  @Value("${activemq.user}")
  private String user;

  @Value("${activemq.password}")
  private String password;

  @Bean
  public ActiveMQConnectionFactory connectionFactory() {
    if ("".equals(user)) {
      return new ActiveMQConnectionFactory(brokerUrl);
    }
    return new ActiveMQConnectionFactory(user, password, brokerUrl);
  }
  ...
}
createConnection metodu

Hiç yorum yok:

Yorum Gönder

Bean Validation @GroupSequence Anotasyonu

Örnek Elimizde şöyle bir kod olsun public class SampleRequest {   @NotNull   LocalDate startDate;   @NotNull   LocalDate endDate;   @AssertT...