use of com.alibaba.rocketmq.common.message.Message in project warn-report by saaavsaaa.
the class ProducerDouble method repeat.
public void repeat() {
int poolSize = 1;
int delay = repeatDelay;
int period = repeatPeriod;
ScheduledExecutorService executor = Executors.newScheduledThreadPool(poolSize);
Runnable runnable = new Runnable() {
public void run() {
if (!errorSendeds.isEmpty()) {
for (Message sended : errorSendeds) {
for (DefaultMQProducer one : producers) {
System.out.println(String.format("===repeat==============ip : %s, send NamesrvAddr : %s, send key: %s, topic :%s", one.getClientIP(), one.getNamesrvAddr(), sended.getKeys(), sended.getTopic()));
sendRepeat(one, sended);
}
}
}
}
};
executor.scheduleAtFixedRate(runnable, delay, period, TimeUnit.MILLISECONDS);
}
use of com.alibaba.rocketmq.common.message.Message in project warn-report by saaavsaaa.
the class ProducerSingle method repeat.
@Override
public void repeat() {
int poolSize = 1;
int delay = repeatDelay;
int period = repeatPeriod;
ScheduledExecutorService executor = Executors.newScheduledThreadPool(poolSize);
Runnable runnable = new Runnable() {
public void run() {
if (!errorSendeds.isEmpty()) {
for (Message one : errorSendeds) {
System.out.println(String.format("case : ProducerSingle repeat, ip : %s, send NamesrvAddr : %s, send key: %s, topic :%s", producer.getClientIP(), producer.getNamesrvAddr(), one.getKeys(), one.getTopic()));
try {
SendResult sendResult = producer.send(one);
if (sendResult != null && sendResult.getSendStatus() == SendStatus.SEND_OK) {
errorSendeds.remove(one);
System.out.println("error count : " + errorSendeds.size());
}
System.out.println("repeat count :" + repeatCount.incrementAndGet());
} catch (Exception e) {
System.out.println("reason : sendRepeat ProducerSingle send error" + e.getMessage());
System.out.println("repeat count :" + repeatCount.incrementAndGet());
}
}
}
}
};
executor.scheduleAtFixedRate(runnable, delay, period, TimeUnit.MILLISECONDS);
}
use of com.alibaba.rocketmq.common.message.Message in project incubator-skywalking by apache.
the class MessageSendInterceptor method beforeMethod.
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, MethodInterceptResult result) throws Throwable {
Message message = (Message) allArguments[2];
ContextCarrier contextCarrier = new ContextCarrier();
String namingServiceAddress = String.valueOf(objInst.getSkyWalkingDynamicField());
AbstractSpan span = ContextManager.createExitSpan(buildOperationName(message.getTopic()), contextCarrier, namingServiceAddress);
span.setComponent(ComponentsDefine.ROCKET_MQ);
Tags.MQ_BROKER.set(span, (String) allArguments[0]);
Tags.MQ_TOPIC.set(span, message.getTopic());
SpanLayer.asMQ(span);
SendMessageRequestHeader requestHeader = (SendMessageRequestHeader) allArguments[3];
StringBuilder properties = new StringBuilder(requestHeader.getProperties());
CarrierItem next = contextCarrier.items();
while (next.hasNext()) {
next = next.next();
if (!StringUtil.isEmpty(next.getHeadValue())) {
properties.append(next.getHeadKey());
properties.append(NAME_VALUE_SEPARATOR);
properties.append(next.getHeadValue());
properties.append(PROPERTY_SEPARATOR);
}
}
requestHeader.setProperties(properties.toString());
if (allArguments[6] != null) {
((EnhancedInstance) allArguments[6]).setSkyWalkingDynamicField(new SendCallBackEnhanceInfo(message.getTopic(), ContextManager.capture()));
}
}
use of com.alibaba.rocketmq.common.message.Message in project warn-report by saaavsaaa.
the class TestProcess method TestSend.
// sh mqadmin updateTopic -b 192.168.3.62 -n 192.168.3.62:9876 -t 'testTopic'
@Test
public void TestSend() throws MQClientException, InterruptedException, RemotingException, MQBrokerException {
final String address = "192.168.1.44:9876;192.168.1.45:9876";
final String producerGroup = "pg";
final String topic = "topicTest";
final String tag = "";
final String key = "aaa";
final String body = "it's body by aaa";
Producer producer = new Producer(address, producerGroup);
Message msg = Producer.buildMessage(topic, tag, key, body);
SendResult sendResult = producer.send(msg);
System.out.println(sendResult);
}
use of com.alibaba.rocketmq.common.message.Message in project warn-report by saaavsaaa.
the class TestRocketCluter method TestSend.
@Test
public void TestSend() throws MQClientException, InterruptedException, RemotingException, MQBrokerException {
final String producerGroup = "pg";
final String topic = "topicTest";
final String tag = "";
final String key = "aaa";
final String body = "it's body by qqq";
List<String> addresses = new ArrayList<String>();
addresses.add("192.168.1.44:9876");
addresses.add("192.168.1.45:9876");
ProducerCluter producer = new ProducerCluter(addresses, producerGroup);
Message msg = ProducerCluter.buildMessage(topic, tag, key, body);
boolean sendResult = producer.send(msg);
System.out.println(sendResult);
// Thread.sleep(1000*1000);
}
Aggregations