lazy arguments
This commit is contained in:
parent
2212e2ada6
commit
0db033f5be
@ -31,14 +31,14 @@ import de.berlin.airport.artemis.json.Sessions;
|
|||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
|
||||||
private static final String QUEUE = "foobar";
|
private static String QUEUE = "foobar";
|
||||||
private static final String USERNAME = "artemis";
|
private static String USERNAME = "artemis";
|
||||||
private static final String PASSWORD = "artemis";
|
private static String PASSWORD = "artemis";
|
||||||
private static final String AMQP_HOST = "localhost";
|
private static String AMQP_HOST = "localhost";
|
||||||
private static final String BROKER_NAME = "0.0.0.0";
|
private static String BROKER_NAME = "0.0.0.0";
|
||||||
private static final int AMQP_PORT = 5672;
|
private static int AMQP_PORT = 5672;
|
||||||
private static final String JMX_HOST = "localhost";
|
private static String JMX_HOST = "localhost";
|
||||||
private static final int JMX_PORT = 1099;
|
private static int JMX_PORT = 1099;
|
||||||
|
|
||||||
public void run() throws IOException, MalformedObjectNameException, InstanceNotFoundException, MBeanException,
|
public void run() throws IOException, MalformedObjectNameException, InstanceNotFoundException, MBeanException,
|
||||||
ReflectionException, NamingException, ClientException {
|
ReflectionException, NamingException, ClientException {
|
||||||
@ -55,7 +55,8 @@ public class Main {
|
|||||||
Sender amqpSender = amqpConnectionSender.openSender(QUEUE);
|
Sender amqpSender = amqpConnectionSender.openSender(QUEUE);
|
||||||
|
|
||||||
Client amqpClientReceiver = Client.create();
|
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);
|
Receiver amqpReceiver = amqpConnectionReceiver.openReceiver(QUEUE);
|
||||||
|
|
||||||
amqpSender.send(Message.create("Hello baz"));
|
amqpSender.send(Message.create("Hello baz"));
|
||||||
@ -65,7 +66,8 @@ public class Main {
|
|||||||
Connections connections = jmxBroker.getConnections();
|
Connections connections = jmxBroker.getConnections();
|
||||||
Sessions sessions = jmxBroker.getSessions();
|
Sessions sessions = jmxBroker.getSessions();
|
||||||
QueuePage queuePage = jmxBroker.getQueuesPaged(
|
QueuePage queuePage = jmxBroker.getQueuesPaged(
|
||||||
"{\"field\":\"\",\"operation\":\"\",\"value\":\"\",\"sortOrder\":\"asc\",\"sortColumn\":\"name\"}", 1,
|
"{\"field\":\"\",\"operation\":\"\",\"value\":\"\",\"sortOrder\":\"asc\",\"sortColumn\":\"name\"}",
|
||||||
|
1,
|
||||||
200);
|
200);
|
||||||
Producers producers = jmxBroker.getProducers();
|
Producers producers = jmxBroker.getProducers();
|
||||||
HashMap<de.berlin.airport.artemis.json.Connection, Consumers> consumersPerConnection = new HashMap<>();
|
HashMap<de.berlin.airport.artemis.json.Connection, Consumers> consumersPerConnection = new HashMap<>();
|
||||||
@ -106,7 +108,8 @@ public class Main {
|
|||||||
System.out.println(
|
System.out.println(
|
||||||
"|----------|----------------------------|--------------------------------------|-----------|----------|");
|
"|----------|----------------------------|--------------------------------------|-----------|----------|");
|
||||||
for (Queue queue : queuePage.getData()) {
|
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()));
|
queue.getName(), queue.getConsumerCount(), queue.getMessageCount()));
|
||||||
}
|
}
|
||||||
System.out.println(
|
System.out.println(
|
||||||
@ -164,6 +167,21 @@ public class Main {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
try {
|
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 main = new Main();
|
||||||
main.run();
|
main.run();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user