This commit is contained in:
Clebert Suconic 2018-03-01 16:22:41 -05:00
commit 005e9d67d0
91 changed files with 415 additions and 285 deletions

View File

@ -75,7 +75,6 @@ public abstract class ActionAbstract implements Action {
} else {
brokerEtc = getBrokerInstance() + "/etc";
}
System.setProperty("artemis.instance.etc", brokerEtc);
}
return brokerEtc;
}

View File

@ -79,6 +79,7 @@ public class Role implements Serializable {
this(name, send, consume, createDurableQueue, deleteDurableQueue, createNonDurableQueue, deleteNonDurableQueue, manage, consume);
}
@Deprecated
public Role(final String name,
final boolean send,
final boolean consume,
@ -156,6 +157,14 @@ public class Role implements Serializable {
return deleteNonDurableQueue;
}
public boolean isManage() {
return manage;
}
public boolean isBrowse() {
return browse;
}
@Override
public String toString() {
StringBuffer stringReturn = new StringBuffer("Role {name=" + name + "; allows=[");
@ -260,12 +269,4 @@ public class Role implements Serializable {
result = 31 * result + (browse ? 1 : 0);
return result;
}
public boolean isManage() {
return manage;
}
public boolean isBrowse() {
return browse;
}
}

View File

@ -30,13 +30,16 @@ export TEST_TARGET="./target"
cd $ARTEMIS_HOME/examples/features/standard/
cd bridge; mvn verify; cd ..
cd bridge; mvn verify; cd ..
cd browser; mvn verify; cd ..
cd auto-closeable; mvn verify; cd ..
cd broker-plugin; mvn verify; cd ..
cd browser; mvn verify; cd ..
cd cdi; mvn verify; cd ..
cd client-kickoff; mvn verify; cd ..
cd completion-listener; mvn verify; cd ..
cd consumer-rate-limit; mvn verify; cd ..
cd context; mvn verify; cd ..
cd core-bridge; mvn verify; cd ..
cd database; mvn verify; cd ..
cd dead-letter; mvn verify; cd ..
cd delayed-redelivery; mvn verify; cd ..
cd divert; mvn verify; cd ..
@ -45,16 +48,14 @@ cd embedded; mvn verify; cd ..
cd embedded-simple; mvn verify; cd ..
cd expiry; mvn verify; cd ..
cd http-transport; mvn verify; cd ..
cd interceptor; mvn verify; cd ..
cd interceptor-client; mvn verify; cd ..
cd interceptor-client-mqtt; mvn verify; cd ..
cd jms-auto-closeable; mvn verify; cd ..
cd instantiate-connection-factory; mvn verify; cd ..
cd interceptor; mvn verify; cd ..
cd interceptor-amqp; mvn verify; cd ..
cd interceptor-client; mvn verify; cd ..
cd interceptor-mqtt; mvn verify; cd ..
cd jms-bridge; mvn verify; cd ..
cd jms-completion-listener; mvn verify; cd ..
cd jms-context; mvn verify; cd ..
cd jms-shared-consumer; mvn verify; cd ..
cd jmx; mvn verify; cd ..
cd jmx-ssl; mvn verify; cd ..
# too big for most CI machines
#cd large-message; mvn verify; cd ..
@ -80,15 +81,18 @@ cd scheduled-message; mvn verify; cd ..
cd security; mvn verify; cd ..
cd security-ldap; mvn verify; cd ..
cd send-acknowledgements; mvn verify; cd ..
cd shared-consumer; mvn verify; cd ..
cd slow-consumer; mvn verify; cd ..
cd spring-integration; mvn verify; cd ..
cd ssl-enabled; mvn verify; cd ..
cd ssl-enabled-crl-mqtt; mvn verify; cd ..
cd ssl-enabled-dual-authentication; mvn verify; cd ..
cd static-selector; mvn verify; cd ..
cd temp-queue; mvn verify; cd ..
cd topic; mvn verify; cd ..
cd topic-hierarchies; mvn verify; cd ..
cd topic-selector-example1; mvn verify; cd ..
cd topic-selector-example2; mvn verify; cd ..
cd topic-selector1; mvn verify; cd ..
cd topic-selector2; mvn verify; cd ..
cd transactional; mvn verify; cd ..
cd xa-heuristic; mvn verify; cd ..
cd xa-receive; mvn verify; cd ..
@ -134,5 +138,37 @@ cd scale-down; mvn verify; cd ..
cd transaction-failover; mvn verify; cd ..
cd $ARTEMIS_HOME/examples/protocols/amqp/
cd queue; mvn verify; cd ..
cd $ARTEMIS_HOME/examples/protocols/mqtt/
cd clustered-queue-mqtt; mvn verify; cd ..
cd publish-subscribe; mvn verify; cd ..
cd $ARTEMIS_HOME/examples/protocols/openwire/
cd queue; mvn verify; cd ..
cd message-listener; mvn verify; cd ..
cd message-recovery; mvn verify; cd ..
cd $ARTEMIS_HOME/examples/protocols/stomp/
cd stomp; mvn verify; cd ..
cd stomp1.1; mvn verify; cd ..
cd stomp1.2; mvn verify; cd ..
cd stomp-dual-authentication; mvn verify; cd ..
cd stomp-embedded-interceptor; mvn verify; cd ..
cd stomp-jms; mvn verify; cd ..
cd $CURRENT_DIR
rm -rf target

View File

@ -30,12 +30,16 @@ export TEST_TARGET="./target"
cd $ARTEMIS_HOME/examples/features/standard/
cd bridge; mvn verify; cd ..
cd bridge; mvn verify; cd ..
cd browser; mvn verify; cd ..
cd auto-closeable; mvn verify; cd ..
cd broker-plugin; mvn verify; cd ..
cd browser; mvn verify; cd ..
cd cdi; mvn verify; cd ..
cd client-kickoff; mvn verify; cd ..
cd completion-listener; mvn verify; cd ..
cd consumer-rate-limit; mvn verify; cd ..
cd context; mvn verify; cd ..
cd core-bridge; mvn verify; cd ..
cd database; mvn verify; cd ..
cd dead-letter; mvn verify; cd ..
cd delayed-redelivery; mvn verify; cd ..
cd divert; mvn verify; cd ..
@ -44,15 +48,14 @@ cd embedded; mvn verify; cd ..
cd embedded-simple; mvn verify; cd ..
cd expiry; mvn verify; cd ..
cd http-transport; mvn verify; cd ..
cd interceptor; mvn verify; cd ..
cd interceptor-client; mvn verify; cd ..
cd jms-auto-closeable; mvn verify; cd ..
cd instantiate-connection-factory; mvn verify; cd ..
cd interceptor; mvn verify; cd ..
cd interceptor-amqp; mvn verify; cd ..
cd interceptor-client; mvn verify; cd ..
cd interceptor-mqtt; mvn verify; cd ..
cd jms-bridge; mvn verify; cd ..
cd jms-completion-listener; mvn verify; cd ..
cd jms-context; mvn verify; cd ..
cd jms-shared-consumer; mvn verify; cd ..
cd jmx; mvn verify; cd ..
cd jmx-ssl; mvn verify; cd ..
# too big for most CI machines
#cd large-message; mvn verify; cd ..
@ -78,15 +81,18 @@ cd scheduled-message; mvn verify; cd ..
cd security; mvn verify; cd ..
cd security-ldap; mvn verify; cd ..
cd send-acknowledgements; mvn verify; cd ..
cd shared-consumer; mvn verify; cd ..
cd slow-consumer; mvn verify; cd ..
cd spring-integration; mvn verify; cd ..
cd ssl-enabled; mvn verify; cd ..
cd ssl-enabled-crl-mqtt; mvn verify; cd ..
cd ssl-enabled-dual-authentication; mvn verify; cd ..
cd static-selector; mvn verify; cd ..
cd temp-queue; mvn verify; cd ..
cd topic; mvn verify; cd ..
cd topic-hierarchies; mvn verify; cd ..
cd topic-selector-example1; mvn verify; cd ..
cd topic-selector-example2; mvn verify; cd ..
cd topic-selector1; mvn verify; cd ..
cd topic-selector2; mvn verify; cd ..
cd transactional; mvn verify; cd ..
cd xa-heuristic; mvn verify; cd ..
cd xa-receive; mvn verify; cd ..

View File

@ -871,7 +871,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil {
}
for (String role : allRoles) {
securityRoles.add(new Role(role, send.contains(role), consume.contains(role), createDurableQueue.contains(role), deleteDurableQueue.contains(role), createNonDurableQueue.contains(role), deleteNonDurableQueue.contains(role), manageRoles.contains(role), browseRoles.contains(role)));
securityRoles.add(new Role(role, send.contains(role), consume.contains(role), createDurableQueue.contains(role), deleteDurableQueue.contains(role), createNonDurableQueue.contains(role), deleteNonDurableQueue.contains(role), manageRoles.contains(role), browseRoles.contains(role), createAddressRoles.contains(role), deleteAddressRoles.contains(role)));
}
return securityMatch;

View File

@ -366,8 +366,18 @@ public class LegacyLDAPSecuritySettingPlugin implements SecuritySettingPlugin {
Rdn rdn = ldapname.getRdn(ldapname.size() - 1);
String roleName = rdn.getValue().toString();
logger.debug("\tRole name: " + roleName);
Role role = new Role(roleName, permissionType.equalsIgnoreCase(writePermissionValue), permissionType.equalsIgnoreCase(readPermissionValue), permissionType.equalsIgnoreCase(adminPermissionValue), permissionType.equalsIgnoreCase(adminPermissionValue), permissionType.equalsIgnoreCase(adminPermissionValue), permissionType.equalsIgnoreCase(adminPermissionValue), false, // there is no permission from ActiveMQ 5.x that corresponds to the "manage" permission in ActiveMQ Artemis
permissionType.equalsIgnoreCase(readPermissionValue)); // the "browse" permission matches "read" from ActiveMQ 5.x
Role role = new Role(roleName,
permissionType.equalsIgnoreCase(writePermissionValue), // send
permissionType.equalsIgnoreCase(readPermissionValue), // consume
permissionType.equalsIgnoreCase(adminPermissionValue), // createDurableQueue
permissionType.equalsIgnoreCase(adminPermissionValue), // deleteDurableQueue
permissionType.equalsIgnoreCase(adminPermissionValue), // createNonDurableQueue
permissionType.equalsIgnoreCase(adminPermissionValue), // deleteNonDurableQueue
false, // manage - there is no permission from ActiveMQ 5.x that corresponds to this
permissionType.equalsIgnoreCase(readPermissionValue), // browse
permissionType.equalsIgnoreCase(adminPermissionValue), // createAddress
permissionType.equalsIgnoreCase(adminPermissionValue) // deleteAddress
);
roles.add(role);
}

View File

@ -508,63 +508,62 @@ public class FileConfigurationTest extends ConfigurationImplTest {
Map<String, Set<Role>> securityRoles = fc.getSecurityRoles();
Set<Role> roles = securityRoles.get("#");
//N.B. - FileConfigurationParser uses the constructor without createAddress and deleteAddress
//cn=mygroup,dc=local,dc=com = amq1
Role testRole1 = new Role("cn=mygroup,dc=local,dc=com",false, false, false,
false, true, false, false,
false);
false, false, false);
//myrole1 = amq1 + amq2
Role testRole2 = new Role("myrole1",false, false, false,
false, true, true, false,
false);
false, false, false);
//myrole3 = amq3 + amq4
Role testRole3 = new Role("myrole3",false, false, true,
true, false, false, false,
false);
false, false, false);
//myrole4 = amq5 + amq!@#$%^&*() + amq6
Role testRole4 = new Role("myrole4",true, true, false,
false, false, false, false,
true);
true, true, true);
//myrole5 = amq4 = amq3 + amq4
Role testRole5 = new Role("myrole5",false, false, true,
true, false, false, false,
false);
false, false, false);
Role testRole6 = new Role("amq1",false, false, false,
false, true, false, false,
false);
false, false, false);
Role testRole7 = new Role("amq2",false, false, false,
false, false, true, false,
false);
false, false, false);
Role testRole8 = new Role("amq3",false, false, true,
false, false, false, false,
false);
false, false, false);
Role testRole9 = new Role("amq4",false, false, true,
true, false, false, false,
false);
false, false, false);
Role testRole10 = new Role("amq5",false, false, false,
false, false, false, false,
false);
false, true, true);
Role testRole11 = new Role("amq6",false, true, false,
false, false, false, false,
true);
true, false, false);
Role testRole12 = new Role("amq7",false, false, false,
false, false, false, true,
false);
false, false, false);
Role testRole13 = new Role("amq!@#$%^&*()",true, false, false,
false, false, false, false,
false);
false, false, false);
assertEquals(13, roles.size());
assertTrue(roles.contains(testRole1));

View File

@ -35,6 +35,12 @@ wildcard match can be used using the wildcard characters '`#`' and
Eight different permissions can be given to the set of queues which
match the address. Those permissions are:
- `createAddress`. This permission allows the user to create an
address fitting the `match`.
- `deleteAddress`. This permission allows the user to delete an
address fitting the `match`.
- `createDurableQueue`. This permission allows the user to create a
durable queue under matching addresses.
@ -225,13 +231,14 @@ The name of the queue or topic defined in LDAP will serve as the "match" for the
will be mapped from the ActiveMQ 5.x type to the Artemis type, and the role will be mapped as-is.
ActiveMQ 5.x only has 3 permission types - `read`, `write`, and `admin`. These permission types are described on their
[website](http://activemq.apache.org/security.html). However, as described previously, ActiveMQ Artemis has 7 permission
types - `createDurableQueue`, `deleteDurableQueue`, `createNonDurableQueue`, `deleteNonDurableQueue`, `send`, `consume`,
`browse`, and `manage`. Here's how the old types are mapped to the new types:
[website](http://activemq.apache.org/security.html). However, as described previously, ActiveMQ Artemis has 9 permission
types - `createAddress`, `deleteAddress`, `createDurableQueue`, `deleteDurableQueue`, `createNonDurableQueue`,
`deleteNonDurableQueue`, `send`, `consume`, `browse`, and `manage`. Here's how the old types are mapped to the new types:
- `read` - `consume`, `browse`
- `write` - `send`
- `admin` - `createDurableQueue`, `deleteDurableQueue`, `createNonDurableQueue`, `deleteNonDurableQueue`
- `admin` - `createAddress`, `deleteAddress`, `createDurableQueue`, `deleteDurableQueue`, `createNonDurableQueue`,
`deleteNonDurableQueue`
As mentioned, there are a few places where a translation was performed to achieve some equivalence.:

View File

@ -1,32 +0,0 @@
Running the ActiveMQ Artemis Examples
============================
To run an individual example firstly cd into the example directory and run
```sh
mvn verify
```
Most examples offer a way to start them without creating and starting the broker (say if you want to do it manually)
```sh
mvn verify -PnoServer
```
If you are running against an un released version, i.e. from master branch, you will have to run `mvn install` on the root
pom.xml and the example/activemq-jms-examples-common/pom.xml first.
If you want to run all the examples (except those that need to be run standalone) you can run `mvn verify -Pexamples` in the examples
directory but before you do you will need to up the memory used by running:
```
export MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=256m"
```
### Recreating the examples
If you are trying to copy the examples somewhere else and modifying them. Consider asking Maven to explicitly list all the dependencies:
```
# if trying to modify the 'topic' example:
cd examples/jms/topic && mvn dependency:list
```

View File

@ -27,7 +27,7 @@
<version>2.5.0-SNAPSHOT</version>
</parent>
<artifactId>artemis-cdi-example</artifactId>
<artifactId>cdi</artifactId>
<packaging>jar</packaging>
<name>ActiveMQ Artemis CDI Example</name>
@ -153,7 +153,7 @@
<dependencies>
<dependency>
<groupId>org.apache.activemq.examples.broker</groupId>
<artifactId>artemis-cdi-example</artifactId>
<artifactId>cdi</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>

View File

@ -27,9 +27,9 @@ under the License.
<version>2.5.0-SNAPSHOT</version>
</parent>
<artifactId>datatabase</artifactId>
<artifactId>database</artifactId>
<packaging>jar</packaging>
<name>ActiveMQ Artemis JMS Expiry Example</name>
<name>ActiveMQ Artemis JMS Database Example</name>
<properties>
<activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
@ -104,7 +104,7 @@ under the License.
<dependencies>
<dependency>
<groupId>org.apache.activemq.examples.broker</groupId>
<artifactId>datatabase</artifactId>
<artifactId>database</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

View File

@ -4,4 +4,6 @@ To run the example, simply type **mvn verify** from this directory, or **mvn -Pn
This example shows you how to configure ActiveMQ Artemis to run with a database.
Notice this is not making any assumption of what is the recommended database to be used with Artemis. After all we recommend the artemis journal to be used, however in certain environments users will prefer databases for specific reasons.
### Notice
This is not making any assumption of what is the recommended database to be used with Artemis. We generally recommend the Artemis journal to be used. However, in certain environments users will prefer databases for specific reasons.

View File

@ -18,10 +18,7 @@ specific language governing permissions and limitations
under the License.
-->
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:activemq"
xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd">
<configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:activemq" xsi:schemaLocation="urn:activemq /schema/artemis-server.xsd">
<core xmlns="urn:activemq:core">
<persistence-enabled>false</persistence-enabled>
@ -30,11 +27,9 @@ under the License.
<acceptor name="in-vm">vm://0</acceptor>
</acceptors>
<!-- Other config -->
<security-settings>
<!--security for example queue-->
<security-setting match="#">
<permission type="createAddress" roles="guest"/>
<permission type="createDurableQueue" roles="guest"/>
<permission type="deleteDurableQueue" roles="guest"/>
<permission type="createNonDurableQueue" roles="guest"/>
@ -43,6 +38,5 @@ under the License.
<permission type="send" roles="guest"/>
</security-setting>
</security-settings>
</core>
</configuration>

View File

@ -27,7 +27,7 @@ under the License.
<version>2.5.0-SNAPSHOT</version>
</parent>
<artifactId>bridge</artifactId>
<artifactId>jms-bridge</artifactId>
<packaging>jar</packaging>
<name>ActiveMQ Artemis JMS Bridge Example</name>
@ -147,7 +147,7 @@ under the License.
<dependencies>
<dependency>
<groupId>org.apache.activemq.examples.broker</groupId>
<artifactId>bridge</artifactId>
<artifactId>jms-bridge</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

View File

@ -14,6 +14,15 @@ To access this MBeanServer remotely, add the following to the management.xml con
With these properties, ActiveMQ Artemis broker will be manageable remotely using standard JMX URL on port `1099`.
The various keystore files are generated using the following commands:
* `keytool -genkey -keystore server-side-keystore.jks -storepass secureexample -keypass secureexample -dname "CN=ActiveMQ Artemis Server, OU=Artemis, O=ActiveMQ, L=AMQ, S=AMQ, C=AMQ" -keyalg RSA`
* `keytool -export -keystore server-side-keystore.jks -file server-side-cert.cer -storepass secureexample`
* `keytool -import -keystore client-side-truststore.jks -file server-side-cert.cer -storepass secureexample -keypass secureexample -noprompt`
* `keytool -genkey -keystore client-side-keystore.jks -storepass secureexample -keypass secureexample -dname "CN=ActiveMQ Artemis Client, OU=Artemis, O=ActiveMQ, L=AMQ, S=AMQ, C=AMQ" -keyalg RSA`
* `keytool -export -keystore client-side-keystore.jks -file client-side-cert.cer -storepass secureexample`
* `keytool -import -keystore server-side-truststore.jks -file client-side-cert.cer -storepass secureexample -keypass secureexample -noprompt`
## More information
* [Java management guide](https://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html)

View File

@ -83,10 +83,10 @@ public class JMXOverSSLExample {
String[] creds = {"guest", "guest"};
env.put(JMXConnector.CREDENTIALS, creds);
System.setProperty("javax.net.ssl.trustStore", args[0] + "activemq.example.truststore");
System.setProperty("javax.net.ssl.trustStorePassword", "activemqexample");
System.setProperty("javax.net.ssl.keyStore", args[0] + "activemq.example.keystore");
System.setProperty("javax.net.ssl.keyStorePassword", "activemqexample");
System.setProperty("javax.net.ssl.trustStore", args[0] + "client-side-truststore.jks");
System.setProperty("javax.net.ssl.trustStorePassword", "secureexample");
System.setProperty("javax.net.ssl.keyStore", args[0] + "client-side-keystore.jks");
System.setProperty("javax.net.ssl.keyStorePassword", "secureexample");
JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(JMXOverSSLExample.JMX_URL), env);
@ -131,6 +131,11 @@ public class JMXOverSSLExample {
if (connection != null) {
connection.close();
}
System.clearProperty("javax.net.ssl.trustStore");
System.clearProperty("javax.net.ssl.trustStorePassword");
System.clearProperty("javax.net.ssl.keyStore");
System.clearProperty("javax.net.ssl.keyStorePassword");
}
}
}

View File

@ -20,10 +20,10 @@
connector-port="1099"
connector-host="localhost"
secured="true"
key-store-path="${data.dir}/../etc/activemq.example.keystore"
key-store-password="activemqexample"
trust-store-path="${data.dir}/../etc/activemq.example.truststore"
trust-store-password="activemqexample"/>
key-store-path="${data.dir}/../etc/server-side-keystore.jks"
key-store-password="secureexample"
trust-store-path="${data.dir}/../etc/server-side-truststore.jks"
trust-store-password="secureexample"/>
<authorisation>
<whitelist>
<entry domain="hawtio"/>

View File

@ -41,12 +41,15 @@ under the License.
<profile>
<id>release</id>
<modules>
<module>bridge</module>
<module>auto-closeable</module>
<module>browser</module>
<module>broker-plugin</module>
<module>cdi</module>
<module>client-kickoff</module>
<module>completion-listener</module>
<module>consumer-rate-limit</module>
<module>context</module>
<module>core-bridge</module>
<module>database</module>
<module>dead-letter</module>
<module>delayed-redelivery</module>
@ -61,11 +64,7 @@ under the License.
<module>interceptor-mqtt</module>
<module>interceptor-amqp</module>
<module>instantiate-connection-factory</module>
<module>jms-auto-closeable</module>
<module>jms-bridge</module>
<module>jms-completion-listener</module>
<module>jms-context</module>
<module>jms-shared-consumer</module>
<module>jmx</module>
<module>jmx-ssl</module>
<module>large-message</module>
@ -90,32 +89,36 @@ under the License.
<module>security</module>
<module>security-ldap</module>
<module>send-acknowledgements</module>
<module>shared-consumer</module>
<module>slow-consumer</module>
<module>spring-integration</module>
<module>ssl-enabled</module>
<module>ssl-enabled-crl-mqtt</module>
<module>ssl-enabled-dual-authentication</module>
<module>static-selector</module>
<module>temp-queue</module>
<module>topic</module>
<module>topic-hierarchies</module>
<module>topic-selector-example1</module>
<module>topic-selector-example2</module>
<module>topic-selector1</module>
<module>topic-selector2</module>
<module>transactional</module>
<module>xa-heuristic</module>
<module>xa-receive</module>
<module>xa-send</module>
<module>ssl-enabled-crl-mqtt</module>
</modules>
</profile>
<profile>
<id>examples</id>
<modules>
<module>bridge</module>
<module>auto-closeable</module>
<module>browser</module>
<module>broker-plugin</module>
<module>cdi</module>
<module>client-kickoff</module>
<module>completion-listener</module>
<module>consumer-rate-limit</module>
<module>context</module>
<module>core-bridge</module>
<module>database</module>
<module>dead-letter</module>
<module>delayed-redelivery</module>
@ -129,12 +132,8 @@ under the License.
<module>interceptor-client</module>
<module>interceptor-mqtt</module>
<module>interceptor-amqp</module>
<module>jms-auto-closeable</module>
<module>instantiate-connection-factory</module>
<module>jms-bridge</module>
<module>jms-completion-listener</module>
<module>jms-context</module>
<module>jms-shared-consumer</module>
<module>jmx</module>
<module>jmx-ssl</module>
<module>large-message</module>
@ -153,16 +152,17 @@ under the License.
<module>queue-requestor</module>
<module>queue-selector</module>
<module>reattach-node</module>
<module>request-reply</module>
<module>rest</module>
<module>request-reply</module>
<module>scheduled-message</module>
<module>security</module>
<module>security-ldap</module>
<module>send-acknowledgements</module>
<module>shared-consumer</module>
<module>slow-consumer</module>
<module>spring-integration</module>
<module>ssl-enabled</module>
<module>ssl-enabled-crl-mqtt</module>
<module>ssl-enabled-dual-authentication</module>
<module>static-selector</module>
@ -172,13 +172,12 @@ under the License.
<module>temp-queue</module>
<module>topic</module>
<module>topic-hierarchies</module>
<module>topic-selector-example1</module>
<module>topic-selector-example2</module>
<module>topic-selector1</module>
<module>topic-selector2</module>
<module>transactional</module>
<module>xa-heuristic</module>
<module>xa-receive</module>
<module>xa-send</module>
<module>ssl-enabled-crl-mqtt</module>
</modules>
</profile>

View File

@ -18,6 +18,7 @@ specific language governing permissions and limitations
under the License.
-->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core">
<bindings-directory>./data/messaging/bindings</bindings-directory>
<journal-directory>./data/messaging/journal</journal-directory>

View File

@ -37,6 +37,7 @@ under the License.
<security-settings>
<!--security for example queues -->
<security-setting match="#">
<permission roles="guest" type="deleteAddress"/>
<permission roles="guest" type="createDurableQueue"/>
<permission roles="guest" type="deleteDurableQueue"/>
<permission roles="guest" type="createNonDurableQueue"/>
@ -44,20 +45,6 @@ under the License.
<permission roles="guest" type="consume"/>
<permission roles="guest" type="send"/>
</security-setting>
<!-- security settings for JMS temporary queue -->
<security-setting match="#">
<permission roles="guest" type="createNonDurableQueue"/>
<permission roles="guest" type="deleteNonDurableQueue"/>
<permission roles="guest" type="consume"/>
<permission roles="guest" type="send"/>
</security-setting>
</security-settings>
<addresses>
<address name="exampleQueue">
<anycast>
<queue name="jms.queue.exampleQueue"/>
</anycast>
</address>
</addresses>
</core>
</configuration>

View File

@ -56,8 +56,9 @@ under the License.
<profile>
<id>examples</id>
<modules>
<!-- this one to be run manually
<module>proton-cpp</module> -->
<!-- these to be run manually
<module>proton-cpp</module>
<module>proton-clustered-cpp</module> -->
<module>queue</module>
<module>proton-ruby</module>

View File

@ -29,7 +29,7 @@ under the License.
<artifactId>clustered-queue-mqtt</artifactId>
<packaging>jar</packaging>
<name>ActiveMQ Artemis JMS Clustered Queue Example</name>
<name>ActiveMQ Artemis MQTT Clustered Queue Example</name>
<properties>
<activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
@ -117,7 +117,7 @@ under the License.
<goal>runClient</goal>
</goals>
<configuration>
<clientClass>org.apache.activemq.artemis.jms.example.ClusteredQueueMQTTExample</clientClass>
<clientClass>org.apache.activemq.artemis.mqtt.example.ClusteredQueueMQTTExample</clientClass>
</configuration>
</execution>
<execution>
@ -149,7 +149,7 @@ under the License.
</executions>
<dependencies>
<dependency>
<groupId>org.apache.activemq.examples.clustered</groupId>
<groupId>org.apache.activemq.examples.mqtt</groupId>
<artifactId>clustered-queue-mqtt</artifactId>
<version>${project.version}</version>
</dependency>

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.activemq.artemis.jms.example;
package org.apache.activemq.artemis.mqtt.example;
import java.util.concurrent.TimeUnit;
import org.fusesource.mqtt.client.BlockingConnection;

View File

@ -40,15 +40,15 @@ under the License.
<profile>
<id>release</id>
<modules>
<module>basic-pubsub</module>
<module>clustered-queue-mqtt</module>
<module>publish-subscribe</module>
</modules>
</profile>
<profile>
<id>examples</id>
<modules>
<module>basic-pubsub</module>
<module>clustered-queue-mqtt</module>
<module>publish-subscribe</module>
</modules>
</profile>
</profiles>

View File

@ -27,9 +27,9 @@ under the License.
<version>2.5.0-SNAPSHOT</version>
</parent>
<artifactId>artemis-mqtt-publish-example</artifactId>
<artifactId>publish-subscribe</artifactId>
<packaging>jar</packaging>
<name>ActiveMQ Artemis MQTT Publish Example</name>
<name>ActiveMQ Artemis MQTT Publish/Subscribe Example</name>
<properties>
<activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
@ -60,6 +60,7 @@ under the License.
<goal>cli</goal>
</goals>
<configuration>
<ignore>${noServer}</ignore>
<spawn>true</spawn>
<testURI>tcp://localhost:61616</testURI>
<args>
@ -73,10 +74,7 @@ under the License.
<goal>runClient</goal>
</goals>
<configuration>
<clientClass>org.apache.activemq.artemis.mqtt.example.MQTTBasicPubSubExample</clientClass>
<args>
<param>${basedir}/target/server0</param>
</args>
<clientClass>org.apache.activemq.artemis.mqtt.example.MQTTPublishSubscribeExample</clientClass>
</configuration>
</execution>
<execution>
@ -85,6 +83,7 @@ under the License.
<goal>cli</goal>
</goals>
<configuration>
<ignore>${noServer}</ignore>
<args>
<param>stop</param>
</args>
@ -94,7 +93,7 @@ under the License.
<dependencies>
<dependency>
<groupId>org.apache.activemq.examples.mqtt</groupId>
<artifactId>artemis-mqtt-publish-example</artifactId>
<artifactId>publish-subscribe</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

View File

@ -1,4 +1,4 @@
# MQTT Example
# MQTT Publish/Subscribe Example
This is a basic MQTT example that demonstrates how to setup and connect to an Apache Artemis broker and send and receive messages using the MQTT protocol.

View File

@ -27,7 +27,7 @@ import org.fusesource.mqtt.client.Topic;
/**
* A simple MQTT publish and subscribe example.
*/
public class MQTTBasicPubSubExample {
public class MQTTPublishSubscribeExample {
public static void main(final String[] args) throws Exception {
// Create a new MQTT connection to the broker. We are not setting the client ID. The broker will pick one for us.

View File

@ -29,7 +29,7 @@ under the License.
<artifactId>message-listener</artifactId>
<packaging>jar</packaging>
<name>ActiveMQ Artemis JMS Queue Example for openwire</name>
<name>ActiveMQ Artemis OpenWire JMS Message Listener Example</name>
<properties>
<activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
@ -84,7 +84,7 @@ under the License.
<goal>runClient</goal>
</goals>
<configuration>
<clientClass>org.apache.activemq.artemis.jms.example.QueueExample</clientClass>
<clientClass>org.apache.activemq.artemis.jms.example.MessageListenerExample</clientClass>
</configuration>
</execution>
<execution>

View File

@ -1,5 +1,5 @@
# JMS Queue Message Listener for OpenWire
# OpenWire JMS Message Listener Example
To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually.
This example shows how to use a MessageListener with the OpenWire client
This example shows how to use a MessageListener with the OpenWire client.

View File

@ -30,10 +30,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.activemq.ActiveMQConnectionFactory;
/**
* A simple JMS Queue example that creates a producer and consumer on a queue and sends then receives a message.
*/
public class QueueExample {
public class MessageListenerExample {
public static void main(final String[] args) throws Exception {
Connection connection = null;

View File

@ -29,7 +29,7 @@ under the License.
<artifactId>message-recovery</artifactId>
<packaging>jar</packaging>
<name>ActiveMQ Artemis JMS Queue Example for openwire</name>
<name>ActiveMQ Artemis OpenWire JMS Message Recovery Example</name>
<properties>
<activemq.basedir>${project.basedir}/../../../..</activemq.basedir>
@ -79,7 +79,7 @@ under the License.
<goal>runClient</goal>
</goals>
<configuration>
<clientClass>org.apache.activemq.artemis.jms.example.QueueExample</clientClass>
<clientClass>org.apache.activemq.artemis.jms.example.MessageRecoveryExample</clientClass>
<args>
<param>${basedir}/target/server0</param>
</args>

View File

@ -1,5 +1,5 @@
# JMS Queue Message Listener for OpenWire
# OpenWire JMS Message Recovery Example
This example will start and stop the broker within the example.
This example shows how to use send messages to a queue, and having these messages recovered from the journal.
This example shows how to use send messages to a queue and having these messages recovered from the journal when the broker is restarted.

View File

@ -31,16 +31,13 @@ import java.util.concurrent.TimeUnit;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.artemis.util.ServerUtil;
/**
* A simple JMS Queue example that creates a producer and consumer on a queue and sends then receives a message.
*/
public class QueueExample {
public class MessageRecoveryExample {
public static void main(final String[] args) throws Exception {
Connection connection = null;
Process server0 = null;
try {
server0 = ServerUtil.startServer(args[0], QueueExample.class.getSimpleName() + "0", 0, 5000);
server0 = ServerUtil.startServer(args[0], MessageRecoveryExample.class.getSimpleName() + "0", 0, 5000);
ConnectionFactory cf = new ActiveMQConnectionFactory();
@ -66,7 +63,7 @@ public class QueueExample {
ServerUtil.killServer(server0);
server0 = ServerUtil.startServer(args[0], QueueExample.class.getSimpleName() + "0", 0, 5000);
server0 = ServerUtil.startServer(args[0], MessageRecoveryExample.class.getSimpleName() + "0", 0, 5000);
ServerUtil.waitForServerToStart(0, 5000);

View File

@ -29,7 +29,7 @@ under the License.
<artifactId>queue-openwire</artifactId>
<packaging>jar</packaging>
<name>ActiveMQ Artemis JMS Queue Example for openwire</name>
<name>ActiveMQ Artemis OpenWire JMS Queue Example</name>
<properties>
<activemq.basedir>${project.basedir}/../../../..</activemq.basedir>

View File

@ -1,13 +1,9 @@
# JMS Queue Example for OpenWire
# OpenWire JMS Queue Example
To run the example, simply type **mvn verify** from this directory, or **mvn -PnoServer verify** if you want to start and create the broker manually.
This example shows you how to send and receive a message to a JMS Queue using ActiveMQ Artemis.
This example shows you how to send and receive a message to a JMS queue using ActiveMQ Artemis.
This example does exactly the same as the "queue" example however using the OpenWire client.
Queues are a standard part of JMS, please consult the JMS 1.1 specification for full details.
A Queue is used to send messages point to point, from a producer to a consumer. The queue guarantees message ordering between these 2 points.
Notice this example is using pretty much a default stock configuration
Notice this example is using the default configuration.

View File

@ -80,13 +80,10 @@ under the License.
<goal>runClient</goal>
</goals>
<configuration>
<clientClass>org.apache.activemq.artemis.jms.example.StompDualAuthenticationExample</clientClass>
<args>
<arg>${project.basedir}/target/server0/etc/client-side-keystore.jks</arg>
<arg>secureexample</arg>
<arg>${project.basedir}/target/server0/etc/client-side-truststore.jks</arg>
<arg>secureexample</arg>
</args>
<arg>${project.build.outputDirectory}/activemq/server0/</arg>
</args>
<clientClass>org.apache.activemq.artemis.jms.example.StompDualAuthenticationExample</clientClass>
</configuration>
</execution>
<execution>

View File

@ -42,17 +42,18 @@ public class StompDualAuthenticationExample {
private static final String END_OF_FRAME = "\u0000";
public static void main(final String[] args) throws Exception {
// set up SSL keystores for Stomp connection
System.setProperty("javax.net.ssl.keyStore", args[0]);
System.setProperty("javax.net.ssl.keyStorePassword", args[1]);
System.setProperty("javax.net.ssl.trustStore", args[2]);
System.setProperty("javax.net.ssl.trustStorePassword", args[3]);
Connection connection = null;
InitialContext initialContext = null;
Security.addProvider(new Provider());
try {
// set up SSL keystores for Stomp connection
System.setProperty("javax.net.ssl.trustStore", args[0] + "client-side-truststore.jks");
System.setProperty("javax.net.ssl.trustStorePassword", "secureexample");
System.setProperty("javax.net.ssl.keyStore", args[0] + "client-side-keystore.jks");
System.setProperty("javax.net.ssl.keyStorePassword", "secureexample");
// Step 1. Create an SSL socket to connect to the broker
SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket socket = (SSLSocket) sslsocketfactory.createSocket("localhost", 5500);
@ -114,6 +115,11 @@ public class StompDualAuthenticationExample {
if (connection != null) {
connection.close();
}
System.clearProperty("javax.net.ssl.trustStore");
System.clearProperty("javax.net.ssl.trustStorePassword");
System.clearProperty("javax.net.ssl.keyStore");
System.clearProperty("javax.net.ssl.keyStorePassword");
}
}

View File

@ -31,7 +31,7 @@ under the License.
<!-- Acceptors -->
<acceptors>
<acceptor name="netty-acceptor">tcp://localhost:61616</acceptor>
<acceptor name="netty-ssl-acceptor">tcp://localhost:5500?sslEnabled=true;needClientAuth=true;keyStorePath=${data.dir}/../etc/server-side-keystore.jks;keyStorePassword=secureexample;trustStorePath=${data.dir}/../etc/server-side-truststore.jks;trustStorePassword=secureexample</acceptor>
<acceptor name="netty-ssl-acceptor">tcp://localhost:5500?sslEnabled=true;needClientAuth=true;keyStorePath=server-side-keystore.jks;keyStorePassword=secureexample;trustStorePath=server-side-truststore.jks;trustStorePassword=secureexample</acceptor>
</acceptors>
<!-- Other config -->
@ -47,7 +47,7 @@ under the License.
<addresses>
<address name="exampleQueue">
<anycast>
<queue name="jms.queue.exampleQueue"/>
<queue name="exampleQueue"/>
</anycast>
</address>
</addresses>

View File

@ -29,7 +29,7 @@ under the License.
<artifactId>stomp-jms</artifactId>
<packaging>jar</packaging>
<name>ActiveMQ Artemis JMS Stomp JMS Example</name>
<name>ActiveMQ Artemis Stomp JMS Example</name>
<properties>
<activemq.basedir>${project.basedir}/../../../..</activemq.basedir>

View File

@ -43,7 +43,7 @@ public class StompExample {
connection.start();
System.out.println("Waiting 20 seconds");
System.out.println("Waiting 10 seconds");
Thread.sleep(10000); // increase this and it will fail
System.out.println("waited");

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
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.
-->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core">
<bindings-directory>./data/messaging/bindings</bindings-directory>
<journal-directory>./data/messaging/journal</journal-directory>
<large-messages-directory>./data/messaging/largemessages</large-messages-directory>
<paging-directory>./data/messaging/paging</paging-directory>
<acceptors>
<acceptor name="netty-acceptor">tcp://localhost:61616?anycastPrefix=/queue/</acceptor>
</acceptors>
<security-settings>
<security-setting match="#">
<permission roles="guest" type="consume"/>
<permission roles="guest" type="send"/>
<permission roles="guest" type="createAddress"/>
<permission roles="guest" type="createDurableQueue"/>
</security-setting>
</security-settings>
</core>
</configuration>

View File

@ -46,8 +46,6 @@ public class StompExample {
// Step 2. Send a CONNECT frame to connect to the server
String connectFrame = "CONNECT\n" +
"login: guest\n" +
"passcode: guest\n" +
"request-id: 1\n" +
"\n" +
END_OF_FRAME;

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
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.
-->
<configuration xmlns="urn:activemq" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:activemq /schema/artemis-configuration.xsd">
<core xmlns="urn:activemq:core">
<bindings-directory>./data/messaging/bindings</bindings-directory>
<journal-directory>./data/messaging/journal</journal-directory>
<large-messages-directory>./data/messaging/largemessages</large-messages-directory>
<paging-directory>./data/messaging/paging</paging-directory>
<acceptors>
<acceptor name="netty-acceptor">tcp://localhost:61616?protocols=CORE</acceptor>
<acceptor name="stomp-acceptor">tcp://localhost:61613?protocols=STOMP</acceptor>
</acceptors>
<security-settings>
<security-setting match="#">
<permission type="send" roles="guest"/>
<permission type="consume" roles="guest"/>
<permission type="createAddress" roles="guest"/>
<permission type="createDurableQueue" roles="guest"/>
</security-setting>
</security-settings>
<address-settings>
<address-setting match="#">
<default-address-routing-type>ANYCAST</default-address-routing-type>
<default-queue-routing-type>ANYCAST</default-queue-routing-type>
</address-setting>
</address-settings>
</core>
</configuration>

View File

@ -48,8 +48,6 @@ public class StompExample {
String connectFrame = "CONNECT\n" +
"accept-version:1.1\n" +
"host:localhost\n" +
"login:guest\n" +
"passcode:guest\n" +
"request-id:1\n" +
"\n" +
END_OF_FRAME;
@ -63,6 +61,7 @@ public class StompExample {
String text = "Hello World from Stomp 1.1 !";
String message = "SEND\n" +
"destination:exampleQueue\n" +
"destination-type:ANYCAST\n" +
"\n" +
text +
END_OF_FRAME;

View File

@ -48,8 +48,6 @@ public class StompExample {
String connectFrame = "CONNECT\n" +
"accept-version:1.2\n" +
"host:localhost\n" +
"login:guest\n" +
"passcode:guest\n" +
"request-id:1\n" +
"\n" +
END_OF_FRAME;
@ -63,6 +61,7 @@ public class StompExample {
String text = "Hello World from Stomp 1.2 !";
String message = "SEND\n" +
"destination:exampleQueue\n" +
"destination-type:ANYCAST\n" +
"\n" +
text +
END_OF_FRAME;

View File

@ -256,10 +256,10 @@ public class AmqpClientTestSupport extends AmqpTestSupport {
// Configure roles
HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
HashSet<Role> value = new HashSet<>();
value.add(new Role("nothing", false, false, false, false, false, false, false, false));
value.add(new Role("browser", false, false, false, false, false, false, false, true));
value.add(new Role("guest", false, true, false, false, false, false, false, true));
value.add(new Role("full", true, true, true, true, true, true, true, true));
value.add(new Role("nothing", false, false, false, false, false, false, false, false, false, false));
value.add(new Role("browser", false, false, false, false, false, false, false, true, false, false));
value.add(new Role("guest", false, true, false, false, false, false, false, true, false, false));
value.add(new Role("full", true, true, true, true, true, true, true, true, true, true));
securityRepository.addMatch(getQueueName(), value);
server.getConfiguration().setSecurityEnabled(true);

View File

@ -486,7 +486,7 @@ public class SimpleJNDIClientTest extends ActiveMQTestBase {
//setup user and role on broker
((ActiveMQJAASSecurityManager) liveService.getSecurityManager()).getConfiguration().addUser("myUser", "myPassword");
((ActiveMQJAASSecurityManager) liveService.getSecurityManager()).getConfiguration().addRole("myUser", "consumeCreateRole");
Role consumeCreateRole = new Role("consumeCreateRole", false, true, true, true, true, true, true, true);
Role consumeCreateRole = new Role("consumeCreateRole", false, true, true, true, true, true, true, true, true, true);
Set<Role> consumerCreateRoles = new HashSet<>();
consumerCreateRoles.add(consumeCreateRole);
liveService.getSecurityRepository().addMatch("test.queue", consumerCreateRoles);

View File

@ -181,10 +181,10 @@ public class MQTTTestSupport extends ActiveMQTestBase {
// Configure roles
HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
HashSet<Role> value = new HashSet<>();
value.add(new Role("nothing", false, false, false, false, false, false, false, false));
value.add(new Role("browser", false, false, false, false, false, false, false, true));
value.add(new Role("guest", false, true, false, false, false, false, false, true));
value.add(new Role("full", true, true, true, true, true, true, true, true));
value.add(new Role("nothing", false, false, false, false, false, false, false, false, false, false));
value.add(new Role("browser", false, false, false, false, false, false, false, true, false, false));
value.add(new Role("guest", false, true, false, false, false, false, false, true, false, false));
value.add(new Role("full", true, true, true, true, true, true, true, true, true, true));
securityRepository.addMatch(getQueueName(), value);
server.getConfiguration().setSecurityEnabled(true);

View File

@ -71,7 +71,7 @@ public class OutgoingConnectionNoJTATest extends ActiveMQRATestBase {
((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().setDefaultUser("guest");
((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().addRole("testuser", "arole");
((ActiveMQJAASSecurityManager) server.getSecurityManager()).getConfiguration().addRole("guest", "arole");
Role role = new Role("arole", true, true, true, true, true, true, true, true);
Role role = new Role("arole", true, true, true, true, true, true, true, true, true, true);
Set<Role> roles = new HashSet<>();
roles.add(role);
server.getSecurityRepository().addMatch(MDBQUEUEPREFIXED, roles);

View File

@ -285,13 +285,11 @@ public class StompTest extends StompTestBase {
}
@Test
public void testSendMessageToNonExistentQueue() throws Exception {
String nonExistentQueue = RandomUtil.randomString();
public void sendMessageToNonExistentQueue(String queuePrefix, String queue, RoutingType routingType) throws Exception {
conn.connect(defUser, defPass);
send(conn, getQueuePrefix() + nonExistentQueue, null, "Hello World", true, RoutingType.ANYCAST);
send(conn, queuePrefix + queue, null, "Hello World", true, routingType);
MessageConsumer consumer = session.createConsumer(ActiveMQJMSClient.createQueue(nonExistentQueue));
MessageConsumer consumer = session.createConsumer(ActiveMQJMSClient.createQueue(queue));
TextMessage message = (TextMessage) consumer.receive(1000);
Assert.assertNotNull(message);
Assert.assertEquals("Hello World", message.getText());
@ -305,26 +303,32 @@ public class StompTest extends StompTestBase {
Assert.assertTrue(Math.abs(tnow - tmsg) < 1500);
// closing the consumer here should trigger auto-deletion
assertNotNull(server.getActiveMQServer()
.getPostOffice()
.getBinding(new SimpleString(nonExistentQueue)));
assertNotNull(server.getActiveMQServer().getPostOffice().getBinding(new SimpleString(queue)));
consumer.close();
assertNull(server.getActiveMQServer()
.getPostOffice()
.getBinding(new SimpleString(nonExistentQueue)));
assertNull(server.getActiveMQServer().getPostOffice().getBinding(new SimpleString(queue)));
}
@Test
public void testSendMessageToNonExistentTopic() throws Exception {
String nonExistentTopic = RandomUtil.randomString();
public void testSendMessageToNonExistentQueue() throws Exception {
sendMessageToNonExistentQueue(getQueuePrefix(), RandomUtil.randomString(), RoutingType.ANYCAST);
}
@Test
public void testSendMessageToNonExistentQueueUsingExplicitDefaultRouting() throws Exception {
String nonExistentQueue = RandomUtil.randomString();
server.getActiveMQServer().getAddressSettingsRepository().addMatch(nonExistentQueue, new AddressSettings().setDefaultAddressRoutingType(RoutingType.ANYCAST).setDefaultQueueRoutingType(RoutingType.ANYCAST));
sendMessageToNonExistentQueue(getQueuePrefix(), nonExistentQueue, null);
}
public void sendMessageToNonExistentTopic(String topicPrefix, String topic, RoutingType routingType) throws Exception {
conn.connect(defUser, defPass);
// first send a message to ensure that sending to a non-existent topic won't throw an error
send(conn, getTopicPrefix() + nonExistentTopic, null, "Hello World", true, RoutingType.MULTICAST);
send(conn, topicPrefix + topic, null, "Hello World", true, routingType);
// create a subscription on the topic and send/receive another message
MessageConsumer consumer = session.createConsumer(ActiveMQJMSClient.createTopic(nonExistentTopic));
send(conn, getTopicPrefix() + nonExistentTopic, null, "Hello World", true);
MessageConsumer consumer = session.createConsumer(ActiveMQJMSClient.createTopic(topic));
send(conn, topicPrefix + topic, null, "Hello World", true, routingType);
TextMessage message = (TextMessage) consumer.receive(1000);
Assert.assertNotNull(message);
Assert.assertEquals("Hello World", message.getText());
@ -337,14 +341,29 @@ public class StompTest extends StompTestBase {
long tmsg = message.getJMSTimestamp();
Assert.assertTrue(Math.abs(tnow - tmsg) < 1500);
assertNotNull(server.getActiveMQServer()
.getAddressInfo(new SimpleString(nonExistentTopic)));
assertNotNull(server.getActiveMQServer().getAddressInfo(new SimpleString(topic)));
// closing the consumer here should trigger auto-deletion of the subscription queue and address
consumer.close();
Thread.sleep(200);
assertNull(server.getActiveMQServer()
.getAddressInfo(new SimpleString(nonExistentTopic)));
assertNull(server.getActiveMQServer().getAddressInfo(new SimpleString(topic)));
}
@Test
public void testSendMessageToNonExistentTopic() throws Exception {
sendMessageToNonExistentTopic(getTopicPrefix(), RandomUtil.randomString(), RoutingType.MULTICAST);
}
@Test
public void testSendMessageToNonExistentTopicUsingExplicitDefaultRouting() throws Exception {
String nonExistentTopic = RandomUtil.randomString();
server.getActiveMQServer().getAddressSettingsRepository().addMatch(nonExistentTopic, new AddressSettings().setDefaultAddressRoutingType(RoutingType.MULTICAST).setDefaultQueueRoutingType(RoutingType.MULTICAST));
sendMessageToNonExistentTopic(getTopicPrefix(), nonExistentTopic, null);
}
@Test
public void testSendMessageToNonExistentTopicUsingImplicitDefaultRouting() throws Exception {
sendMessageToNonExistentTopic(getTopicPrefix(), RandomUtil.randomString(), null);
}
/*

View File

@ -37,6 +37,7 @@ import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.activemq.artemis.api.core.RoutingType;
import org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.protocol.mqtt.MQTTProtocolManagerFactory;
@ -50,7 +51,6 @@ import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
import org.apache.activemq.artemis.core.security.Role;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServers;
import org.apache.activemq.artemis.api.core.RoutingType;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory;
import org.apache.activemq.artemis.jms.server.JMSServerManager;
@ -65,6 +65,7 @@ import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection;
import org.apache.activemq.artemis.tests.unit.util.InVMNamingContext;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@ -159,6 +160,15 @@ public abstract class StompTestBase extends ActiveMQTestBase {
connection.start();
}
@Override
@After
public void tearDown() throws Exception {
if (connection != null) {
connection.close();
}
super.tearDown();
}
/**
* @return

View File

@ -18,6 +18,7 @@
package org.apache.activemq.artemis.tests.integration.stomp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.activemq.artemis.api.core.Interceptor;
@ -25,7 +26,6 @@ import org.apache.activemq.artemis.core.protocol.core.Packet;
import org.apache.activemq.artemis.core.protocol.stomp.StompFrame;
import org.apache.activemq.artemis.core.protocol.stomp.StompFrameInterceptor;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionFactory;
@ -38,8 +38,8 @@ public class StompWithInterceptorsTest extends StompTestBase {
@Override
public List<String> getIncomingInterceptors() {
List<String> stompIncomingInterceptor = new ArrayList<>();
stompIncomingInterceptor.add("org.apache.activemq.artemis.tests.integration.stomp.StompWithInterceptorsTest$MyIncomingStompFrameInterceptor");
stompIncomingInterceptor.add("org.apache.activemq.artemis.tests.integration.stomp.StompWithInterceptorsTest$MyCoreInterceptor");
stompIncomingInterceptor.add("org.apache.activemq.artemis.tests.integration.stomp.StompWithInterceptorsTest$IncomingStompInterceptor");
stompIncomingInterceptor.add("org.apache.activemq.artemis.tests.integration.stomp.StompWithInterceptorsTest$CoreInterceptor");
return stompIncomingInterceptor;
}
@ -47,20 +47,25 @@ public class StompWithInterceptorsTest extends StompTestBase {
@Override
public List<String> getOutgoingInterceptors() {
List<String> stompOutgoingInterceptor = new ArrayList<>();
stompOutgoingInterceptor.add("org.apache.activemq.artemis.tests.integration.stomp.StompWithInterceptorsTest$MyOutgoingStompFrameInterceptor");
stompOutgoingInterceptor.add("org.apache.activemq.artemis.tests.integration.stomp.StompWithInterceptorsTest$OutgoingStompInterceptor");
return stompOutgoingInterceptor;
}
@Test
public void stompFrameInterceptor() throws Exception {
MyIncomingStompFrameInterceptor.incomingInterceptedFrames.clear();
MyOutgoingStompFrameInterceptor.outgoingInterceptedFrames.clear();
Thread.sleep(200);
// So we clear them here
MyCoreInterceptor.incomingInterceptedFrames.clear();
IncomingStompInterceptor.interceptedFrames.clear();
OutgoingStompInterceptor.interceptedFrames.clear();
// wait for the SESS_START which is the last packet for the test's JMS connection
assertTrue(Wait.waitFor(() -> {
for (Packet packet : new ArrayList<>(CoreInterceptor.incomingInterceptedFrames)) {
if (packet.getType() == (byte) 67) {
return true;
}
}
return false;
}, 2000, 50));
CoreInterceptor.incomingInterceptedFrames.clear();
StompClientConnection conn = StompClientConnectionFactory.createClientConnection(uri);
conn.connect(defUser, defPass);
@ -71,11 +76,11 @@ public class StompWithInterceptorsTest extends StompTestBase {
subFrame.addHeader("ack", "auto");
conn.sendFrame(subFrame);
assertEquals(0, MyCoreInterceptor.incomingInterceptedFrames.size());
assertEquals(0, CoreInterceptor.incomingInterceptedFrames.size());
sendJmsMessage(getName());
// Something was supposed to be called on sendMessages
assertTrue("core interceptor is not working", MyCoreInterceptor.incomingInterceptedFrames.size() > 0);
assertTrue("core interceptor is not working", CoreInterceptor.incomingInterceptedFrames.size() > 0);
conn.receiveFrame(10000);
@ -84,83 +89,68 @@ public class StompWithInterceptorsTest extends StompTestBase {
frame.setBody("Hello World");
conn.sendFrame(frame);
assertTrue(Wait.waitFor(() -> OutgoingStompInterceptor.interceptedFrames.size() == 3, 2000, 50));
conn.disconnect();
assertTrue(Wait.waitFor(() -> IncomingStompInterceptor.interceptedFrames.size() == 4, 2000, 50));
List<String> incomingCommands = new ArrayList<>(4);
incomingCommands.add("CONNECT");
incomingCommands.add("SUBSCRIBE");
incomingCommands.add("SEND");
incomingCommands.add("DISCONNECT");
for (int i = 0; i < IncomingStompInterceptor.interceptedFrames.size(); i++) {
Assert.assertEquals(incomingCommands.get(i), IncomingStompInterceptor.interceptedFrames.get(i).getCommand());
Assert.assertEquals("incomingInterceptedVal", IncomingStompInterceptor.interceptedFrames.get(i).getHeader("incomingInterceptedProp"));
}
List<String> outgoingCommands = new ArrayList<>(3);
outgoingCommands.add("CONNECTED");
outgoingCommands.add("MESSAGE");
outgoingCommands.add("MESSAGE");
long timeout = System.currentTimeMillis() + 1000;
// Things are async, giving some time to things arrive before we actually assert
while (MyIncomingStompFrameInterceptor.incomingInterceptedFrames.size() < 4 &&
MyOutgoingStompFrameInterceptor.outgoingInterceptedFrames.size() < 3 &&
timeout > System.currentTimeMillis()) {
Thread.sleep(10);
for (int i = 0; i < OutgoingStompInterceptor.interceptedFrames.size(); i++) {
Assert.assertEquals(outgoingCommands.get(i), OutgoingStompInterceptor.interceptedFrames.get(i).getCommand());
}
Wait.waitFor(() -> {
return MyIncomingStompFrameInterceptor.incomingInterceptedFrames.size() == 4;
});
Assert.assertEquals(4, MyIncomingStompFrameInterceptor.incomingInterceptedFrames.size());
Wait.waitFor(() -> {
return MyOutgoingStompFrameInterceptor.outgoingInterceptedFrames.size() == 3;
});
Assert.assertEquals(3, MyOutgoingStompFrameInterceptor.outgoingInterceptedFrames.size());
for (int i = 0; i < MyIncomingStompFrameInterceptor.incomingInterceptedFrames.size(); i++) {
Assert.assertEquals(incomingCommands.get(i), MyIncomingStompFrameInterceptor.incomingInterceptedFrames.get(i).getCommand());
Assert.assertEquals("incomingInterceptedVal", MyIncomingStompFrameInterceptor.incomingInterceptedFrames.get(i).getHeader("incomingInterceptedProp"));
}
for (int i = 0; i < MyOutgoingStompFrameInterceptor.outgoingInterceptedFrames.size(); i++) {
Assert.assertEquals(outgoingCommands.get(i), MyOutgoingStompFrameInterceptor.outgoingInterceptedFrames.get(i).getCommand());
}
Assert.assertEquals("incomingInterceptedVal", MyOutgoingStompFrameInterceptor.outgoingInterceptedFrames.get(2).getHeader("incomingInterceptedProp"));
Assert.assertEquals("outgoingInterceptedVal", MyOutgoingStompFrameInterceptor.outgoingInterceptedFrames.get(2).getHeader("outgoingInterceptedProp"));
Assert.assertEquals("incomingInterceptedVal", OutgoingStompInterceptor.interceptedFrames.get(2).getHeader("incomingInterceptedProp"));
Assert.assertEquals("outgoingInterceptedVal", OutgoingStompInterceptor.interceptedFrames.get(2).getHeader("outgoingInterceptedProp"));
}
public static class MyCoreInterceptor implements Interceptor {
public static class CoreInterceptor implements Interceptor {
static List<Packet> incomingInterceptedFrames = new ArrayList<>();
@Override
public boolean intercept(Packet packet, RemotingConnection connection) {
IntegrationTestLogger.LOGGER.info("Core intercepted: " + packet);
incomingInterceptedFrames.add(packet);
return true;
}
}
public static class MyIncomingStompFrameInterceptor implements StompFrameInterceptor {
public static class IncomingStompInterceptor implements StompFrameInterceptor {
static List<StompFrame> incomingInterceptedFrames = new ArrayList<>();
static List<StompFrame> interceptedFrames = Collections.synchronizedList(new ArrayList<>());
@Override
public boolean intercept(StompFrame stompFrame, RemotingConnection connection) {
incomingInterceptedFrames.add(stompFrame);
interceptedFrames.add(stompFrame);
stompFrame.addHeader("incomingInterceptedProp", "incomingInterceptedVal");
return true;
}
}
public static class MyOutgoingStompFrameInterceptor implements StompFrameInterceptor {
public static class OutgoingStompInterceptor implements StompFrameInterceptor {
static List<StompFrame> outgoingInterceptedFrames = new ArrayList<>();
static List<StompFrame> interceptedFrames = Collections.synchronizedList(new ArrayList<>());
@Override
public boolean intercept(StompFrame stompFrame, RemotingConnection connection) {
outgoingInterceptedFrames.add(stompFrame);
interceptedFrames.add(stompFrame);
stompFrame.addHeader("outgoingInterceptedProp", "outgoingInterceptedVal");
return true;
}
}
}
}

View File

@ -44,6 +44,8 @@
<security-settings>
<security-setting match="#">
<permission type="createAddress" roles="guest,def"/>
<permission type="deleteAddress" roles="guest,def"/>
<permission type="createDurableQueue" roles="guest,def"/>
<permission type="deleteDurableQueue" roles="guest,def"/>
<permission type="createNonDurableQueue" roles="guest,def"/>