Skip to content
This repository has been archived by the owner on Jun 7, 2021. It is now read-only.

Commit

Permalink
SWARM-587 Unable to connect to JMS remotely
Browse files Browse the repository at this point in the history
MessagingFraction needs to provide a way to activate a RemoteConnectionFactory with HTTP connectors.
As well as the ability to create a topic or queue that will be exposed remotely through the java:/jboss/exported namespace
  • Loading branch information
kenfinnigan committed Aug 4, 2016
1 parent dcd49d1 commit f2d02dc
Showing 1 changed file with 45 additions and 0 deletions.
Expand Up @@ -74,6 +74,15 @@ public EnhancedServer enableClustering() {
return this;
}

public EnhancedServer enableRemote() {
enableHTTPConnections();

connectionFactory(new ConnectionFactory("RemoteConnectionFactory")
.connectors(Collections.singletonList("http-connector"))
.entries("java:/RemoteConnectionFactory", "java:jboss/exported/jms/RemoteConnectionFactory"));
return this;
}

private EnhancedServer enableHTTPConnections() {
if (this.subresources().acceptor(("http-acceptor")) != null) {
return this;
Expand All @@ -99,6 +108,24 @@ public EnhancedServer jmsQueue(String childKey, JMSQueueConsumer config) {
});
}

public EnhancedServer remoteJmsQueue(String childKey) {
remoteJmsQueue(childKey, null);
return this;
}

@SuppressWarnings("unchecked")
public EnhancedServer remoteJmsQueue(String childKey, JMSQueueConsumer config) {
return super.jmsQueue(childKey, (q) -> {
if (config != null) {
config.accept(q);
}
if (q.entries() == null || q.entries().isEmpty()) {
q.entry("java:/jboss/exported/jms/queue/" + childKey);
q.entry("java:/jms/queue/" + childKey);
}
});
}

@SuppressWarnings("unchecked")
@Override
public EnhancedServer jmsTopic(String childKey, JMSTopicConsumer config) {
Expand All @@ -112,5 +139,23 @@ public EnhancedServer jmsTopic(String childKey, JMSTopicConsumer config) {
});
}

public EnhancedServer remoteJmsTopic(String childKey) {
remoteJmsTopic(childKey, null);
return this;
}

@SuppressWarnings("unchecked")
public EnhancedServer remoteJmsTopic(String childKey, JMSTopicConsumer config) {
return super.jmsTopic(childKey, (t) -> {
if (config != null) {
config.accept(t);
}
if (t.entries() == null || t.entries().isEmpty()) {
t.entry("java:/jboss/exported/jms/topic/" + childKey);
t.entry("java:/jms/topic/" + childKey);
}
});
}

private static final AtomicInteger COUNTER = new AtomicInteger();
}

0 comments on commit f2d02dc

Please sign in to comment.