Skip to content
Browse files

Updated copyright and java packages

  • Loading branch information...
1 parent f67ad4d commit 66c97c4f689250174f8404297f7824f80cb36fd3 @scranton scranton committed with scranton Mar 17, 2013
View
2 NOTICE
@@ -1 +1 @@
-Copyright 2012 FuseSource
+Copyright Red Hat, Inc.
View
46 README.md
@@ -1,46 +1,51 @@
External MQ-Fabric Client Demo
==============================
-This project shows how to connect to JBoss A-MQ message brokers running in Fuse Fabric from JMS clients running outside of
-Fuse Fabric (i.e. when the JMS client is not running within a Fabric-enabled Fuse ESB container).
+This project shows how to connect to JBoss A-MQ message brokers running in Fuse
+Fabric from JMS clients running outside of Fuse Fabric (i.e. when the JMS client
+is not running within a Fabric-enabled Fuse ESB container).
The Getting Started with ActiveMQ project uses broker URL's like this:
failover:(tcp://host1:port1,tcp://host2:port2)
-which are replaced in this project with values like this (that also handle failover):
+which are replaced in this project with values like this (that also handle
+failover):
discovery:(fabric:broker-group-name)
-In addition to changing the broker URL's, two other changes are needed to support fabric discovery: a "zookeeper.url"
-System property needs to be set in the environment, and a few fabric libraries must be added to the classpath.
+In addition to changing the broker URL's, two other changes are needed to
+support fabric discovery: a "zookeeper.url" System property needs to be set in
+the environment, and a few fabric libraries must be added to the classpath.
Setting the zookeeper.url
-------------------------
-On a typical developer machine, with Fuse Management Console running locally, the zookeeper.url System property should
-be set to the URL of the Fuse Fabric's Zookeeper instance, which defaults to localhost:2181. One can simply append the
+On a typical developer machine, with Fuse Management Console running locally,
+the zookeeper.url System property should be set to the URL of the Fuse Fabric's
+Zookeeper instance, which defaults to localhost:2181. One can simply append the
property to the startup command line like this:
-Dzookeeper.url=localhost:2181
-or add the following to the maven profile configuration, as is done in this project.
+or add the following to the maven profile configuration, as is done in this
+project.
<systemProperty>
<key>zookeeper.url</key>
<value>localhost:2181</value>
</systemProperty>
-When a distributed fabric registry is used (i.e. a Zookeeper ensemble) the zookeeper.url property should be set to a
-comma delimited list, like this:
+When a distributed fabric registry is used (i.e. a Zookeeper ensemble) the
+zookeeper.url property should be set to a comma delimited list, like this:
-Dzookeeper.url=london:2182,seattle:2181,portland:2181
Adding the fabric libraries
----------------------------------
-These are the dependencies added to the maven project to support the fabric discovery protocol (see the pom.xml for
-version info):
+These are the dependencies added to the maven project to support the fabric
+discovery protocol (see the pom.xml for version info):
<dependency>
<groupId>org.jboss.amq</groupId>
@@ -76,8 +81,7 @@ Running the example against a fabric-based network of brokers
-------------------------------------------------------------
Start a fabric-based network of fault-tolerant (master/slave) brokers.
-For instructions on how to configure and deploy such a network, see
-the
+For instructions on how to configure and deploy such a network, see the
[fabric-ha-setup.md](https://github.com/FuseByExample/external-mq-fabric-client/blob/master/fabric-ha-setup.md).
This configuration features two broker groups networked together,
@@ -93,7 +97,8 @@ To start the consumer open a shell, change to the project root and run the comma
> mvn -e -P consumer-west
-After the consumer is running, open another shell, change to the project root and run the command:
+After the consumer is running, open another shell, change to the project root
+and run the command:
> mvn -e -P producer-east
@@ -106,12 +111,15 @@ and the consumer connected using the URL:
discovery:(fabric:mq-west)
<!--
- Another way to figure out which container is currently the master is to inspect the logs:
+ Another way to figure out which container is currently the master is to
+ inspect the logs:
cat instances/MQ-East1/data/log/karaf.log | grep mq-fabric
-->
After the example is up and running and you see JMS messages being logged to the
-consumer's console, kill the master broker on the east. You can use the `cluster-list` command in the karaf to find out which container is currently the master. For example:
+consumer's console, kill the master broker on the east. You can use the
+`cluster-list` command in the karaf to find out which container is currently
+the master. For example:
JBossA-MQ:karaf@root> cluster-list
[cluster] [masters] [slaves] [services]
@@ -136,5 +144,5 @@ messages, with console output like this:
Sending to destination: queue://fabric.simple this text: '27. message sent
...
-Then kill the container host the west container and observe similar failover and reconnection by the consumer.
-
+Then kill the container host the west container and observe similar failover and
+reconnection by the consumer.
View
19 fabric-ha-setup.md
@@ -1,7 +1,7 @@
# Deploying Complex JBoss A-MQ Networks
This document provides details on how to configure and deploy a network
-of JBoss A-MQ master/slave networked brokers. We will use the Fuse
+of JBoss A-MQ master/slave networked brokers. We will use the Fuse
Management Console (FMC) to simplify configuring and deploying the
configuration to multiple broker JVMs.
@@ -12,7 +12,7 @@ terminal session. Install the FMC by running:
fabric:create -p fmc
It will prompt you to create an admin user if you had not already
-defined one in `etc/users.properties`. The rest of this document
+defined one in `etc/users.properties`. The rest of this document
will assume you have set the user/password combination to admin/admin.
Keep the terminal session running, and connect to
@@ -63,13 +63,19 @@ with a master/slave broker pair identified with the group name
mq-create --group mq-west --networks mq-east --networks-username admin --networks-password admin --assign-container MQ-West1,MQ-West2 mq-west-broker
-At this point, our network of brokers -- four instances of JBoss A-MQ, each running in its own container, networked together and with failover -- is up and running!
+At this point, our network of brokers -- four instances of JBoss A-MQ, each
+running in its own container, networked together and with failover -- is up and]
+running!
-To verify if everything is working properly lets test running some messages over the new deployment. We can use the mq-client.jar that's used to verify a standalone server.
+To verify if everything is working properly lets test running some messages over
+the new deployment. We can use the mq-client.jar that's used to verify a
+standalone server.
-<!-- NOTE: You need an jbos-a-amq more recent than the 014 build for the following to work. -->
+<!-- NOTE: You need an jboss-a-amq more recent than the 014 build for the following to work. -->
-You can use the `cluster-list` command to see the status of the cluster and find out which containers were elected to be the masters and which are assigned to the slaves. Example:
+You can use the `cluster-list` command to see the status of the cluster and find
+out which containers were elected to be the masters and which are assigned to
+the slaves. Example:
JBossA-MQ:karaf@root> cluster-list
[cluster] [masters] [slaves] [services]
@@ -86,4 +92,3 @@ First lets start a consumer running against a broker running in the 'mq-west' gr
Then lets start a producer running against a broker running in the 'mq-east' group:
java -jar extras/mq-client.jar producer --user admin --password admin --brokerUrl 'discovery:(fabric:mq-east)'
-
View
14 pom.xml
@@ -1,6 +1,6 @@
<!--
- ~ Copyright (C) FuseSource, Inc.
- ~ http://fusesource.com
+ ~ Copyright (C) Red Hat, Inc.
+ ~ http://www.redhat.com
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
@@ -20,9 +20,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>com.fusesource.examples</groupId>
- <artifactId>external-mq-fabric-client-demo</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <groupId>org.fusebyexample</groupId>
+ <artifactId>external-mq-fabric-client</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
<name>External MQ-Fabric Client Demo</name>
@@ -141,7 +141,7 @@
<goal>java</goal>
</goals>
<configuration>
- <mainClass>com.fusesource.examples.activemq.SimpleConsumer</mainClass>
+ <mainClass>org.fusebyexample.external_mq_fabric_client.simple.SimpleConsumer</mainClass>
<systemProperties>
<systemProperty>
<key>zookeeper.url</key>
@@ -186,7 +186,7 @@
<goal>java</goal>
</goals>
<configuration>
- <mainClass>com.fusesource.examples.activemq.SimpleProducer</mainClass>
+ <mainClass>org.fusebyexample.external_mq_fabric_client.simple.SimpleProducer</mainClass>
<systemProperties>
<systemProperty>
<key>zookeeper.url</key>
View
50 ...rce/examples/activemq/SimpleConsumer.java → ..._fabric_client/simple/SimpleConsumer.java
@@ -1,6 +1,6 @@
/*
- * Copyright (C) FuseSource, Inc.
- * http://fusesource.com
+ * Copyright (C) Red Hat, Inc.
+ * http://www.redhat.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,25 +15,17 @@
* limitations under the License.
*/
-package com.fusesource.examples.activemq;
+package org.fusebyexample.external_mq_fabric_client.simple;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageConsumer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
+import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class SimpleConsumer {
-
- private static final Log LOG = LogFactory.getLog(SimpleConsumer.class);
+ private static final Logger LOG = LoggerFactory.getLogger(SimpleConsumer.class);
private static final Boolean NON_TRANSACTED = false;
private static final String CONNECTION_FACTORY_NAME = "myJmsFactory";
@@ -42,14 +34,14 @@
private static final String DEFAULT_BROKER_URL = "discovery:(fabric:default)";
public static void main(String args[]) {
-
- String brokerUrl = System.getProperty("java.naming.provider.url");
- brokerUrl = brokerUrl != null ? brokerUrl : DEFAULT_BROKER_URL;
- LOG.info("******************************");
- LOG.info("Connecting to Fuse MQ Broker using URL: " + brokerUrl);
- LOG.info("******************************");
-
- Connection connection = null;
+ final String brokerUrl = System.getProperty("java.naming.provider.url",
+ DEFAULT_BROKER_URL);
+
+ LOG.info("******************************");
+ LOG.info("Connecting to JBoss A-MQ Broker using URL: {}", brokerUrl);
+ LOG.info("******************************");
+
+ Connection connection = null;
try {
// JNDI lookup of JMS Connection Factory and JMS Destination
@@ -65,17 +57,19 @@ public static void main(String args[]) {
Session session = connection.createSession(NON_TRANSACTED, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(destination);
-
- LOG.info("Start consuming messages from " + destination.toString() + " with " + MESSAGE_TIMEOUT_MILLISECONDS + "ms timeout");
+
+ LOG.info("Start consuming messages from {} with {}ms timeout",
+ destination, MESSAGE_TIMEOUT_MILLISECONDS);
// Synchronous message consumer
int i = 1;
while (true) {
Message message = consumer.receive(MESSAGE_TIMEOUT_MILLISECONDS);
if (message != null) {
+ i++;
if (message instanceof TextMessage) {
String text = ((TextMessage) message).getText();
- LOG.info("Got " + (i++) + ". message: " + text);
+ LOG.info("Got {}. message: {}", i, text);
}
} else {
break;
@@ -85,7 +79,7 @@ public static void main(String args[]) {
consumer.close();
session.close();
} catch (Throwable t) {
- LOG.error(t);
+ LOG.error("Error in Simple Consumer", t);
} finally {
// Cleanup code
// In general, you should always close producers, consumers,
@@ -96,7 +90,7 @@ public static void main(String args[]) {
try {
connection.close();
} catch (JMSException e) {
- LOG.error(e);
+ LOG.error("Error closing connection", e);
}
}
}
View
38 ...rce/examples/activemq/SimpleProducer.java → ..._fabric_client/simple/SimpleProducer.java
@@ -1,6 +1,6 @@
/*
- * Copyright (C) FuseSource, Inc.
- * http://fusesource.com
+ * Copyright (C) Red Hat, Inc.
+ * http://www.redhat.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,24 +15,17 @@
* limitations under the License.
*/
-package com.fusesource.examples.activemq;
+package org.fusebyexample.external_mq_fabric_client.simple;
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.MessageProducer;
-import javax.jms.Session;
-import javax.jms.TextMessage;
+import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class SimpleProducer {
-
- private static final Log LOG = LogFactory.getLog(SimpleProducer.class);
+ private static final Logger LOG = LoggerFactory.getLogger(SimpleProducer.class);
private static final Boolean NON_TRANSACTED = false;
private static final long MESSAGE_TIME_TO_LIVE_MILLISECONDS = 0;
@@ -43,13 +36,13 @@
private static final String DEFAULT_BROKER_URL = "discovery:(fabric:default)";
public static void main(String args[]) {
-
- String brokerUrl = System.getProperty("java.naming.provider.url");
- brokerUrl = brokerUrl != null ? brokerUrl : DEFAULT_BROKER_URL;
+ final String brokerUrl = System.getProperty("java.naming.provider.url",
+ DEFAULT_BROKER_URL);
+
LOG.info("******************************");
- LOG.info("Connecting to Fuse MQ Broker using URL: " + brokerUrl);
+ LOG.info("Connecting to Fuse MQ Broker using URL: {}", brokerUrl);
LOG.info("******************************");
-
+
Connection connection = null;
try {
@@ -71,7 +64,8 @@ public static void main(String args[]) {
for (int i = 1; i <= NUM_MESSAGES_TO_BE_SENT; i++) {
TextMessage message = session.createTextMessage(i + ". message sent");
- LOG.info("Sending to destination: " + destination.toString() + " this text: '" + message.getText());
+ LOG.info("Sending to destination: {} this text: {}",
+ destination, message.getText());
producer.send(message);
Thread.sleep(MESSAGE_DELAY_MILLISECONDS);
}
@@ -80,7 +74,7 @@ public static void main(String args[]) {
producer.close();
session.close();
} catch (Throwable t) {
- LOG.error(t);
+ LOG.error("Error sending message", t);
} finally {
// Cleanup code
// In general, you should always close producers, consumers,
@@ -91,7 +85,7 @@ public static void main(String args[]) {
try {
connection.close();
} catch (JMSException e) {
- LOG.error(e);
+ LOG.error("Error closing connection", e);
}
}
}
View
4 src/main/resources/jndi.properties
@@ -1,6 +1,6 @@
#
-# Copyright (C) FuseSource, Inc.
-# http://fusesource.com
+# Copyright (C) Red Hat, Inc.
+# http://www.redhat.com
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
View
4 src/main/resources/log4j.properties
@@ -1,6 +1,6 @@
#
-# Copyright (C) FuseSource, Inc.
-# http://fusesource.com
+# Copyright (C) Red Hat, Inc.
+# http://www.redhat.com
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.

0 comments on commit 66c97c4

Please sign in to comment.
Something went wrong with that request. Please try again.