Skip to content

Commit

Permalink
[ISSUE apache#4390] Realize the SPI extension loading of RabbitMQ adm…
Browse files Browse the repository at this point in the history
…in-api (apache#4395)

* config: rabbitmq spi without webhook, RESTORE BEFORE MERGE

* config: add extensionType in META-INF

* fix: resolve extension not found error when startup

* feat: add rabbitmq management config

* feat: provide limited admin func

* Revert "config: rabbitmq spi without webhook, RESTORE BEFORE MERGE"

This reverts commit a835cbf.

* doc: add PR link to README
  • Loading branch information
Pil0tXia authored Aug 26, 2023
1 parent ebd5b5e commit 707c98d
Show file tree
Hide file tree
Showing 6 changed files with 219 additions and 9 deletions.
26 changes: 26 additions & 0 deletions eventmesh-storage-plugin/eventmesh-storage-rabbitmq/src/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Dashboard

To enable eventmesh-dashboard admin UI for RabbitMQ, you need to add plugin rabbitmq_management.

```bash
rabbitmq-plugins enable rabbitmq_management
```

## RabbitMQ Management

The RabbitMQ management UI can be accessed using a Web browser at `http://{node-hostname}:15672/`.

Users must be [granted permissions](https://www.rabbitmq.com/management.html#permissions) for management UI access.

The following example creates a user with complete access to the management UI/HTTP API (as in, all virtual hosts and management features):

```bash
# create a user
rabbitmqctl add_user full_access s3crEt
# tag the user with "administrator" for full management UI and HTTP API access
rabbitmqctl set_user_tags full_access administrator
```

eventmesh-dashboard does not support authenticating with OAuth 2 currently. If you are using OAuth 2 to authenticate, you should keep `management.disable_basic_auth` configuration at default value `false` to support HTTP basic authentication.

> More information for developers to provide admin functions: https://github.com/apache/eventmesh/pull/4395
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* 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.storage.rabbitmq.admin;

import org.apache.eventmesh.api.admin.AbstractAdmin;
import org.apache.eventmesh.api.admin.TopicProperties;
import org.apache.eventmesh.storage.rabbitmq.config.ConfigurationHolder;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;

import io.cloudevents.CloudEvent;

public class RabbitMQAdmin extends AbstractAdmin {

private ConfigurationHolder configurationHolder;

private String mgmtHost;

private int mgmtPort;

private String mgmtProtocol;

public RabbitMQAdmin() {
super(new AtomicBoolean(false));
}

public void init() throws Exception {
this.mgmtHost = configurationHolder.getHost();
this.mgmtPort = configurationHolder.getMgmtPort();
this.mgmtProtocol = configurationHolder.getMgmtProtocol();
}

@Override
public List<TopicProperties> getTopic() {
// Utilizing the RabbitMQ Management HTTP API is a favorable approach to list queues and historical message counts.
// To display topics, it would be necessary to retrieve the topic name from each message and use it to declare a corresponding queue.
return new ArrayList<>();
}

@Override
public void createTopic(String topicName) {
}

@Override
public void deleteTopic(String topicName) {
}

@Override
public void publish(CloudEvent cloudEvent) throws Exception {
}

@Override
public void shutdown() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* 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.storage.rabbitmq.admin;

import org.apache.eventmesh.api.admin.Admin;
import org.apache.eventmesh.api.admin.TopicProperties;

import java.util.List;
import java.util.Properties;

import io.cloudevents.CloudEvent;

public class RabbitMQAdminAdaptor implements Admin {

private final RabbitMQAdmin admin;

public RabbitMQAdminAdaptor() {
admin = new RabbitMQAdmin();
}

@Override
public boolean isStarted() {
return admin.isStarted();
}

@Override
public boolean isClosed() {
return admin.isClosed();
}

@Override
public void start() {
admin.start();
}

@Override
public void shutdown() {
admin.shutdown();
}

@Override
public void init(Properties properties) throws Exception {
admin.init(properties);
}

@Override
public List<TopicProperties> getTopic() throws Exception {
return admin.getTopic();
}

@Override
public void createTopic(String topicName) {
admin.createTopic(topicName);
}

@Override
public void deleteTopic(String topicName) {
admin.deleteTopic(topicName);
}

@Override
public List<CloudEvent> getEvent(String topicName, int offset, int length) throws Exception {
return admin.getEvent(topicName, offset, length);
}

@Override
public void publish(CloudEvent cloudEvent) throws Exception {
admin.publish(cloudEvent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,10 @@ public class ConfigurationHolder {

@ConfigFiled(field = "autoAck")
private boolean autoAck;

@ConfigFiled(field = "mgmt.port")
private int mgmtPort;

@ConfigFiled(field = "mgmt.protocol")
private String mgmtProtocol;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 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.

rabbitmq=org.apache.eventmesh.storage.rabbitmq.admin.RabbitMQAdminAdaptor
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,21 @@
#

####################### rabbitmq server ##################
eventMesh.server.rabbitmq.host=
eventMesh.server.rabbitmq.port=
eventMesh.server.rabbitmq.username=
eventMesh.server.rabbitmq.passwd=
eventMesh.server.rabbitmq.virtualHost=
eventMesh.server.rabbitmq.host=127.0.0.1
eventMesh.server.rabbitmq.port=5672
eventMesh.server.rabbitmq.username=guest
eventMesh.server.rabbitmq.passwd=guest
eventMesh.server.rabbitmq.virtualHost=/

####################### rabbitmq queue setting ##################
# DIRECT, FANOUT, TOPIC, HEADERS
eventMesh.server.rabbitmq.exchangeType=TOPIC
eventMesh.server.rabbitmq.exchangeName=
eventMesh.server.rabbitmq.routingKey=
eventMesh.server.rabbitmq.queueName=
eventMesh.server.rabbitmq.autoAck=true
eventMesh.server.rabbitmq.exchangeName=eventmesh.default
eventMesh.server.rabbitmq.routingKey=#
eventMesh.server.rabbitmq.queueName=DefaultQueue
eventMesh.server.rabbitmq.autoAck=true

####################### rabbitmq management ##################
eventMesh.server.rabbitmq.mgmt.port=15672
# HTTP, HTTPS
eventMesh.server.rabbitmq.mgmt.protocol=HTTP

0 comments on commit 707c98d

Please sign in to comment.