ActiveMQ etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
ActiveMQ etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

15 Ağustos 2021 Pazar

ActiveMQ Kullanımı

Giriş
Not : ActiveMQ API yazısına da bakabilirsiniz

ActiveMQ indirilip ve unzip edilir. Daha sonra bin dizininde şöyle yaparız
activeMQ start 
Login
Login için şu adrese gideriz. Kullanıcı adı ve şifre 'admin'
http://localhost:8161/admin/
Menülerde Queue ve Topic linklerini kullanarak kuyruklara bakılabilir.
Topics
Şeklen şöyle

Subscribers
Şeklen şöyle


Artemis
Artemis aslında eski HornetQ. Açıklaması şöyle
In spite of HornetQ's incredible speed, however, it failed to surpass its biggest competitor. Near the end of 2014, the codebase for HornetQ was donated to the Apache ActiveMQ community. Today, it exists as an Active MQ subproject called Artemis.



11 Ocak 2021 Pazartesi

ActiveMQ API

Maven
Eski kodlarda şu satırı dahil ederiz
<dependency>
  <groupId>org.apache.activemq</groupId>
  <artifactId>activemq-all</artifactId>
  <version>5.15.11</version>
</dependency>
Yeni kodlarda dependencyManagement alanında şöyle yaparız
<dependency>
  <groupId>org.apache.activemq</groupId>
  <artifactId>artemis-jakarta-server</artifactId>
  <version>2.28.0</version>
  <type>pom</type>
  <scope>test</scope>
</dependency>
Sonra şöyle yaparız
<dependency>
  <groupId>org.apache.activemq</groupId>
  <artifactId>artemis-jms-client</artifactId>
</dependency>

BrokerService Sınıfı
Şu satırı dahil ederiz
import org.apache.activemq.broker.BrokerService;
addConnector metodu
Embedded broker başlatmak için şöyle yaparız
@Bean
public BrokerService broker() throws Exception {
  BrokerService broker = new BrokerService();
  broker.addConnector("tcp://localhost:61616");
  return broker;
}
setBrokerName metodu
Şöyle yaparız
@Bean
public BrokerService broker() throws Exception {
  BrokerService ret = new BrokerService();
  ret.addConnector("tcp://0.0.0.0:4444"); // allow remote connections
  ret.setBrokerName("primary-broker");
  ret.setUseJmx(true);
  return ret;
}
setPersistanceAdapter metodu
Şöyle yaparız
@Bean(initMethod = "start", destroyMethod = "stop")
public BrokerService broker() throws Exception {
  final BrokerService broker = new BrokerService();
  //broker.addConnector("tcp://localhost:61616");
  broker.addConnector("vm://localhost");
  PersistenceAdapter persistenceAdapter = new KahaDBPersistenceAdapter();
  File dir = new File(System.getProperty("user.home") + File.separator + "kaha");
  if (!dir.exists()) {
    dir.mkdirs();
  }
  persistenceAdapter.setDirectory(dir);
  broker.setPersistenceAdapter(persistenceAdapter);
  broker.setPersistent(true);
  return broker;
}
setPersistent metodu
Embedded ve persistent broker başlatmak için şöyle yaparız
@Bean
public BrokerService broker() throws Exception {
  BrokerService broker = new BrokerService();
  broker.addConnector("tcp://0.0.0.0:61616");
  brokerService.setPersistent(false);
  return broker;
}
Veri şurada saklanır
// default messages store is under AMQ_HOME/data/KahaDB/
Veri tabanı için şu satırı dahil etmek gerekirr
<dependency>
  <groupId>org.apache.activemq</groupId>
  <artifactId>activemq-kahadb-store</artifactId>
</dependency>