Skip to content

Commit 47a71aa

Browse files
author
zengfr
committed
easymqtt4j 1.1
1 parent d6154eb commit 47a71aa

File tree

46 files changed

+712
-249
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+712
-249
lines changed

README.md

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,29 @@
11
# easymqtt4j
22
easymqtt4j , netty +mqtt +subscriber+ publisher +broker+cluster server for java
33

4-
54
Java使用easymqtt4j快速开发工业级mqtt企业级应用
65

76
easymqtt4j , netty +mqtt +subscriber+ publisher +broker+cluster server for java
8-
9-
easymqtt4j特点:
10-
11-
1、spring integration 集成模式,自由灵活。
12-
13-
2、完全支持mqtt 3.1、3.1.1国际标准协议,支持tcp\websocket等等,可配置。
14-
15-
3、客户端完全支持接入主流broker服务如:Eclipse Paho,Mosquitto,JBoss A-MQ 6.1, Apache ActiveMQ 5.10-SNAPSHOT,Apache Camel 2.13.0,HiveMQ,EMQ,mosquitto,moquette,JMQTT,mqttwk等等。
16-
17-
4、发布、订阅接口简单&统一Gateway。
18-
19-
5、完全支持event事件EventGateway,灵活自由控制。
20-
21-
6、支持handleEvent、connectionLost、 messageArrived、deliveryComplete。
22-
23-
7、支持preSend、postSend、afterSendCompletion。
24-
25-
8、支持preReceive、postReceive、afterReceiveCompletion。
26-
27-
使用方法&步骤:
28-
29-
1、引用jar
30-
31-
2、实现 MqttSubscriberGateway消息队列订阅 接口
32-
33-
3、实现 MqttEventGateway 事件 接口
34-
35-
4、MqttPublisherGateway消息发送 接口 ( 使用请参考 MqttScheduleTask 消息定时发送)
36-
37-
项目开源地址1: https://github.com/zengfr/easymqtt4j
38-
39-
项目开源地址2:https://gitee.com/zengfr/easymqtt4j
40-
41-
测试代码 : https://github.com/zengfr/easymqtt4j/tree/master/easymqtt4j-test/src/main/java/com/zengfr/easymqtt4j/test
42-
43-
详细见 :https://my.oschina.net/zengfr/blog/4281902
7+
### easymqtt4j特点:
8+
- 1、spring integration 集成模式,自由灵活
9+
- 2、完全支持mqtt 3.1、3.1.1国际标准协议,支持tcp\websocket等等,可配置。
10+
- 3、客户端完全支持接入主流broker服务如:Eclipse Paho,Mosquitto,JBoss A-MQ 6.1, Apache ActiveMQ 5.10-SNAPSHOT,Apache Camel 2.13.0,HiveMQ,EMQ,mosquitto,moquette,JMQTT,mqttwk等等。
11+
- 4、发布、订阅接口简单&统一Gateway。
12+
- 5、完全支持event事件EventGateway,灵活自由控制。
13+
- 6、支持handleEvent、connectionLost、 messageArrived、deliveryComplete。
14+
- 7、支持preSend、postSend、afterSendCompletion。
15+
- 8、支持preReceive、postReceive、afterReceiveCompletion。
16+
### easymqtt4j使用方法&步骤:
17+
- 1、引用jar
18+
- 2、实现 MqttSubscriberGateway消息队列订阅 接口
19+
- 3、实现 MqttEventGateway 事件 接口
20+
- 4、MqttPublisherGateway消息发送 接口 ( 使用请参考 MqttScheduleTask 消息定时发送)
21+
### open project home site
22+
- 项目开源地址1: https://github.com/zengfr/easymqtt4j
23+
- 项目开源地址2: https://gitee.com/zengfr/easymqtt4j
24+
### project test and demo
25+
- 测试代码 : https://github.com/zengfr/easymqtt4j/tree/master/easymqtt4j-test/src/main/java/com/zengfr/easymqtt4j/test
26+
27+
- 详细见 :https://my.oschina.net/zengfr/blog/4281902
28+
### other相关开源项目推荐
29+
- https://github.com/zengfr/easymodbus4j

easymqtt4j-activemq-plugins/pom.xml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<parent>
66
<artifactId>easymqtt4j</artifactId>
7-
<groupId>com.zengfr.easymqtt4j</groupId>
7+
<groupId>com.github.zengfr.easymqtt4j</groupId>
88
<version>1.0</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
@@ -14,14 +14,32 @@
1414
<groupId>org.apache.activemq</groupId>
1515
<artifactId>activemq-broker</artifactId>
1616
</dependency>
17+
<dependency>
18+
<groupId>org.apache.activemq</groupId>
19+
<artifactId>activemq-jaas</artifactId>
20+
</dependency>
21+
<dependency>
22+
<groupId>com.github.zengfr.easymqtt4j</groupId>
23+
<artifactId>easymqtt4j-jaas-plugins</artifactId>
24+
</dependency>
1725
</dependencies>
1826
<dependencyManagement>
1927
<dependencies>
28+
<dependency>
29+
<groupId>com.github.zengfr.easymqtt4j</groupId>
30+
<artifactId>easymqtt4j-jaas-plugins</artifactId>
31+
<version>${project.version}</version>
32+
</dependency>
2033
<dependency>
2134
<groupId>org.apache.activemq</groupId>
2235
<artifactId>activemq-broker</artifactId>
2336
<version>5.15.13</version>
2437
</dependency>
38+
<dependency>
39+
<groupId>org.apache.activemq</groupId>
40+
<artifactId>activemq-jaas</artifactId>
41+
<version>5.15.13</version>
42+
</dependency>
2543
</dependencies>
2644
</dependencyManagement>
2745

easymqtt4j-activemq-plugins/src/main/java/com/zengfr/easymqtt4j/plugins/ActiveMQBrokerFilter.java renamed to easymqtt4j-activemq-plugins/src/main/java/com/github/zengfr/easymqtt4j/plugins/activemq/ActiveMQBrokerFilter.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
package com.zengfr.easymqtt4j.plugins;
1+
package com.github.zengfr.easymqtt4j.plugins.activemq;
22
import org.apache.activemq.broker.Broker;
33
import org.apache.activemq.broker.BrokerFilter;
4-
import org.apache.activemq.broker.ProducerBrokerExchange;
5-
import org.apache.activemq.command.Message;
6-
import org.apache.activemq.plugin.StatisticsBrokerPlugin;
74

85
/**
96
* Created by zengfr on 2020/6/1.

easymqtt4j-activemq-plugins/src/main/java/com/zengfr/easymqtt4j/plugins/ActiveMQBrokerPlugin.java renamed to easymqtt4j-activemq-plugins/src/main/java/com/github/zengfr/easymqtt4j/plugins/activemq/ActiveMQBrokerPlugin.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
package com.zengfr.easymqtt4j.plugins;
1+
package com.github.zengfr.easymqtt4j.plugins.activemq;
22
import org.apache.activemq.broker.Broker;
33
import org.apache.activemq.broker.BrokerPlugin;
4-
import org.apache.activemq.plugin.StatisticsBrokerPlugin;
54

65
/**
76
* Created by zengfr on 2020/6/1.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.github.zengfr.easymqtt4j.plugins.activemq;
2+
3+
4+
import com.github.zengfr.easymqtt4j.plugins.jaas.JaasAbstractJdbcLoginModule;
5+
import org.apache.activemq.jaas.GroupPrincipal;
6+
import org.apache.activemq.jaas.UserPrincipal;
7+
8+
import javax.security.auth.Subject;
9+
import java.security.Principal;
10+
import java.util.Set;
11+
12+
/**
13+
* Created by zengfr on 2020/6/5.
14+
*/
15+
public class ActiveMQJdbcLoginModule extends JaasAbstractJdbcLoginModule {
16+
17+
18+
public ActiveMQJdbcLoginModule() {
19+
super();
20+
}
21+
22+
23+
@Override
24+
protected boolean commitPrincipals(Subject subject, Context context) {
25+
String userName = context.userName;
26+
Set<Principal> principals = subject.getPrincipals();
27+
UserPrincipal userPrincipal = new UserPrincipal(userName);
28+
principals.add(userPrincipal);
29+
30+
Set<String> groups = getUserGroups(userName);
31+
log.debug(String.format("groups:%s,%s", userName, groups));
32+
if (groups != null) {
33+
context.groups = groups;
34+
for (String entry : context.groups) {
35+
principals.add(new GroupPrincipal(entry));
36+
}
37+
}
38+
return true;
39+
}
40+
41+
42+
}

easymqtt4j-artemis-plugins/pom.xml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<parent>
66
<artifactId>easymqtt4j</artifactId>
7-
<groupId>com.zengfr.easymqtt4j</groupId>
7+
<groupId>com.github.zengfr.easymqtt4j</groupId>
88
<version>1.0</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
@@ -18,6 +18,15 @@
1818
<groupId>org.apache.activemq</groupId>
1919
<artifactId>artemis-server</artifactId>
2020
</dependency>
21+
<!--dependency>
22+
<groupId>org.hibernate</groupId>
23+
<artifactId>hibernate-core</artifactId>
24+
<version>5.4.4.Final</version>
25+
</dependency-->
26+
<dependency>
27+
<groupId>com.github.zengfr.easymqtt4j</groupId>
28+
<artifactId>easymqtt4j-jaas-plugins</artifactId>
29+
</dependency>
2130
</dependencies>
2231
<dependencyManagement>
2332
<dependencies>
@@ -26,7 +35,13 @@
2635
<artifactId>artemis-server</artifactId>
2736
<version>2.12.0</version>
2837
</dependency>
38+
<dependency>
39+
<groupId>com.github.zengfr.easymqtt4j</groupId>
40+
<artifactId>easymqtt4j-jaas-plugins</artifactId>
41+
<version>${project.version}</version>
42+
</dependency>
2943
</dependencies>
44+
3045
</dependencyManagement>
3146

3247

easymqtt4j-artemis-plugins/src/main/java/com/zengfr/easymqtt4j/plugins/ArtemisActiveMQServerPlugin.java renamed to easymqtt4j-artemis-plugins/src/main/java/com/github/zengfr/easymqtt4j/plugins/ArtemisActiveMQServerPlugin.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
package com.zengfr.easymqtt4j.plugins;
1+
package com.github.zengfr.easymqtt4j.plugins;
22

33
import org.apache.activemq.artemis.api.core.*;
44
import org.apache.activemq.artemis.api.core.management.ActiveMQServerControl;
5-
import org.apache.activemq.artemis.core.config.Configuration;
6-
import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
75
import org.apache.activemq.artemis.core.persistence.OperationContext;
86
import org.apache.activemq.artemis.core.postoffice.QueueBinding;
97
import org.apache.activemq.artemis.core.server.ServerSession;
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
// * Created by zengfr on 2020/5/15.
33
// */
44
//import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
5-
//import org.apache.activemq.artemis.spi.core.security.jaas.CertificateCallback;
6-
//import org.apache.activemq.artemis.spi.core.security.jaas.JaasCallbackHandler;
7-
//import org.apache.activemq.artemis.spi.core.security.jaas.RolePrincipal;
8-
//import org.apache.activemq.artemis.spi.core.security.jaas.UserPrincipal;
5+
//import org.apache.activemq.artemis.spi.core.security.com.github.zengfr.easymqtt4j.jaas.CertificateCallback;
6+
//import org.apache.activemq.artemis.spi.core.security.com.github.zengfr.easymqtt4j.jaas.JaasCallbackHandler;
7+
//import org.apache.activemq.artemis.spi.core.security.com.github.zengfr.easymqtt4j.jaas.RolePrincipal;
8+
//import org.apache.activemq.artemis.spi.core.security.com.github.zengfr.easymqtt4j.jaas.UserPrincipal;
99
//import org.apache.qpid.proton.Proton;
1010
//import org.apache.qpid.proton.amqp.Symbol;
1111
//import org.apache.qpid.proton.engine.Connection;
@@ -96,7 +96,7 @@
9696
//
9797
// static {
9898
// try {
99-
// Class<?> jassCallbackHandlerClass = Class.forName("org.apache.activemq.artemis.spi.core.security.jaas.JaasCallbackHandler");
99+
// Class<?> jassCallbackHandlerClass = Class.forName("org.apache.activemq.artemis.spi.core.security.com.github.zengfr.easymqtt4j.jaas.JaasCallbackHandler");
100100
// REMOTING_CONNECTION_FIELD = jassCallbackHandlerClass.getField("remotingConnection");
101101
// REMOTING_CONNECTION_FIELD.setAccessible(true);
102102
// } catch (ClassNotFoundException | NoSuchFieldException ignored) {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.zengfr.easymqtt4j.plugins; /**
1+
package com.github.zengfr.easymqtt4j.plugins; /**
22
* Created by zengfr on 2020/5/15.
33
*/
44
import java.util.Collections;

easymqtt4j-artemis-plugins/src/main/java/com/zengfr/easymqtt4j/plugins/ArtemisSecuritySettingPlugin.java renamed to easymqtt4j-artemis-plugins/src/main/java/com/github/zengfr/easymqtt4j/plugins/ArtemisSecuritySettingPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.zengfr.easymqtt4j.plugins;
1+
package com.github.zengfr.easymqtt4j.plugins;
22

33
import org.apache.activemq.artemis.core.security.Role;
44
import org.apache.activemq.artemis.core.server.SecuritySettingPlugin;

0 commit comments

Comments
 (0)