Skip to content

Instantly share code, notes, and snippets.

@tobias

tobias/*.txt Secret

Created November 9, 2015 20:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobias/d42f6133af1560318c4c to your computer and use it in GitHub Desktop.
Save tobias/d42f6133af1560318c4c to your computer and use it in GitHub Desktop.
modified messaging/api/src/main/java/org/wildfly/swarm/messaging/MessagingFraction.java
@@ -32,11 +32,24 @@ public class MessagingFraction extends MessagingActiveMQ<MessagingFraction> impl
}
public MessagingFraction defaultServer() {
- if (this.defaultServer == null) {
- this.defaultServer = server("default", EnhancedServer::enableInVm);
+ if (getOrCreateDefaultServer() != null) {
+ server("default", EnhancedServer::enableInVm);
}
- return this.defaultServer;
+ return this;
+ }
+
+ public MessagingFraction defaultServer(EnhancedServerConsumer config) {
+ config.accept(getOrCreateDefaultServer());
+
+ return this;
+ }
+
+ private EnhancedServer getOrCreateDefaultServer() {
+ return (EnhancedServer)subresources().servers().stream()
+ .filter(s -> "default".equals(s.getKey()))
+ .findFirst()
+ .orElse(null);
}
public MessagingFraction server(String childKey, EnhancedServerConsumer consumer) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment