seperate connections

This commit is contained in:
damage 2024-09-26 09:21:01 +02:00
parent 7a2cbbf8ec
commit 17fae78801

View File

@ -46,14 +46,18 @@ public class Main {
jmxBroker.connect(JMX_HOST, JMX_PORT, USERNAME, PASSWORD); jmxBroker.connect(JMX_HOST, JMX_PORT, USERNAME, PASSWORD);
// JMXQueue jmxQueue = jmxBroker.getQueueJMX(QUEUE); // JMXQueue jmxQueue = jmxBroker.getQueueJMX(QUEUE);
Client amqpCLient = Client.create();
ConnectionOptions ampqConnectionOptions = new ConnectionOptions(); ConnectionOptions ampqConnectionOptions = new ConnectionOptions();
ampqConnectionOptions.user(USERNAME); ampqConnectionOptions.user(USERNAME);
ampqConnectionOptions.password(PASSWORD); ampqConnectionOptions.password(PASSWORD);
Connection amqpConnection = amqpCLient.connect(AMQP_HOST, AMQP_PORT, ampqConnectionOptions); Client amqpClientSender = Client.create();
Receiver amqpReceiver = amqpConnection.openReceiver(QUEUE); Connection amqpConnectionSender = amqpClientSender.connect(AMQP_HOST, AMQP_PORT, ampqConnectionOptions);
Sender amqpSender = amqpConnection.openSender(QUEUE); Sender amqpSender = amqpConnectionSender.openSender(QUEUE);
Client amqpClientReceiver = Client.create();
Connection amqpConnectionReceiver = amqpClientReceiver.connect(AMQP_HOST, AMQP_PORT, ampqConnectionOptions);
Receiver amqpReceiver = amqpConnectionReceiver.openReceiver(QUEUE);
amqpSender.send(Message.create("Hello baz")); amqpSender.send(Message.create("Hello baz"));
Delivery amqpDelivery = amqpReceiver.receive(); Delivery amqpDelivery = amqpReceiver.receive();
System.out.println(amqpDelivery.message().body().toString()); System.out.println(amqpDelivery.message().body().toString());
@ -154,7 +158,8 @@ public class Main {
// System.in.read(); // System.in.read();
jmxBroker.disconnect(); jmxBroker.disconnect();
amqpConnection.close(); amqpConnectionSender.close();
amqpConnectionReceiver.close();
} }
public static void main(String[] args) { public static void main(String[] args) {