fix rocketmq example errors.

pull/2505/head
sorie 3 years ago
parent 8a55030dd6
commit 1509138e86

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package com.alibaba.cloud.examples.broadcast; package com.alibaba.cloud.examples.delay;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -47,6 +47,10 @@ public class RocketMQDelayConsumeApplication {
SpringApplication.run(RocketMQDelayConsumeApplication.class, args); SpringApplication.run(RocketMQDelayConsumeApplication.class, args);
} }
/**
* Produce delay messages
* @return
*/
@Bean @Bean
public ApplicationRunner producerDelay() { public ApplicationRunner producerDelay() {
return args -> { return args -> {

@ -36,10 +36,17 @@ import org.springframework.stereotype.Component;
public class OrderlyMessageQueueSelector implements MessageQueueSelector { public class OrderlyMessageQueueSelector implements MessageQueueSelector {
private static final Logger log = LoggerFactory private static final Logger log = LoggerFactory
.getLogger(OrderlyMessageQueueSelector.class); .getLogger(OrderlyMessageQueueSelector.class);
/**
* to select a fixed queue by id
* @param mqs
* @param msg
* @param arg
* @return
*/
@Override @Override
public MessageQueue select(List<MessageQueue> mqs, Message msg, Object arg) { public MessageQueue select(List<MessageQueue> mqs, Message msg, Object arg) {
Integer id = (Integer) ((MessageHeaders) arg).get(MessageConst.PROPERTY_ORIGIN_MESSAGE_ID); Integer id = (Integer) ((MessageHeaders) arg).get(MessageConst.PROPERTY_ORIGIN_MESSAGE_ID);
String tag = (String) ((MessageHeaders) arg).get(MessageConst.PROPERTY_TAGS);
int index = id % RocketMQOrderlyConsumeApplication.tags.length % mqs.size(); int index = id % RocketMQOrderlyConsumeApplication.tags.length % mqs.size();
return mqs.get(index); return mqs.get(index);
} }

@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package com.alibaba.cloud.examples.broadcast; package com.alibaba.cloud.examples.sql;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

Loading…
Cancel
Save