Package com.taobao.metamorphosis.client.extension.spring

Examples of com.taobao.metamorphosis.client.extension.spring.MetaqTemplate


        this.createProducer();

        ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
        // use template to send messages.
        final String topic = "meta-test";
        MetaqTemplate template = (MetaqTemplate) context.getBean("metaqTemplate");
        int count = 100;
        for (int i = 0; i < count; i++) {
            SendResult result =
                    template.send(MessageBuilder.withTopic(topic).withBody(new Trade(i, "test", i, "test")));
            assertTrue(result.isSuccess());
        }
        TradeMessageListener listener = (TradeMessageListener) context.getBean("messageListener");
        while (listener.counter.get() != count) {
            Thread.sleep(100);
View Full Code Here


public class TradeSender {
    public static void main(final String[] args) throws Exception {
        ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
        // use template to send messages.
        final String topic = "test";
        MetaqTemplate template = (MetaqTemplate) context.getBean("metaqTemplate");

        final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String line = null;
        long tradeId = 0;
        int money = 1000;
        while ((line = readLine(reader)) != null) {
            // send message
            final SendResult sendResult =
                    template.send(MessageBuilder.withTopic(topic).withBody(new Trade(tradeId++, line, money++, line)));
            // check result
            if (!sendResult.isSuccess()) {
                System.err.println("Send message failed,error message:" + sendResult.getErrorMessage());
            }
            else {
View Full Code Here

TOP

Related Classes of com.taobao.metamorphosis.client.extension.spring.MetaqTemplate

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.