Compare commits

...

3 Commits

Author SHA1 Message Date
424699b35f executable jar 2024-09-26 14:01:38 +02:00
0db033f5be lazy arguments 2024-09-26 13:55:30 +02:00
2212e2ada6 build java 11 and jar-with-dependencies 2024-09-26 13:16:48 +02:00
2 changed files with 58 additions and 13 deletions

31
pom.xml
View File

@ -9,10 +9,37 @@
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<archive>
<manifest>
<mainClass>de.berlin.airport.artemis.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.qpid/protonj2-client -->
<dependency>

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) {