Skip to content

Commit d6154eb

Browse files
zengfrzengfr
authored andcommitted
Update README.md
1 parent 87a3caa commit d6154eb

File tree

17 files changed

+1115
-16
lines changed

17 files changed

+1115
-16
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,43 @@
11
# easymqtt4j
22
easymqtt4j , netty +mqtt +subscriber+ publisher +broker+cluster server for java
3+
4+
5+
Java使用easymqtt4j快速开发工业级mqtt企业级应用
6+
7+
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

easymqtt4j-activemq-plugins/pom.xml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,21 @@
88
<version>1.0</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
11-
1211
<artifactId>easymqtt4j-activemq-plugins</artifactId>
13-
12+
<dependencies>
13+
<dependency>
14+
<groupId>org.apache.activemq</groupId>
15+
<artifactId>activemq-broker</artifactId>
16+
</dependency>
17+
</dependencies>
18+
<dependencyManagement>
19+
<dependencies>
20+
<dependency>
21+
<groupId>org.apache.activemq</groupId>
22+
<artifactId>activemq-broker</artifactId>
23+
<version>5.15.13</version>
24+
</dependency>
25+
</dependencies>
26+
</dependencyManagement>
1427

1528
</project>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.zengfr.easymqtt4j.plugins;
2+
import org.apache.activemq.broker.Broker;
3+
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;
7+
8+
/**
9+
* Created by zengfr on 2020/6/1.
10+
*/
11+
public class ActiveMQBrokerFilter extends BrokerFilter {
12+
public ActiveMQBrokerFilter(Broker next) {
13+
super(next);
14+
}
15+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.zengfr.easymqtt4j.plugins;
2+
import org.apache.activemq.broker.Broker;
3+
import org.apache.activemq.broker.BrokerPlugin;
4+
import org.apache.activemq.plugin.StatisticsBrokerPlugin;
5+
6+
/**
7+
* Created by zengfr on 2020/6/1.
8+
*/
9+
public class ActiveMQBrokerPlugin implements BrokerPlugin {
10+
@Override
11+
public Broker installPlugin(Broker broker) throws Exception {
12+
return null;
13+
}
14+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
package com.zengfr.easymqtt4j.plugins;
2+
3+
import org.apache.activemq.artemis.api.core.*;
4+
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;
7+
import org.apache.activemq.artemis.core.persistence.OperationContext;
8+
import org.apache.activemq.artemis.core.postoffice.QueueBinding;
9+
import org.apache.activemq.artemis.core.server.ServerSession;
10+
import org.apache.activemq.artemis.core.server.plugin.ActiveMQServerPlugin;
11+
import org.apache.activemq.artemis.core.server.plugin.impl.LoggingActiveMQServerPluginLogger;
12+
import org.apache.activemq.artemis.core.transaction.Transaction;
13+
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
14+
import org.apache.activemq.artemis.spi.core.protocol.SessionCallback;
15+
16+
import java.io.Serializable;
17+
import java.util.Map;
18+
19+
/**
20+
* Created by zengfr on 2020/5/15.
21+
*/
22+
public class ArtemisActiveMQServerPlugin implements
23+
ActiveMQServerPlugin, Serializable {
24+
public static final String LOG_ALL_EVENTS = "LOG_ALL_EVENTS";
25+
public static final String IS_ENABLED = "IsEnabled";
26+
27+
private boolean logAll = false;
28+
private boolean isEnabled = true;
29+
@Override
30+
public void init(Map<String, String> properties) {
31+
logAll = Boolean.parseBoolean(properties.getOrDefault(LOG_ALL_EVENTS, "false"));
32+
isEnabled = Boolean.parseBoolean(properties.getOrDefault(IS_ENABLED, "true"));
33+
}
34+
35+
@Override
36+
public void afterCreateConnection(RemotingConnection connection) throws ActiveMQException {
37+
ActiveMQServerControl activeMQServerControl;
38+
// activeMQServerControl.addSecuritySettings();
39+
if(!isCheckOK()){
40+
connection.disconnect(false);
41+
//connection.
42+
}
43+
//Configuration config = new ConfigurationImpl();
44+
45+
//config.registerBrokerPlugin(new AuthArtemisServerPlugin());
46+
}
47+
48+
@Override
49+
public void beforeCreateSession(String name,
50+
String username,
51+
int minLargeMessageSize,
52+
RemotingConnection connection,
53+
boolean autoCommitSends,
54+
boolean autoCommitAcks,
55+
boolean preAcknowledge,
56+
boolean xa,
57+
String publicAddress,
58+
SessionCallback callback,
59+
boolean autoCreateQueues,
60+
OperationContext context,
61+
Map<SimpleString, RoutingType> prefixes)
62+
throws ActiveMQException {
63+
64+
}
65+
66+
@Override
67+
public void beforeCreateConsumer(long consumerID,
68+
QueueBinding queueBinding,
69+
SimpleString filterString,
70+
boolean browseOnly,
71+
boolean supportLargeMessage) throws ActiveMQException {
72+
73+
}
74+
75+
@Override
76+
public void beforeCreateQueue(QueueConfiguration queueConfig) throws ActiveMQException {
77+
78+
}
79+
80+
@Override
81+
public void beforeSend(ServerSession session,
82+
Transaction tx,
83+
Message message,
84+
boolean direct,
85+
boolean noAutoCreateQueue) throws ActiveMQException {
86+
87+
88+
}
89+
private static boolean isCheckOK(){
90+
LoggingActiveMQServerPluginLogger.LOGGER.info("");
91+
return true;
92+
}
93+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.zengfr.easymqtt4j.plugins;
2+
3+
import org.apache.activemq.artemis.spi.core.security.jaas.PropertiesLoginModule;
4+
5+
import javax.security.auth.Subject;
6+
import javax.security.auth.callback.*;
7+
import javax.security.auth.login.FailedLoginException;
8+
import javax.security.auth.login.LoginException;
9+
import javax.security.auth.spi.LoginModule;
10+
import java.io.IOException;
11+
import java.util.Map;
12+
import java.util.Properties;
13+
14+
/**
15+
* Created by zengfr on 2020/5/15.
16+
*/
17+
public class ArtemisPropertiesLoginModule implements LoginModule {
18+
private Properties users;
19+
private CallbackHandler callbackHandler;
20+
private boolean loginSucceeded;
21+
@Override
22+
public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState, Map<String, ?> options) {
23+
PropertiesLoginModule propertiesLoginModule;
24+
this.callbackHandler = callbackHandler;
25+
this.loginSucceeded=false;
26+
}
27+
28+
@Override
29+
public boolean login() throws LoginException {
30+
Callback[] callbacks = new Callback[]{new NameCallback("Username: "), new PasswordCallback("Password: ", false)};
31+
32+
try {
33+
this.callbackHandler.handle(callbacks);
34+
} catch (IOException var6) {
35+
throw new LoginException(var6.getMessage());
36+
} catch (UnsupportedCallbackException var7) {
37+
throw new LoginException(var7.getMessage() + " not available to obtain information from user");
38+
}
39+
40+
String userName = ((NameCallback)callbacks[0]).getName();
41+
char[] tmpPassword = ((PasswordCallback)callbacks[1]).getPassword();
42+
if (userName == null) {
43+
throw new FailedLoginException("User is null");
44+
} else {
45+
String password = this.users.getProperty(userName);
46+
if (password == null) {
47+
48+
}
49+
//loginSucceeded=password.equalsIgnoreCase(tmpPassword);
50+
}
51+
return loginSucceeded;
52+
}
53+
54+
@Override
55+
public boolean commit() throws LoginException {
56+
return false;
57+
}
58+
59+
@Override
60+
public boolean abort() throws LoginException {
61+
return false;
62+
}
63+
64+
@Override
65+
public boolean logout() throws LoginException {
66+
return false;
67+
}
68+
}

0 commit comments

Comments
 (0)