amazon-mq-client/src/main/java/com/aws/sample/amazonmq/AmazonMqClient.java [106:150]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            if (interval > 0) {
                System.out.println(String.format("%s - Sender: sent '%s'", df.format(new Date()), message.getText()));
                try {
                    Thread.sleep(interval);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    private static void receiveMessages(Session session, MessageConsumer consumer) throws JMSException {
        consumer.setMessageListener(new MessageListener() {
            public void onMessage(Message message) {
                try {
                    if (message instanceof TextMessage) {
                        TextMessage msg = (TextMessage) message;
                        System.out.println(String.format("%s - Receiver: received '%s'", df.format(new Date()), msg.getText()));
                    } else if (message instanceof BytesMessage) {
                        BytesMessage msg = (BytesMessage) message;
                        byte[] content = new byte[(int)msg.getBodyLength()];
                        msg.readBytes(content);
                        System.out.println(String.format("%s - Receiver: received '%s'", df.format(new Date()), new String(content)));
                    } else {
                        System.out.println(String.format("%s - Receiver: received '%s'", df.format(new Date()), message));
                    }
                    message.acknowledge();
                } catch (JMSException e) {
                    throw new RuntimeException(e);
                }
            }});
    }

    private static CommandLine parseAndValidateCommandLineArguments(String[] args) throws ParseException {
        Options options = new Options();
        options.addOption("help", false, "Print the help message.");
        options.addOption("url", true, "The broker connection url.");
        options.addOption("user", true, "The user to connect to the broker.");
        options.addOption("password", true, "The password for the user.");
        options.addOption("mode", true, "Whether to act as 'sender' or 'receiver'");
        options.addOption("type", true, "Whether to use a queue or a topic.");
        options.addOption("destination", true, "The name of the queue or topic");
        options.addOption("name", true, "The name of the sender");
        options.addOption("interval", true, "The interval in msec at which messages are generated. Default 1000");
        options.addOption("notPersistent", false, "Send messages in non-persistent mode");
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



amqp-client/src/main/java/com/aws/sample/amazonmq/AMQPClient.java [104:148]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
            if (interval > 0) {
                System.out.println(String.format("%s - Sender: sent '%s'", df.format(new Date()), message.getText()));
                try {
                    Thread.sleep(interval);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    private static void receiveMessages(Session session, MessageConsumer consumer) throws JMSException {
        consumer.setMessageListener(new MessageListener() {
            public void onMessage(Message message) {
                try {
                    if (message instanceof TextMessage) {
                        TextMessage msg = (TextMessage) message;
                        System.out.println(String.format("%s - Receiver: received '%s'", df.format(new Date()), msg.getText()));
                    } else if (message instanceof BytesMessage) {
                        BytesMessage msg = (BytesMessage) message;
                        byte[] content = new byte[(int)msg.getBodyLength()];
                        msg.readBytes(content);
                        System.out.println(String.format("%s - Receiver: received '%s'", df.format(new Date()), new String(content)));
                    } else {
                        System.out.println(String.format("%s - Receiver: received '%s'", df.format(new Date()), message));
                    }
                    message.acknowledge();
                } catch (JMSException e) {
                    throw new RuntimeException(e);
                }
            }});
    }

    private static CommandLine parseAndValidateCommandLineArguments(String[] args) throws ParseException {
        Options options = new Options();
        options.addOption("help", false, "Print the help message.");
        options.addOption("url", true, "The broker connection url.");
        options.addOption("user", true, "The user to connect to the broker.");
        options.addOption("password", true, "The password for the user.");
        options.addOption("mode", true, "Whether to act as 'sender' or 'receiver'");
        options.addOption("type", true, "Whether to use a queue or a topic.");
        options.addOption("destination", true, "The name of the queue or topic");
        options.addOption("name", true, "The name of the sender");
        options.addOption("interval", true, "The interval in msec at which messages are generated. Default 1000");
        options.addOption("notPersistent", false, "Send messages in non-persistent mode");
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



