You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@eventmesh.apache.org by mi...@apache.org on 2022/10/15 03:19:45 UTC
[incubator-eventmesh] branch protocol-amqp updated: define message router interface
This is an automated email from the ASF dual-hosted git repository.
mikexue pushed a commit to branch protocol-amqp
in repository https://gitbox.apache.org/repos/asf/incubator-eventmesh.git
The following commit(s) were added to refs/heads/protocol-amqp by this push:
new 65c295a7 define message router interface
new 9f42fb17 Merge pull request #1585 from wangshaojie4039/protocol-amqp
65c295a7 is described below
commit 65c295a70b12356a4e64b7ef646b05ba0fae2fba
Author: wangshaojie <wa...@cmss.chinamobile.com>
AuthorDate: Sat Oct 15 10:59:41 2022 +0800
define message router interface
---
.../runtime/core/protocol/amqp/QueueContainer.java | 2 +-
.../AmqpRouter.java} | 25 ++++----
.../RouteComponent.java} | 23 +++-----
.../RoutingResult.java} | 39 ++++++++-----
.../protocol/amqp/metadata/model/BindingInfo.java | 68 ++++++++++++++++++++++
5 files changed, 112 insertions(+), 45 deletions(-)
diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/QueueContainer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/QueueContainer.java
index c908ea84..0c841978 100644
--- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/QueueContainer.java
+++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/QueueContainer.java
@@ -17,7 +17,7 @@
package org.apache.eventmesh.runtime.core.protocol.amqp;
-import org.apache.eventmesh.runtime.core.protocol.amqp.remoting.MetaModels.AmqpQueue;
+import org.apache.eventmesh.runtime.core.protocol.amqp.remoting.metamodels.AmqpQueue;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/QueueContainer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/exchange/AmqpRouter.java
similarity index 60%
copy from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/QueueContainer.java
copy to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/exchange/AmqpRouter.java
index c908ea84..c74f70ca 100644
--- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/QueueContainer.java
+++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/exchange/AmqpRouter.java
@@ -15,25 +15,22 @@
* limitations under the License.
*/
-package org.apache.eventmesh.runtime.core.protocol.amqp;
-import org.apache.eventmesh.runtime.core.protocol.amqp.remoting.MetaModels.AmqpQueue;
+package org.apache.eventmesh.runtime.core.protocol.amqp.exchange;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
+import org.apache.eventmesh.runtime.core.protocol.amqp.metadata.model.BindingInfo;
-/**
- * manage all queues used in the server
- */
-public class QueueContainer {
- private ExchangeContainer exchangeContainer;
+import java.util.Map;
- private Map<VirtualHost, Map<String, AmqpQueue>> queueMap;
+public interface AmqpRouter {
- public QueueContainer(ExchangeContainer exchangeContainer) {
- this.exchangeContainer = exchangeContainer;
- this.queueMap = new ConcurrentHashMap<>();
+ enum Type {
+ Direct,
+ Fanout,
+ Topic,
+ Headers
}
+ boolean isMatch(BindingInfo bindingInfo, Map<String, Object> routingInfo);
-}
\ No newline at end of file
+}
diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/QueueContainer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/exchange/RouteComponent.java
similarity index 59%
copy from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/QueueContainer.java
copy to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/exchange/RouteComponent.java
index c908ea84..4aff9386 100644
--- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/QueueContainer.java
+++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/exchange/RouteComponent.java
@@ -15,25 +15,16 @@
* limitations under the License.
*/
-package org.apache.eventmesh.runtime.core.protocol.amqp;
+package org.apache.eventmesh.runtime.core.protocol.amqp.exchange;
-import org.apache.eventmesh.runtime.core.protocol.amqp.remoting.MetaModels.AmqpQueue;
+import org.apache.eventmesh.runtime.core.protocol.amqp.metadata.model.BindingInfo;
import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
+import java.util.Set;
-/**
- * manage all queues used in the server
- */
-public class QueueContainer {
- private ExchangeContainer exchangeContainer;
-
- private Map<VirtualHost, Map<String, AmqpQueue>> queueMap;
-
- public QueueContainer(ExchangeContainer exchangeContainer) {
- this.exchangeContainer = exchangeContainer;
- this.queueMap = new ConcurrentHashMap<>();
- }
+public interface RouteComponent {
+ RoutingResult routMessage(Set<BindingInfo> bindingInfos, AmqpRouter.Type type,
+ Map<String, Object> routingInfo);
-}
\ No newline at end of file
+}
diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/QueueContainer.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/exchange/RoutingResult.java
similarity index 57%
copy from eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/QueueContainer.java
copy to eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/exchange/RoutingResult.java
index c908ea84..3d0727ec 100644
--- a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/QueueContainer.java
+++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/exchange/RoutingResult.java
@@ -15,25 +15,36 @@
* limitations under the License.
*/
-package org.apache.eventmesh.runtime.core.protocol.amqp;
-import org.apache.eventmesh.runtime.core.protocol.amqp.remoting.MetaModels.AmqpQueue;
+package org.apache.eventmesh.runtime.core.protocol.amqp.exchange;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
+import java.util.HashSet;
+import java.util.Set;
-/**
- * manage all queues used in the server
- */
-public class QueueContainer {
- private ExchangeContainer exchangeContainer;
+public class RoutingResult {
+
+ Set<String> queues;
+
+ public RoutingResult(Set<String> queues) {
+ this.queues = queues;
+ }
- private Map<VirtualHost, Map<String, AmqpQueue>> queueMap;
+ public RoutingResult() {
+ }
+
+ public void addQueue(String queue) {
+ if (queues == null) {
+ queues = new HashSet<>();
+ }
+ queues.add(queue);
+ }
- public QueueContainer(ExchangeContainer exchangeContainer) {
- this.exchangeContainer = exchangeContainer;
- this.queueMap = new ConcurrentHashMap<>();
+ public Set<String> getQueues() {
+ return queues;
}
+ public boolean hasNoMatch() {
+ return queues == null || queues.isEmpty();
+ }
-}
\ No newline at end of file
+}
diff --git a/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/metadata/model/BindingInfo.java b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/metadata/model/BindingInfo.java
new file mode 100644
index 00000000..287f1ddf
--- /dev/null
+++ b/eventmesh-runtime/src/main/java/org/apache/eventmesh/runtime/core/protocol/amqp/metadata/model/BindingInfo.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+package org.apache.eventmesh.runtime.core.protocol.amqp.metadata.model;
+
+import java.util.Map;
+import java.util.Objects;
+
+public class BindingInfo {
+
+ private String destination;
+ private String bindingKey;
+ private Map<String, String> argument;
+
+ public BindingInfo() {
+ }
+
+ public BindingInfo(String destination, String bindingKey, Map<String, String> argument) {
+ this.destination = destination;
+ this.bindingKey = bindingKey;
+ this.argument = argument;
+ }
+
+ public String getDestination() {
+ return destination;
+ }
+
+ public String getBindingKey() {
+ return bindingKey;
+ }
+
+ public Map<String, String> getArgument() {
+ return argument;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ BindingInfo that = (BindingInfo) o;
+ return Objects.equals(destination, that.destination) &&
+ Objects.equals(bindingKey, that.bindingKey);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(destination, bindingKey);
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: commits-help@eventmesh.apache.org