Package com.aliyun.openservices.ons.api

Examples of com.aliyun.openservices.ons.api.SendResult


        Message msg = new Message(//
            "TopicTestONS", // Topic, 请向ONS运维人员申请
            "TagA", // Tag, 相当于子Topic概念,应用可以自由设置,Consumer消费时,可以通过他来过滤消息
            "Hello ONS".getBytes()// 消息内容,二进制形式
                );
        SendResult sendResult = producer.send(msg);
        System.out.println(sendResult);
        producer.shutdown();
       
       
View Full Code Here


        // 以方便您在无法正常收到消息情况下,可通过ONS Console查询消息并补发。
        // 注意:不设置也不会影响消息正常收发
        msg.setKey("ORDERID_100");

        // 发送消息,只要不抛异常就是成功
        SendResult sendResult = producer.send(msg);
        System.out.println(sendResult);

        // 在应用退出前,销毁Producer对象<br>
        // 注意:如果不销毁也没有问题
        producer.shutdown();
View Full Code Here

        properties.put(PropertyKeyConst.ProducerId, "ProducerId1");
        TransactionProducer producer =
                ONSFactory.createTransactionProducer(properties, new LocalTransactionCheckerImpl());
        producer.start();
        Message msg = new Message("TopicTestONS", "TagA", "Hello ONS".getBytes());
        SendResult sendResult = producer.send(msg, new LocalTransactionExecuter() {
            @Override
            public TransactionStatus execute(Message msg, Object arg) {
                return TransactionStatus.CommitTransaction;
            }
        }, null);
View Full Code Here

        Message msg = new Message(//
            "TopicTestONS", // Topic, 请向ONS运维人员申请
            "TagA", // Tag, 相当于子Topic概念,应用可以自由设置,Consumer消费时,可以通过他来过滤消息
            "Hello ONS".getBytes()// 消息内容,二进制形式
                );
        SendResult sendResult = producer.send(msg);
        System.out.println(sendResult);
        producer.shutdown();
    }
View Full Code Here

        Message msg = new Message(//
            "TopicTestONS", // Topic, 请向MetaQ运维人员申请
            "TagA", // Tag, 相当于子Topic概念,应用可以自由设置,Consumer消费时,可以通过他来过滤消息
            "Hello ONS".getBytes()// 消息内容,二进制形式
                );
        SendResult sendResult = producer.send(msg, new MessageQueueSelector() {

            @Override
            public int select(int queueTotal, Message msg, Object arg) {
                int value = Math.abs(arg.hashCode());
                if (value < 0) {
View Full Code Here

public class Producer {

    public static void main(String[] args) {
        ApplicationContext ctx = new ClassPathXmlApplicationContext("producer.xml");
        ProducerBean producer = (ProducerBean) ctx.getBean("producer");
        SendResult sendResult = producer.send(new Message("TopicTest", "tag", "Hello".getBytes()));
        System.out.println(sendResult);
    }
View Full Code Here

        try {
            com.alibaba.rocketmq.client.producer.SendResult sendResultRMQ =
                    this.defaultMQProducer.send(msgRMQ);

            SendResult sendResult = new SendResult();
            sendResult.setMessageId(sendResultRMQ.getMsgId());
            return sendResult;
        }
        catch (Exception e) {
            throw new ONSClientException("defaultMQProducer send exception", e);
        }
View Full Code Here

                                    com.alibaba.rocketmq.common.message.Message arg1, Object arg2) {
                                int select = selector.select(arg0.size(), message, arg);
                                return arg0.get(select);
                            }
                        }, arg);
            SendResult sendResult = new SendResult();
            sendResult.setMessageId(sendResultRMQ.getMsgId());
            return sendResult;
        }
        catch (Exception e) {
            throw new ONSClientException("defaultMQProducer send order exception", e);
        }
View Full Code Here

        try {
            com.alibaba.rocketmq.client.producer.SendResult sendResultRMQ =
                    this.defaultMQProducer.send(msgRMQ);

            SendResult sendResult = new SendResult();
            sendResult.setMessageId(sendResultRMQ.getMsgId());
            return sendResult;
        }
        catch (Exception e) {
            throw new ONSClientException("defaultMQProducer send exception", e);
        }
View Full Code Here

                                    com.alibaba.rocketmq.common.message.Message arg1, Object arg2) {
                                int select = selector.select(arg0.size(), message, arg);
                                return arg0.get(select);
                            }
                        }, arg);
            SendResult sendResult = new SendResult();
            sendResult.setMessageId(sendResultRMQ.getMsgId());
            return sendResult;
        }
        catch (Exception e) {
            throw new ONSClientException("defaultMQProducer send order exception", e);
        }
View Full Code Here

TOP

Related Classes of com.aliyun.openservices.ons.api.SendResult

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.