Category : mq

First, the role of message middleware Message-Oriented Middleware (MOM).The use of message middleware generally has two functions: one is decoupling and the other is asynchronous (it plays the role of cutting peaks and filling valleys) Second, the basic specification of JMS 1. Message Delivery Model Point-to-point model (queue-based model, if there are multiple consumers, then ..

Read more

Order This article focuses on OpenMessaging. Architecture diagram Namespace, similar to cgroup’s namespace, is used for security isolation. Each namespace has its own producer, consumer, topic, queue, etc. Producer, there are two types of message producers, one is Producer, and the other is BatchMessageSender. The former provides multiple sending methods to send messages to the ..

Read more

Order This article focuses on openmessaging-java. maven <dependency> <groupId>io.openmessaging</groupId> <artifactId>openmessaging-api</artifactId> <version>0.3.1-alpha</version> </dependency> Maven’s latest version is 0.3.1-alpha, and the source code of 0.3.2-alpha-SNAPSHOT is directly used here. producer Producer openmessaging-java/openmessaging-api/src/main/java/io/openmessaging/producer/Producer.java /** * A {@code Producer} is a simple object used to send messages on behalf * of a {@code MessagingAccessPoint}. An instance of {@code Producer} ..

Read more

Order This article mainly studies the MessagingAccessPoint of openmessaging. MessagingAccessPoint openmessaging-java/openmessaging-api/src/main/java/io/openmessaging/MessagingAccessPoint.java /** * An instance of {@code MessagingAccessPoint} may be obtained from {@link OMS}, which is capable of creating {@code * Producer}, {@code Consumer}, {@code ResourceManager}, and other facility entities. * <p> * For example: * <pre> * MessagingAccessPoint messagingAccessPoint = OMS.getMessagingAccessPoint(“oms:rocketmq://alice@rocketmq.apache.org/us-east:default_space”); * messagingAccessPoint.startup(); * ..

Read more

Order This article mainly shows an example of using open-messaging. consumer PullConsumer openmessaging-java/openmessaging-api-samples/src/main/java/io/openmessaging/samples/consumer/PullConsumerApp.java public class PullConsumerApp { public static void main(String[] args) throws OMSResourceNotExistException { //Load and start the vendor implementation from a specific OMS driver URL. final MessagingAccessPoint messagingAccessPoint = OMS.getMessagingAccessPoint(“oms:rocketmq://alice@rocketmq.apache.org/us-east”); messagingAccessPoint.startup(); //Fetch a ResourceManager to create Queue resource. ResourceManager resourceManager = messagingAccessPoint.resourceManager(); resourceManager.createQueue( ..

Read more

Order This article mainly studies AbstractOMSProducer. AbstractOMSProducer io/openmessaging/rocketmq/producer/AbstractOMSProducer.java abstract class AbstractOMSProducer implements ServiceLifecycle, MessageFactory { final static Logger log = ClientLogger.getLog(); final KeyValue properties; final DefaultMQProducer rocketmqProducer; private boolean started = false; final ClientConfig clientConfig; AbstractOMSProducer(final KeyValue properties) { this.properties = properties; this.rocketmqProducer = new DefaultMQProducer(); this.clientConfig = BeanUtils.populate(properties, ClientConfig.class); String accessPoints = clientConfig.getOmsAccessPoints(); if ..

Read more

Order This article mainly studies the ProducerImpl of rocketmq. ProducerImpl io/openmessaging/rocketmq/producer/ProducerImpl.java public class ProducerImpl extends AbstractOMSProducer implements Producer { public ProducerImpl(final KeyValue properties) { super(properties); } @Override public KeyValue properties() { return properties; } @Override public SendResult send(final Message message) { return send(message, this.rocketmqProducer.getSendMsgTimeout()); } @Override public SendResult send(final Message message, final KeyValue properties) { ..

Read more

Order This article mainly studies rocketmq’s SequenceProducerImpl SequenceProducerImpl io/openmessaging/rocketmq/producer/SequenceProducerImpl.java public class SequenceProducerImpl extends AbstractOMSProducer implements SequenceProducer { private BlockingQueue<Message> msgCacheQueue; public SequenceProducerImpl(final KeyValue properties) { super(properties); this.msgCacheQueue = new LinkedBlockingQueue<>(); } @Override public KeyValue properties() { return properties; } @Override public void send(final Message message) { checkMessageType(message); org.apache.rocketmq.common.message.Message rmqMessage = OMSUtil.msgConvert((BytesMessage) message); try { Validators.checkMessage(rmqMessage, ..

Read more

Order This article mainly studies PullConsumerImpl of rocketmq. PullConsumerImpl io/openmessaging/rocketmq/consumer/PullConsumerImpl.java public class PullConsumerImpl implements PullConsumer { private final DefaultMQPullConsumer rocketmqPullConsumer; private final KeyValue properties; private boolean started = false; private String targetQueueName; private final MQPullConsumerScheduleService pullConsumerScheduleService; private final LocalMessageCache localMessageCache; private final ClientConfig clientConfig; final static Logger log = ClientLogger.getLog(); public PullConsumerImpl(final String queueName, final ..

Read more

Order This article mainly studies rocketmq’s PushConsumerImpl PushConsumerImpl io/openmessaging/rocketmq/consumer/PushConsumerImpl.java public class PushConsumerImpl implements PushConsumer { private final DefaultMQPushConsumer rocketmqPushConsumer; private final KeyValue properties; private boolean started = false; private final Map<String, MessageListener> subscribeTable = new ConcurrentHashMap<>(); private final ClientConfig clientConfig; public PushConsumerImpl(final KeyValue properties) { this.rocketmqPushConsumer = new DefaultMQPushConsumer(); this.properties = properties; this.clientConfig = BeanUtils.populate(properties, ..

Read more

Order This article mainly studies the KVConfigManager of rocketmq. KVConfigManager org/apache/rocketmq/namesrv/kvconfig/KVConfigManager.java public class KVConfigManager { private static final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME); private final NamesrvController namesrvController; private final ReadWriteLock lock = new ReentrantReadWriteLock(); private final HashMap<String/* Namespace */, HashMap<String/* Key */, String/* Value */>> configTable = new HashMap<String, HashMap<String, String>>(); public KVConfigManager(NamesrvController namesrvController) { this.namesrvController ..

Read more

Order This article mainly studies rocketmq’s BrokerHousekeepingService. BrokerHousekeepingService org/apache/rocketmq/namesrv/routeinfo/BrokerHousekeepingService.java public class BrokerHousekeepingService implements ChannelEventListener { private static final Logger log = LoggerFactory.getLogger(LoggerName.NAMESRV_LOGGER_NAME); private final NamesrvController namesrvController; public BrokerHousekeepingService(NamesrvController namesrvController) { this.namesrvController = namesrvController; } @Override public void onChannelConnect(String remoteAddr, Channel channel) { } @Override public void onChannelClose(String remoteAddr, Channel channel) { this.namesrvController.getRouteInfoManager().onChannelDestroy(remoteAddr, channel); } @Override ..

Read more