Package org.switchyard.component.test.mixins.hornetq

Examples of org.switchyard.component.test.mixins.hornetq.HornetQMixIn


        }
        System.out.println("Message sent: provider=" + provider + ", queueName=" + queueName + ", payload=" + payload);
    }

    private static void sendToHornetQ(String payload, String queueName) throws Exception {
        HornetQMixIn hqMixIn = new HornetQMixIn(false)
            .setUser(HQ_USER)
            .setPassword(HQ_PASSWD);
        hqMixIn.initialize();

        try {
            Session session = hqMixIn.getJMSSession();
            MessageProducer producer = session.createProducer(HornetQMixIn.getJMSQueue(queueName));
            producer.send(hqMixIn.createJMSMessage(payload));
            session.close();
            verifyOutputQueue(hqMixIn.createJMSSession());
        } finally {
            hqMixIn.uninitialize();
        }
    }
View Full Code Here


            sendToHornetQ();
        }
    }

    private static void sendToHornetQ() throws Exception {
        HornetQMixIn hqMixIn = new HornetQMixIn(false)
                                    .setUser(HQ_USER)
                                    .setPassword(HQ_PASSWD);
        hqMixIn.initialize();
        Session session = null;
        try {
            session = hqMixIn.createJMSSession();
            final MessageProducer producer = session.createProducer(HornetQMixIn.getJMSQueue(QUEUE_NAME));
            Message message = hqMixIn.createJMSMessageFromResource(MESSAGE_PAYLOAD);
            producer.send(message);
            System.out.println("Message sent. Please see server console output");
        } finally {
            hqMixIn.uninitialize();
        }
    }
View Full Code Here

            sendToHornetQ(args[0]);
        }
    }
   
    private static void sendToHornetQ(String value) throws Exception {
        HornetQMixIn hqMixIn = new HornetQMixIn(false)
            .setUser(USER)
            .setPassword(PASSWD);
        hqMixIn.initialize();

        try {
            Session session = hqMixIn.getJMSSession();
            final MessageProducer producer = session.createProducer(HornetQMixIn.getJMSQueue(REQUEST_NAME));
            final MessageConsumer consumer = session.createConsumer(HornetQMixIn.getJMSQueue(REPLY_NAME));

            producer.send(hqMixIn.createJMSMessage(createPayload(value)));
            System.out.println("Message sent. Waiting for reply ...");

            Message message = consumer.receive(3000);
            String reply = hqMixIn.readStringFromJMSMessage(message);
            System.out.println("REPLY: \n" + reply);
        } finally {
            hqMixIn.uninitialize();
        }
    }
View Full Code Here

     * Only execution point for this application.
     * @param ignored not used.
     * @throws Exception if something goes wrong.
     */
    public static void main(final String[] args) throws Exception {
        HornetQMixIn hqMixIn = new HornetQMixIn(false)
            .setUser(USER)
            .setPassword(PASSWD);
        if (args.length == 0) {
            System.err.println("ERROR: Use -Dexec.args to pass a name and language value, e.g. -Dexec.args=\"Skippy english\"");
            return;
        }

        hqMixIn.initialize();

        try {
            final Session session = hqMixIn.createJMSSession();
            final MessageProducer producer = session.createProducer(HornetQMixIn.getJMSQueue(QUEUE));
            final TextMessage message = session.createTextMessage();
            String payload = TEMPLATE.replace("@name@", args[0]);
            if (args.length == 2) {
                payload = payload.replace("@lang@", args[1]);
            } else {
                payload = payload.replace("@lang@", "english");
            }
            System.out.println(payload);
            message.setText(payload);
            producer.send(message);

            System.out.println("Sent message [" + message + "]");
            Thread.sleep(2000);
        } finally {
            hqMixIn.uninitialize();
        }
    }
View Full Code Here

     * Main routing for OrderIntakeClient
     * @param args command-line args
     * @throws Exception if something goes wrong.
     */
    public static void main(final String[] args) throws Exception {
        HornetQMixIn hqMixIn = new HornetQMixIn(false)
            .setUser(USER)
            .setPassword(PASSWD);
        hqMixIn.initialize();

        try {
            Session session = hqMixIn.getJMSSession();
            MessageProducer producer = session.createProducer(HornetQMixIn.getJMSQueue(ORDER_QUEUE_NAME));

            String orderTxt = readFileContent(args[0]);
            System.out.println("Submitting Order" + "\n"
                + "----------------------------\n"
                + orderTxt
                + "\n----------------------------");
            producer.send(hqMixIn.createJMSMessage(orderTxt));
            MessageConsumer consumer = session.createConsumer(HornetQMixIn.getJMSQueue(ORDERACK_QUEUE_NAME));
            System.out.println("Order submitted ... waiting for reply.");
            TextMessage reply = (TextMessage)consumer.receive(3000);
            if (reply == null) {
                System.out.println("No reply received.");
            } else {
                String str = reply.getText();
                System.out.println("Received reply" + "\n"
                    + "----------------------------\n"
                    + str
                    + "\n----------------------------");
            }
        } finally {
            hqMixIn.uninitialize();
        }
    }
View Full Code Here

     * Main routing for OrderIntakeClient
     * @param args command-line args
     * @throws Exception if something goes wrong.
     */
    public static void main(final String[] args) throws Exception {
        HornetQMixIn hqMixIn = new HornetQMixIn(false)
            .setUser(USER)
            .setPassword(PASSWD);
        hqMixIn.initialize();

        try {
            Session session = hqMixIn.getJMSSession();
            MessageProducer producer = session.createProducer(HornetQMixIn.getJMSQueue(ORDER_QUEUE_NAME));

            String orderTxt = readFileContent(args[0]);
            System.out.println("Submitting Order" + "\n"
                + "----------------------------\n"
                + orderTxt
                + "\n----------------------------");
            producer.send(hqMixIn.createJMSMessage(orderTxt));
            MessageConsumer consumer = session.createConsumer(HornetQMixIn.getJMSQueue(ORDERACK_QUEUE_NAME));
            System.out.println("Order submitted ... waiting for reply.");
            TextMessage reply = (TextMessage) consumer.receive(3000);
            if (reply == null) {
                System.out.println("No reply received.");
            } else {
                System.out.println("Received reply" + "\n"
                    + "----------------------------\n"
                    + reply.getText()
                    + "\n----------------------------");
            }
        } finally {
            hqMixIn.uninitialize();
        }
    }
View Full Code Here

        String[] orders = { "BREAD", "PIZZA", "JAM", "POTATO", "MILK", "JAM" };
        if (args.length != 0) {
            orders = args;
        }

        HornetQMixIn hqMixIn = new HornetQMixIn(false)
            .setUser(USER)
            .setPassword(PASSWD);
        hqMixIn.initialize();

        try {
            Session session = hqMixIn.createJMSSession();
            MessageProducer producer = session.createProducer(HornetQMixIn.getJMSQueue(ORDER_QUEUE));
            for (String order : orders) {
                final TextMessage message = session.createTextMessage();
                message.setText(order);
                producer.send(message);
            }
            session.close();

            session = hqMixIn.createJMSSession();
            System.out.println("* * *  SHIPPING ORDERS  * * *");
            MessageConsumer consumer = session.createConsumer(HornetQMixIn.getJMSQueue(SHIPPING_QUEUE));
            Message msg = null;
            while ((msg = consumer.receive(1000)) != null) {
                System.out.println(" - " + hqMixIn.readStringFromJMSMessage(msg));
            }
            System.out.println();

            System.out.println("* * *  PENDING ORDERS (FILLING STOCK)  * * *");
            consumer = session.createConsumer(HornetQMixIn.getJMSQueue(FILLING_STOCK_QUEUE));
            while ((msg = consumer.receive(1000)) != null) {
                System.out.println(" - " + hqMixIn.readStringFromJMSMessage(msg));
            }
            session.close();
            Thread.sleep(2000);
        } finally {
            hqMixIn.uninitialize();
        }
    }
View Full Code Here

TOP

Related Classes of org.switchyard.component.test.mixins.hornetq.HornetQMixIn

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.