Search in sources :

Example 6 with Message

use of com.yanghui.elephant.common.message.Message in project elephant by yanghuijava.

the class Producer method main.

public static void main(String[] args) throws MQClientException {
    DefaultMQProducer producer = new DefaultMQProducer("test");
    producer.setRegisterCenter("120.77.152.143:2181");
    producer.start();
    /**
     * 目前只支持activemq:
     * 发送queue,message的destination值加上前缀:queue://
     * 发送topic,message的destination值加上前缀:topic://
     */
    try {
        for (int i = 0; i < 1; i++) {
            Message msg = new Message("queue://yanghui.queue.test1", ("我是消息" + i).getBytes());
            SendResult sendResult = producer.send(msg);
            System.out.println(sendResult);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    producer.shutdown();
}
Also used : Message(com.yanghui.elephant.common.message.Message) SendResult(com.yanghui.elephant.client.producer.SendResult) DefaultMQProducer(com.yanghui.elephant.client.producer.DefaultMQProducer) MQClientException(com.yanghui.elephant.client.exception.MQClientException)

Aggregations

Message (com.yanghui.elephant.common.message.Message)6 MessageEntity (com.yanghui.elephant.store.entity.MessageEntity)3 LocalTransactionExecuter (com.yanghui.elephant.client.producer.LocalTransactionExecuter)2 TransactionMQProducer (com.yanghui.elephant.client.producer.TransactionMQProducer)2 TransactionSendResult (com.yanghui.elephant.client.producer.TransactionSendResult)2 MQClientException (com.yanghui.elephant.client.exception.MQClientException)1 DefaultMQProducer (com.yanghui.elephant.client.producer.DefaultMQProducer)1 SendResult (com.yanghui.elephant.client.producer.SendResult)1 LocalTransactionState (com.yanghui.elephant.common.constant.LocalTransactionState)1 RemotingCommand (com.yanghui.elephant.remoting.procotol.RemotingCommand)1 Date (java.util.Date)1 Map (java.util.Map)1