Ş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@EnableJmspublic class JmsConfig {@Value("${activemq.url}")private String brokerUrl;@Value("${activemq.user}")private String user;@Value("${activemq.password}")private String password;@Beanpublic ActiveMQConnectionFactory connectionFactory() {if ("".equals(user)) {return new ActiveMQConnectionFactory(brokerUrl);}return new ActiveMQConnectionFactory(user, password, brokerUrl);}...}
createConnection metodu
JMS ConnectionFactory Arayüzü döndürür.