From f2d02dcda71a41362d44e2c94f57ffca732a093e Mon Sep 17 00:00:00 2001 From: Ken Finnigan Date: Thu, 4 Aug 2016 14:37:47 -0400 Subject: [PATCH] SWARM-587 Unable to connect to JMS remotely 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 --- .../swarm/messaging/EnhancedServer.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/messaging/src/main/java/org/wildfly/swarm/messaging/EnhancedServer.java b/messaging/src/main/java/org/wildfly/swarm/messaging/EnhancedServer.java index 7985b547ea..e5170cd615 100644 --- a/messaging/src/main/java/org/wildfly/swarm/messaging/EnhancedServer.java +++ b/messaging/src/main/java/org/wildfly/swarm/messaging/EnhancedServer.java @@ -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; @@ -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) { @@ -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(); }