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>
Hiç yorum yok:
Yorum Gönder