Skip to content

Commit

Permalink
removed ActiveMQ support
Browse files Browse the repository at this point in the history
  • Loading branch information
brmeyer committed Feb 18, 2015
1 parent a1e27f0 commit 8ec2d46
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 108 deletions.
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -8,6 +8,5 @@ target
*.versionsBackup
*~
.checkstyle
activemq-data
*.iml
.idea
Expand Up @@ -64,8 +64,6 @@ public class ArtificerConstants {
public static final String ARTIFICER_CONFIG_EVENT_JMS_CONNECTIONFACTORY = "artificer.config.events.jms.connectionfactory"; //$NON-NLS-1$
public static final String ARTIFICER_CONFIG_EVENT_JMS_TOPICS = "artificer.config.events.jms.topics"; //$NON-NLS-1$
public static final String ARTIFICER_CONFIG_EVENT_JMS_QUEUES = "artificer.config.events.jms.queues"; //$NON-NLS-1$
public static final String ARTIFICER_CONFIG_EVENT_JMS_PORT = "artificer.config.events.jms.embedded-activemq-port"; //$NON-NLS-1$
public static final String ARTIFICER_CONFIG_EVENT_JMS_URL = "artificer.config.events.jms.activemq-url"; //$NON-NLS-1$
public static final String ARTIFICER_CONFIG_EVENT_JMS_USER = "artificer.config.events.jms.user"; //$NON-NLS-1$
public static final String ARTIFICER_CONFIG_EVENT_JMS_PASSWORD = "artificer.config.events.jms.password"; //$NON-NLS-1$

Expand Down
Expand Up @@ -110,7 +110,6 @@ protected void preConfig() {
System.setProperty("overlord.resource-caching.disabled", "true");

System.setProperty("artificer.config.events.jms.topics", "artificer/events/topic");
System.setProperty("artificer.config.events.jms.embedded-activemq-port", "61616");
}

/**
Expand Down
13 changes: 1 addition & 12 deletions doc/guide/en-US/GuideArtificerClients.asciidoc
Expand Up @@ -243,12 +243,9 @@ artificer.config.events.jms.topics = artificer/events/topic
# In addition to the above topics, Artificer will also publish non-expiring events to any JMS queue names (JNDI)
# listed here (comma-delimited).
artificer.config.events.jms.queues =
# If Artificer is running on a non-JavaEE server, or a server where JMS/JNDI is not properly configured, it will start
# an embedded ActiveMQ broker over TCP. The property controls that port.
artificer.config.events.jms.embedded-activemq-port = 61616
----
Artificer supports three JMS environments:
Artificer supports two JMS environments:
* When Artificer is installed in Wildfly/EAP by using our installation script, JMS is configured automatically. The existing
HornetQ configuration is modified to add the default topic, described above, and all necessary credentials.
Expand All @@ -258,14 +255,6 @@ IMPORTANT: In order for HornetQ to work properly, the standalone-full profile mu
* For other EE platforms, Artificer will always attempt to discover a JMS 'ConnectionFactory' and all
configured topics/queues through JNDI. If found, it will simply use that existing framework and setup.
Users can add additional topics/queues to their framework, then add them to 'artificer.properties' (see above).
* If the no existing JMS setup is discovered, Artificer kicks off an embedded ActiveMQ broker over TCP. Then, all
configured topics and queues are created automatically. External clients can connect to this broker in one of two ways:
** The ActiveMQ broker provides a lightweight JNDI implementation and automatically exposes the ConnectionFactory
(literally named "ConnectionFactory"). To expose the topics/queues, the *client app* needs to include a
'jndi.properties' file (and ActiveMQ jars) on the classpath. The contents of that file should contain something like
'topic.[jndi name] = [activemq topic name]'. '[jndi name]' is then available to the client. Other than that
properties file, the client is able to use generic JNDI and JMS without any ActiveMQ APIs.
** Simply use the ActiveMQ libraries and API
Authorization
^^^^^^^^^^^^^
Expand Down
12 changes: 0 additions & 12 deletions events/jms/pom.xml
Expand Up @@ -36,18 +36,6 @@
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-client</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-broker</artifactId>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-kahadb-store</artifactId>
</dependency>

<!-- Logging -->
<dependency>
Expand Down
Expand Up @@ -16,17 +16,14 @@
package org.artificer.events.jms;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerService;
import org.apache.commons.lang.StringUtils;
import org.artificer.events.ArtifactUpdateEvent;
import org.artificer.events.jms.i18n.Messages;
import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.BaseArtifactType;
import org.artificer.common.ArtificerConfig;
import org.artificer.common.ArtificerConstants;
import org.artificer.common.ontology.ArtificerOntology;
import org.artificer.events.ArtifactUpdateEvent;
import org.artificer.events.EventProducer;
import org.artificer.events.OntologyUpdateEvent;
import org.oasis_open.docs.s_ramp.ns.s_ramp_v1.BaseArtifactType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -53,19 +50,6 @@
* correctly configured. We simply use the existing JMS framework and the
* pre-existing topics/queues.
*
* Otherwise, we assume we're on a non-JavaEE server (EAP without
* standalone-full, etc). We then create an embedded ActiveMQ broker over a TCP
* port, then programmatically create all topics/queues. External clients can
* then connect to it in one of two ways: 1.) Simply use the ActiveMQ libs and
* API 2.) The ActiveMQ broker provides a lightweight JNDI implementation and
* automatically exposes the ConnectionFactory (literally named
* "ConnectionFactory"). To expose the topics/queues, the *client app* needs to
* include a jndi.properties file (and ActiveMQ jar) on the classpath. The
* contents should contain something like
* "topic.[jndi name] = [activemq topic name]". [jndi name] is then available to
* the client. Other than that properties file, the client is able to use
* generic JNDI and JMS without any ActiveMQ APIs.
*
* @author Brett Meyer
*/
public class JMSEventProducer implements EventProducer {
Expand Down Expand Up @@ -105,64 +89,27 @@ public void startup() {
queueNames = queueNamesProp.split(","); //$NON-NLS-1$
}

try {
// First, see if a ConnectionFactory and Topic/Queue exists on JNDI. If so, assume JMS is properly
// setup in a Java EE container and simply use it.

ConnectionFactory connectionFactory = (ConnectionFactory) jndiLookup(connectionFactoryName);
connection = connectionFactory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

for (String topicName : topicNames) {
Topic topic = (Topic) jndiLookup(topicName);
destinations.add(topic);
}

for (String queueName : queueNames) {
Queue queue = (Queue) jndiLookup(queueName);
destinations.add(queue);
}
} catch (NamingException e) {
// Otherwise, JMS wasn't setup. Assume we need to start an embedded
// ActiveMQ broker and create the destinations.

String bindAddress = "tcp://localhost:" //$NON-NLS-1$
+ ArtificerConfig.getConfigProperty(ArtificerConstants.ARTIFICER_CONFIG_EVENT_JMS_PORT, "61616"); //$NON-NLS-1$

LOG.warn(Messages.i18n.format("org.artificer.events.jms.embedded_broker", bindAddress)); //$NON-NLS-1$
// See if a ConnectionFactory and Topic/Queue exists on JNDI. If so, assume JMS is properly
// setup in a Java EE container and use it.

session = null;
destinations.clear();
ConnectionFactory connectionFactory = (ConnectionFactory) jndiLookup(connectionFactoryName);
connection = connectionFactory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

BrokerService broker = new BrokerService();
broker.addConnector(bindAddress);
broker.start();
for (String topicName : topicNames) {
Topic topic = (Topic) jndiLookup(topicName);
destinations.add(topic);
}

// Event though we added a TCP connector, above, ActiveMQ also exposes the broker over the "vm"
// protocol. It optimizes performance for connections on the same JVM.
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost"); //$NON-NLS-1$
initActiveMQ(connectionFactory, topicNames, queueNames);
for (String queueName : queueNames) {
Queue queue = (Queue) jndiLookup(queueName);
destinations.add(queue);
}
} catch (Exception e) {
LOG.error(e.getMessage(), e);
}
}
}

private void initActiveMQ(ConnectionFactory connectionFactory, String[] topicNames, String[] queueNames)
throws Exception {
connection = connectionFactory.createConnection();
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

for (String topicName : topicNames) {
destinations.add(session.createTopic(topicName));
}

for (String queueName : queueNames) {
destinations.add(session.createQueue(queueName));
}
}

@Override
public void artifactCreated(BaseArtifactType artifact) {
Expand Down
@@ -1 +0,0 @@
org.artificer.events.jms.embedded_broker=Could not discover "ConnectionFactory" and/or the configured topics/queues over JNDI. Assuming a non-EE environment or that JMS/JNDI isn't configured. Falling back on an embedded ActiveMQ broker, available on {0}
5 changes: 1 addition & 4 deletions installer/src/main/resources/updates/artificer.properties
Expand Up @@ -17,7 +17,4 @@ artificer.config.events.jms.connectionfactory = ConnectionFactory
artificer.config.events.jms.topics = artificer/events/topic
# In addition to the above topics, Artificer will also publish non-expiring events to any JMS queue names (JNDI)
# listed here (comma-delimited).
artificer.config.events.jms.queues =
# If Artificer is running on a non-JavaEE server, or a server where JMS/JNDI is not properly configured, it will start
# an embedded ActiveMQ broker over TCP. The property controls that port.
artificer.config.events.jms.embedded-activemq-port = 61616
artificer.config.events.jms.queues =
5 changes: 0 additions & 5 deletions pom.xml
Expand Up @@ -753,11 +753,6 @@
<artifactId>javax.security.jacc-api</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-kahadb-store</artifactId>
<version>${version.org.apache.activemq}</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
Expand Down
3 changes: 0 additions & 3 deletions test/src/test/resources/jndi.properties

This file was deleted.

0 comments on commit 8ec2d46

Please sign in to comment.