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