本文整理了Java中org.apache.rocketmq.common.message.Message.<init>()
方法的一些代码示例,展示了Message.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.<init>()
方法的具体详情如下:
包路径:org.apache.rocketmq.common.message.Message
类名称:Message
方法名:<init>
暂无
代码示例来源:origin: apache/rocketmq
public static void main(String[] args) throws Exception {
DefaultMQProducer producer = new DefaultMQProducer("BatchProducerGroupName");
producer.start();
//If you just send messages of no more than 1MiB at a time, it is easy to use batch
//Messages of the same batch should have: same topic, same waitStoreMsgOK and no schedule support
String topic = "BatchTest";
List<Message> messages = new ArrayList<>();
messages.add(new Message(topic, "Tag", "OrderID001", "Hello world 0".getBytes()));
messages.add(new Message(topic, "Tag", "OrderID002", "Hello world 1".getBytes()));
messages.add(new Message(topic, "Tag", "OrderID003", "Hello world 2".getBytes()));
producer.send(messages);
}
}
代码示例来源:origin: apache/rocketmq
private static Message buildMessage(final int messageSize, final String topic) throws UnsupportedEncodingException {
Message msg = new Message();
msg.setTopic(topic);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < messageSize; i += 10) {
sb.append("hello baby");
}
msg.setBody(sb.toString().getBytes(RemotingHelper.DEFAULT_CHARSET));
return msg;
}
}
代码示例来源:origin: apache/rocketmq
private static Message buildMessage(final String topic, final int messageSize) throws UnsupportedEncodingException {
Message msg = new Message();
msg.setTopic(topic);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < messageSize; i += 11) {
sb.append("hello jodie");
}
msg.setBody(sb.toString().getBytes(MixAll.DEFAULT_CHARSET));
return msg;
}
代码示例来源:origin: apache/rocketmq
public Object getMessageByTag(String tag) {
Object objMsg = null;
if (this instanceof RMQNormalProducer) {
org.apache.rocketmq.common.message.Message msg = new org.apache.rocketmq.common.message.Message(
topic, (RandomUtil.getStringByUUID() + "." + new Date()).getBytes());
objMsg = msg;
if (tag != null) {
msg.setTags(tag);
}
}
return objMsg;
}
代码示例来源:origin: apache/rocketmq
public void asyncSend(int msgSize, MessageQueueSelector selector) {
this.msgSize = msgSize;
for (int i = 0; i < msgSize; i++) {
Message msg = new Message(topic, RandomUtil.getStringByUUID().getBytes());
this.asyncSend(msg, selector, i);
}
}
代码示例来源:origin: apache/rocketmq
public void sendOneWay(int msgSize) {
for (int i = 0; i < msgSize; i++) {
Message msg = new Message(topic, RandomUtil.getStringByUUID().getBytes());
this.sendOneWay(msg);
}
}
代码示例来源:origin: apache/rocketmq
public void asyncSend(int msgSize) {
this.msgSize = msgSize;
for (int i = 0; i < msgSize; i++) {
Message msg = new Message(topic, RandomUtil.getStringByUUID().getBytes());
this.asyncSend(msg);
}
}
代码示例来源:origin: apache/rocketmq
public void sendOneWay(int msgSize, MessageQueue mq) {
for (int i = 0; i < msgSize; i++) {
Message msg = new Message(topic, RandomUtil.getStringByUUID().getBytes());
this.sendOneWay(msg, mq);
}
}
代码示例来源:origin: apache/rocketmq
public void asyncSend(int msgSize, MessageQueue mq) {
this.msgSize = msgSize;
for (int i = 0; i < msgSize; i++) {
Message msg = new Message(topic, RandomUtil.getStringByUUID().getBytes());
this.asyncSend(msg, mq);
}
}
代码示例来源:origin: apache/rocketmq
public void sendOneWay(int msgSize, MessageQueueSelector selector) {
for (int i = 0; i < msgSize; i++) {
Message msg = new Message(topic, RandomUtil.getStringByUUID().getBytes());
this.sendOneWay(msg, selector, i);
}
}
}
代码示例来源:origin: apache/rocketmq
/**
* Use this function while transaction msg is committed or rollback write a flag 'd' to operation queue for the
* msg's offset
*
* @param messageExt Op message
* @param messageQueue Op message queue
* @return This method will always return true.
*/
private boolean addRemoveTagInTransactionOp(MessageExt messageExt, MessageQueue messageQueue) {
Message message = new Message(TransactionalMessageUtil.buildOpTopic(), TransactionalMessageUtil.REMOVETAG,
String.valueOf(messageExt.getQueueOffset()).getBytes(TransactionalMessageUtil.charset));
writeOp(message, messageQueue);
return true;
}
代码示例来源:origin: apache/storm
private Message prepareMessage(Tuple input) {
String topic = selector.getTopic(input);
String tag = selector.getTag(input);
String key = mapper.getKeyFromTuple(input);
byte[] value = mapper.getValueFromTuple(input);
return new Message(topic, tag, key, value);
}
代码示例来源:origin: apache/rocketmq
public static Message cloneMessage(final Message msg) {
Message newMsg = new Message(msg.getTopic(), msg.getBody());
newMsg.setFlag(msg.getFlag());
newMsg.setProperties(msg.getProperties());
return newMsg;
}
代码示例来源:origin: apache/rocketmq
@Test(expected = java.lang.NullPointerException.class)
public void testSendMQNull() throws Exception {
Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes());
DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr);
MessageQueue messageQueue = null;
producer.sendOneway(msg, messageQueue);
}
代码示例来源:origin: apache/rocketmq
@Test(expected = org.apache.rocketmq.client.exception.MQClientException.class)
public void testSendSelectorNull() throws Exception {
Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes());
DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr);
MessageQueueSelector selector = null;
producer.sendOneway(msg, selector, 100);
}
代码示例来源:origin: apache/rocketmq
@Test
public void testSendCallBackNull() throws Exception {
Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes());
DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr);
SendCallback sendCallback = null;
producer.send(msg, sendCallback);
}
代码示例来源:origin: apache/rocketmq
@Test(expected = org.apache.rocketmq.client.exception.MQClientException.class)
public void testSelectorThrowsException() throws Exception {
Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes());
DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr);
producer.sendOneway(msg, new MessageQueueSelector() {
@Override
public MessageQueue select(List<MessageQueue> list, Message message, Object o) {
String str = null;
return list.get(str.length());
}
}, null);
}
}
代码示例来源:origin: apache/rocketmq
@Test
public void testSelectorThrowsException() throws Exception {
Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes());
DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr);
producer.send(msg, new MessageQueueSelector() {
@Override
public MessageQueue select(List<MessageQueue> list, Message message, Object o) {
String str = null;
return list.get(str.length());
}
}, null, SendCallBackFactory.getSendCallBack());
}
代码示例来源:origin: apache/rocketmq
@Test
public void testSendMQNull() throws Exception {
Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes());
DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr);
MessageQueue messageQueue = null;
producer.send(msg, messageQueue, SendCallBackFactory.getSendCallBack());
}
代码示例来源:origin: apache/rocketmq
@Test
public void testSendSelectorNull() throws Exception {
Message msg = new Message(topic, RandomUtils.getStringByUUID().getBytes());
DefaultMQProducer producer = ProducerFactory.getRMQProducer(nsAddr);
MessageQueueSelector selector = null;
producer.send(msg, selector, 100, SendCallBackFactory.getSendCallBack());
}
内容来源于网络,如有侵权,请联系作者删除!