Skip to content

Commit

Permalink
Work with HornetQ 2.3 or 2.4 out-of-container
Browse files Browse the repository at this point in the history
And test against 2.3 as well to ensure that.
  • Loading branch information
tobias committed Jul 30, 2015
1 parent 626b39b commit 456a0d3
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
9 changes: 9 additions & 0 deletions modules/messaging-hornetq/pom.xml
Expand Up @@ -46,6 +46,15 @@

</dependencies>

<profiles>
<profile>
<id>hornetq-2.3</id>
<properties>
<version.hornetq>2.3.25.Final</version.hornetq>
</properties>
</profile>
</profiles>

<build>
<plugins>
<plugin>
Expand Down
Expand Up @@ -29,6 +29,8 @@
import org.slf4j.Logger;

import javax.jms.ConnectionFactory;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
Expand Down Expand Up @@ -116,7 +118,10 @@ protected ConnectionFactory createRemoteConnectionFactory(final Options<CreateCo
hornetQcf.setRetryIntervalMultiplier(options.getDouble(CreateContextOption.RECONNECT_RETRY_INTERVAL_MULTIPLIER));
hornetQcf.setMaxRetryInterval(options.getLong(CreateContextOption.RECONNECT_MAX_RETRY_INTERVAL));

return hornetQcf;
// We have to cast for HornetQ 2.3 - the factory object that is returned is both a HornetQConnectionFactory
// and a javax.jms.ConnectionFactory, but HornetQConnectionFactory doesn't implement j.j.ConnectionFactory.
// With HornetQ 2.4, this cast is redundant.
return (ConnectionFactory)hornetQcf;
}

protected javax.jms.Topic createTopic(String name) throws Exception {
Expand Down Expand Up @@ -162,11 +167,37 @@ protected javax.jms.Queue lookupQueue(String name) {
}

protected void destroyQueue(String name) throws Exception {
this.jmsServerManager().destroyQueue(name, true);
invokeDestroy("destroyQueue", name);
}

protected void destroyTopic(String name) throws Exception {
this.jmsServerManager().destroyTopic(name, true);
invokeDestroy("destroyTopic", name);
}

//HornetQ 2.3 has single-arity destroy functions, 2.4 has double-arity
private void invokeDestroy(String method, String name) {
Class clazz = this.jmsServerManager().getClass();
Method destroy = null;
for (Method each: clazz.getMethods()) {
if (method.equals(each.getName())) {
destroy = each;
break;
}
}

if (destroy == null) {
throw new IllegalStateException(String.format("Class %s has no %s method", clazz, method));
}

try {
if (destroy.getParameterTypes().length == 1) {
destroy.invoke(this.jmsServerManager(), name);
} else {
destroy.invoke(this.jmsServerManager(), name, true);
}
} catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException("Failed to destroy destination " + name, e);
}
}

protected Object lookupJNDI(String jndiName) {
Expand All @@ -179,4 +210,4 @@ protected Object lookupJNDI(String jndiName) {
protected EmbeddedServer server;

private final static Logger log = WunderBoss.logger("org.projectodd.wunderboss.messaging.hornetq");
}
}
8 changes: 7 additions & 1 deletion support/bees-ci-build.sh
Expand Up @@ -30,4 +30,10 @@ mark "Reversioning"
mvn -B versions:set -DnewVersion=1.x.incremental.${BUILD_NUMBER}

mark "Building"
mvn -B -s ${SETTINGS_FILE} -Pbees install deploy
mvn -B -s ${SETTINGS_FILE} install

mark "Testing messaging against HornetQ 2.3"
mvn -B -s ${SETTINGS_FILE} -f modules/messaging-hornetq/pom.xml -P hornetq-2.3 test

mark "Deploying"
mvn -B -s ${SETTINGS_FILE} -Pbees deploy

0 comments on commit 456a0d3

Please sign in to comment.