ejlp12 / jboss-amq-workshop

JBoss A-MQ Workshop
1 stars 2 forks source link

NOT_AN_ISSUE: Temporary content & images #1

Open ejlp12 opened 9 years ago

ejlp12 commented 9 years ago

LAB 01 – INSTALLING JBOSS A-MQ

If you are starting from scratch, and not on a lab machine, you can continue this lab section with following instructions.

Installing JBoss A-MQ 6.2 is easy. You'll need to unzip the distribution into the target directory. You can get a JBoss A-MQ distribution from http://www.jboss.org/products/amq.

image

If you have Subscription, then you can download from Red Hat Customer Portal: https://access.redhat.com/jbossnetwork/restricted/listSoftware.html?product=jboss.amq&downloadType=distributions&version=6.2.0

image

       $ mkdir Servers
       $ cd Servers
       $ unzip ~/Downloads/jboss-a-mq-6.2.0.redhat-133.zip

This will create a subdirectory named jboss-a-mq-6.2.0.redhat-133.

You will need to edit a couple of configuration files after your first install to setup an administrative username and password.

Edit <JBoss A-MQ Home>/etc/users.properties, and uncomment (remove the leading #) the last line. The format is <username>=<password>,<role>,<role>. For the purposes of this lab, let's use admin as a username and password is admin.

       admin=admin,admin

Go to <JBoss A-MQ Home>/bin directory and Start the A-MQ broker using following command

cd /Servers/jboss-a-mq-6.2.0.redhat-133/bin
./amq

You will get following output and it will prompt you with A-MQ console

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128M; support was removed in 8.0
Please wait, JBoss A-MQ is initializing...
100% [========================================================================]

      _ ____                                __  __  ____
     | |  _ \                    /\        |  \/  |/ __ \
     | | |_) | ___  ___ ___     /  \ ______| \  / | |  | |
 _   | |  _ < / _ \/ __/ __|   / /\ \______| |\/| | |  | |
| |__| | |_) | (_) \__ \__ \  / ____ \     | |  | | |__| |
 \____/|____/ \___/|___/___/ /_/    \_\    |_|  |_|\___\_\

  JBoss A-MQ (6.2.0.redhat-133)
  http://www.redhat.com/products/jbossenterprisemiddleware/amq/

Hit '<tab>' for a list of available commands
and '[cmd] --help' for help on a specific command.

Open a browser to http://localhost:8181 to access the management console

Hit '<ctrl-d>' or 'osgi:shutdown' to shutdown JBoss A-MQ.

JBossA-MQ:karaf@root>

That's it! An install so fast, you don't even have time to get a cup of coffee...

ejlp12 commented 9 years ago

By default, JBoss A-MQ will start in interactive mode, which means it both starts the server, and displays the command Console. There are startup options to refine this, such as ./bin/amq server to just start the server without the Console, and ./bin/amq client to start just the Console that will connect to a locally running server.

ejlp12 commented 9 years ago

LAB 02 – INTERACTING WITH JBOSS A-MQ CONSOLE

Now that we have a running local JBoss A-MQ server, you have a whole new command Console to play with... The JBoss A-MQ container supports an SSHD server that allows you to SSH into your running server to manage it. When you start up JBoss A-MQ, by default, it displays the Console for the instance you just started. You can also use a script to connect to other local and remote instances (check out <JBoss A-MQ Home>/bin/client --help).

This Console supports hundreds of commands to manage your JBoss A- MQ server. The console also supports limited scripting (think simple BASH shell scripts), and command output pipelining (log:display |grep started) – try that in your father's server...

Explore the Shell on your own for a little bit. Hit to display a list of commands (264 and counting). To see the help for any command type its name followed by --help.

Try to give the console following command:

ejlp12 commented 9 years ago

LAB 03 – TESTING JBOSS A-MQ FOR THE FIRST TIME

JBoss A-MQ includes a messaging test client as part of its distribution that helps you validate that everything is working correctly. You can download the client jar library () then put it in the <JBoss A-MQ Home>/extras directory.

To run it we will need another Terminal window. Executing java -jar mq-client.jar will have it list its options.

In messaging systems there are two (2) types of clients: • Producers – who sending messages • Consumers – who receive messages

So let's continue...

Run the two (2) following command in your Terminal. The only difference between the two (2) is the first argument: producer or consumer. If you try to run this in a single Terminal, you need to run the producer version first, as the consumer will wait (block) for messages. You will ultimately want to have, at least, two Terminal windows going, so you might as well do that now...

java -jar mq-client.jar producer --brokerUrl failover://tcp://localhost:61616 --user admin --password admin --destination queue://summit.test --count 10

image

Run Consumer:

java -jar mq-client.jar consumer --brokerUrl failover://tcp://localhost:61616 --user admin --password admin --destination queue://summit.test --count 10

image

The quick version of what the parameters are is:

The connection string uses the Apache ActiveMQ failover transport (failover://prefix) that has the client automatically re-connect when the connection is lost. It is followed by tcp://<hostname>:<port>.

ejlp12 commented 9 years ago

LAB 04 – QUEUES

JBoss A-MQ is a fully compliant JMS 1.1 broker, which means it supports things like JMS Queues. Queues are for point-to-point messaging, that is one and only one consumer will receive any given message. We saw an example of queues in the last lab where we tested a producer and a consumer client against JBoss A-MQ. So now lets see what happens if we have two (2) consumers running...

For this lab, best to have at least four (4) Terminal windows open; Note order of execution is import, so please do the steps below in order

  1. Terminal 1 (A-MQ) – Running JBoss A-MQ – see Lab 01 – Starting the JBoss A-MQ server if you need to re-start A-MQ
  2. Terminal 2 (Consumer1)

    java -jar mq-client.jar consumer --brokerUrl failover://tcp://localhost:61616 --user admin --password admin --destination queue://summit.test --count 50
  3. Terminal 3 (Consumer2)

    java -jar mq-client.jar consumer --brokerUrl failover://tcp://localhost:61616 --user admin --password admin --destination queue://summit.test --count 50
  4. Terminal 4 (Producer)

    java -jar mq-client.jar producer --brokerUrl failover://tcp://localhost:61616 --user admin --password admin --destination queue://summit.test --count 100 --sleep 100

You should see results like the following

[IMAGE]

Notice how in the Consumers, the messages are interleaving, in this case Consumer1 is getting all the odd numbered messages, and Consumer2 is getting all the even numbered message. In messaging this is called Competing Consumers. JBoss A-MQ will, by default, round robin load balance message dispatch across all the consumers on a Queue.

Try some different combinations for producers and consumers on your own. The most important part is ensuring they are all connecting to the same --destination (the JMS specification calls Queues and Topics generically Destinations). You can also increase the delay between message send (--sleep) in the producer if you'd like to try starting a mid-way...

Also try running the producer only, and then the consumer only. You should see A-MQ store the messages in-between. This is a key benefit of JMS Queues in that they allow producers and consumers to communication asynchronously, meaning they don't both have to be running at the same time to receive messages. This can be a big benefit to many systems designs where one system can be done for maintenance, while other systems can continue sending and receiving messages...

ejlp12 commented 9 years ago

LAB 05 – PUBLISH/SUBSCRIBE (TOPICS)

JBoss A-MQ is a fully compliant JMS 1.1 broker, which means it also supports things like JMS Topics. Topics are for publishing messages to all subscribers on a names topic. This is different from Queues, as Queues are 1-to-1 and Topics are 1-to-Many, that is all subscribers to a Topic get a copy of the message.

For this lab, best to have at least four (4) Terminal windows open; Note order of execution is import so please do the steps below in order

  1. Terminal 1 (A-MQ) – Running JBoss A-MQ – see Lab 02 – Starting the JBoss A-MQ server if you need to re-start A-MQ
  2. Terminal 2 (Consumer)

    java -jar mq-client.jar consumer --brokerUrl failover://tcp://localhost:61616 --user admin --password admin --destination topic://summit.test --count 10
  3. Terminal 3 (Consumer)

    java -jar mq-client.jar consumer --brokerUrl failover://tcp://localhost:61616 --user admin --password admin --destination topic://summit.test --count 10
  4. Terminal 4 (Producer)

    java -jar mq-client.jar producer --brokerUrl failover://tcp://localhost:61616 --user admin --password admin --destination topic://summit.test --count 10

You should see results like the following

[IMAGE]

Now this isn't a cut and paste duplicate, you'll see that both consumers received all of the messages sent by the producer.

With a Topic all connected consumers (subscribers) will receive all messages sent by the producers (publishers). The key part is “connected” consumers. A normal Topic consumer only receives messages sent after that consumer connects. This is another big difference from Queues, which will save messages.

Now experiment and try some different combinations. Remember you can add a delay between message sends (--sleep <ms>), and change the number of messages sent or waited for (--count).

ejlp12 commented 9 years ago

LAB 06 – ACTIVEMQ CONFIGURATION

JBoss A-MQ embeds Apache ActiveMQ, which is providing the bulk of the reliable messaging capabilities. ActiveMQ's configuration is primarily driven by a configuration file located by default in <JBoss A-MQ Home>/etc/activemq.xml. This configuration file, combined with some property value substitution at load time, determine how the ActiveMQ server will behave.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:amq="http://activemq.apache.org/schema/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq- core.xsd">
   <!-- Allows us to use system properties and fabric as variables in this configuration file -->
   <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
      <property name="properties">
         <bean class="org.fusesource.mq.fabric.ConfigurationProperties" />
      </property>
   </bean>
   <broker xmlns="http://activemq.apache.org/schema/core" brokerName="${broker-name}" dataDirectory="${data}" start="false">
      <destinationPolicy>
         <policyMap>
            <policyEntries>
               <policyEntry topic="&gt;" producerFlowControl="true">
                  <pendingMessageLimitStrategy>
                     <constantPendingMessageLimitStrategy limit="1000" />
                  </pendingMessageLimitStrategy>
               </policyEntry>
               <policyEntry queue="&gt;" producerFlowControl="true" memoryLimit="1mb" />
            </policyEntries>
         </policyMap>
      </destinationPolicy>
      <managementContext>
         <managementContext createConnector="false" />
      </managementContext>
      <persistenceAdapter>
         <kahaDB directory="${data}/kahadb" />
      </persistenceAdapter>
      <plugins>
         <jaasAuthenticationPlugin configuration="karaf" />
      </plugins>
      <systemUsage>
         <systemUsage>
            <memoryUsage>
               <memoryUsage limit="64 mb" />
            </memoryUsage>
            <storeUsage>
               <storeUsage limit="100 gb" />
            </storeUsage>
            <tempUsage>
               <tempUsage limit="50 gb" />
            </tempUsage>
         </systemUsage>
      </systemUsage>
      <transportConnectors>
         <transportConnector name="openwire" uri="tcp://0.0.0.0:0?maximumConnections=1000" />
      </transportConnectors>
   </broker>
</beans>

Here's a quick overview of the major components of the ActiveMQ configuration file. You can read more about its configuration here – https://access.redhat.com/site/documentation/JBoss_A-MQ/.

First thing you may notice is that its a Spring file; ActiveMQ is configured using dependency injection.

ejlp12 commented 9 years ago

LAB 07 – CONFIGURING FABRIC

JBoss A-MQ includes a technology called Fabric that can help with setting up and managing many instances of JBoss A-MQ (and JBoss Fuse). It provides a centralized configuration management and provisioning capability, and it includes a runtime registry that allows clients to auto-discovery where named groups of instances are (host, port, etc.).

In this lab, we're going to configure the first component of a Fabric deployment, the Fabric controller including the Fabric Management Console.

In the Terminal window that has JBoss A-MQ running (if you need to re-start, look at Lab 02 – Starting the JBoss A-MQ server), type the following command

       fabric:create --clean --zookeeper-password admin --profile fmc

You will see the Console restart (it will re-display the JBoss A-MQ ASCII art). At this point, this instance of JBoss A-MQ has performed a quick change act under the covers.

That's a lot for one little command...

Before I spend a little time explaining what just happened, this would be a good time to stand and say “I am now the master of my own Fabric!”. You're entering a brave new world, don't look back...

The fabric:create command had a few components

Enough with the explanations, for now. Let's go to the next lab, and explore the FMC web GUI...

ejlp12 commented 9 years ago

LAB 08 – EXPLORING FABRIC MANAGEMENT CONSOLE

Now that you are master of your own Fabric (if you aren't, follow the steps in Lab 08 – Configuring Fabric), we should also have at our disposal a web GUI. Open your local web browser and go to http://localhost:8181 and you should see something like this...

image

The login information is what you configured in Lab 01 – Installing JBoss A-MQ (hint: admin/admin). Go ahead and Log In...

Once you’ve logged in, you will be greeted with a welcome screen. Click “Containers” to view your list of containers.

image

There's a lot here, so let me give you the quick summary of the top tab bar so you can explore on your own.

So go explore on your own for a bit, and then in the next lab we'll walk you though a couple of multiple container configurations. If you manage to really break your environment (perhaps having too much fun clicking buttons, eh?), then you can go back to Lab 07 – Configuring Fabric and clean up before the next lab.

ejlp12 commented 8 years ago

image

image

image

image

image

image

image

image