lazy arguments

This commit is contained in:
damage 2024-09-26 13:55:30 +02:00
parent 2212e2ada6
commit 0db033f5be

View File

@ -31,14 +31,14 @@ import de.berlin.airport.artemis.json.Sessions;
public class Main {
private static final String QUEUE = "foobar";
private static final String USERNAME = "artemis";
private static final String PASSWORD = "artemis";
private static final String AMQP_HOST = "localhost";
private static final String BROKER_NAME = "0.0.0.0";
private static final int AMQP_PORT = 5672;
private static final String JMX_HOST = "localhost";
private static final int JMX_PORT = 1099;
private static String QUEUE = "foobar";
private static String USERNAME = "artemis";
private static String PASSWORD = "artemis";
private static String AMQP_HOST = "localhost";
private static String BROKER_NAME = "0.0.0.0";
private static int AMQP_PORT = 5672;
private static String JMX_HOST = "localhost";
private static int JMX_PORT = 1099;
public void run() throws IOException, MalformedObjectNameException, InstanceNotFoundException, MBeanException,
ReflectionException, NamingException, ClientException {
@ -55,7 +55,8 @@ public class Main {
Sender amqpSender = amqpConnectionSender.openSender(QUEUE);
Client amqpClientReceiver = Client.create();
Connection amqpConnectionReceiver = amqpClientReceiver.connect(AMQP_HOST, AMQP_PORT, ampqConnectionOptions);
Connection amqpConnectionReceiver = amqpClientReceiver.connect(AMQP_HOST, AMQP_PORT,
ampqConnectionOptions);
Receiver amqpReceiver = amqpConnectionReceiver.openReceiver(QUEUE);
amqpSender.send(Message.create("Hello baz"));
@ -65,7 +66,8 @@ public class Main {
Connections connections = jmxBroker.getConnections();
Sessions sessions = jmxBroker.getSessions();
QueuePage queuePage = jmxBroker.getQueuesPaged(
"{\"field\":\"\",\"operation\":\"\",\"value\":\"\",\"sortOrder\":\"asc\",\"sortColumn\":\"name\"}", 1,
"{\"field\":\"\",\"operation\":\"\",\"value\":\"\",\"sortOrder\":\"asc\",\"sortColumn\":\"name\"}",
1,
200);
Producers producers = jmxBroker.getProducers();
HashMap<de.berlin.airport.artemis.json.Connection, Consumers> consumersPerConnection = new HashMap<>();
@ -106,7 +108,8 @@ public class Main {
System.out.println(
"|----------|----------------------------|--------------------------------------|-----------|----------|");
for (Queue queue : queuePage.getData()) {
System.out.println(String.format("| %8d | %-26s | %-36s | %9d | %8d |", queue.getId(), queue.getAddress(),
System.out.println(String.format("| %8d | %-26s | %-36s | %9d | %8d |", queue.getId(),
queue.getAddress(),
queue.getName(), queue.getConsumerCount(), queue.getMessageCount()));
}
System.out.println(
@ -164,6 +167,21 @@ public class Main {
public static void main(String[] args) {
try {
if (args.length == 8) {
int i = 0;
Main.AMQP_HOST = args[i++];
Main.AMQP_PORT = Integer.parseInt(args[i++]);
Main.JMX_HOST = args[i++];
Main.JMX_PORT = Integer.parseInt(args[i++]);
Main.USERNAME = args[i++];
Main.PASSWORD = args[i++];
Main.BROKER_NAME = args[i++];
Main.QUEUE = args[i++];
} else {
System.err.println("Usage: Main <amqp host> <amqp port> <jmx host> <jmx port> <username> <password> <broker name> <queue>");
System.exit(1);
}
Main main = new Main();
main.run();
} catch (Exception e) {