What would be the simplest way to test if ActiveMQ is functioning properly?
Would it be by putting a message in a queue and remove from the queue?
Say with a programming language like python? Or would there be simpler methods that already do this?
ActiveMQ exposes management functions via JMX which you can use from GUI tools like JVisualVM and JConsole (among others). One of these exposed MBeans provides "health" information (i.e. HealthViewMBean). You can read more about this in the ActiveMQ wiki.
Testing the health of the broker by sending/receiving a message is certainly possible and not terribly difficult. In general, I think the simplest method would be to use the command-line tools available in the ActiveMQ distribution. If you're using Python then you could write a simple application that produces a message and then consumes it using STOMP. A good place to start on that would be here.
Here you go some practical examples on how to do so in ActiveMQ 5:
Via Jolokia REST API (requiring authentication):
curl -u admin:admin -H origin:localhost http://localhost:8161/api/jolokia/read/org.apache.activemq:type=Broker,brokerName=localhost,service=Health/CurrentStatus | grep Good
Or via activemq CLI directly (useful for creating docker health checks):
/opt/activemq/bin/activemq query --objname type=Broker,brokerName=*,service=Health | grep Good
Both were tested using symptoma/activemq:5.17.2 docker image.
Plus: Health check using docker-compose:
services:
activemq:
image: symptoma/activemq:5.17.2
ports:
- "61616:61616"
- "8161:8161"
healthcheck:
test: /opt/activemq/bin/activemq query --objname type=Broker,brokerName=*,service=Health | grep Good
interval: 10s
timeout: 5s
retries: 5
Related
I have application that uses rabbitmq to queue messages for other parts of ecosystem. I would like to do some performance testing and tuning, but just on my part (the program). So I guess I would like to somehow "mock" away the rabbitmq server, but without changes to my application.
Is there something like dummy rabbitmq server that just accepts all messages and throws them away immediately? Or can I configure actual rabbitmq in that way?
I was using local docker image for the performance test. You can run it with the command:
docker run -d -p 8081:15672 rabbitmq:3-management
You can access management gui on localhost:8081, default username and password is guest/guest
After you are done running a performance test you can purge queue. You do that in Queues>your queue>Purge
PS: Port can be anything you want, just change 8081 in the docker command :)
I understand that Test Kitchen follows the sequence
create node > converge cookbook > run tests
What is the best practice to create a test that assumes a strong external dependency?
An example is the Kafka cookbook https://supermarket.chef.io/cookbooks/kafka. As you might know, Kafka is a messaging broker application that depends on Zookeeper, a separate application that is the message hub.
Following proper separation of concerns, the Kafka cookbook does not include Zookeeper - it can be installed in the same host or in a different machine.
However in order to do a simple verification if Kafka is working, (i.e. create a simple message), you need to have a Zookeeper server running.
For example, the test could be running these three commands after installation
# creates a message topic
bin/kafka-create-topic.sh --zookeeper localhost:2181 --replica 1 --partition 1 --topic test
# lists existing message topics
bin/kafka-list-topic.sh --zookeeper localhost:2181
# sends a message to this machine
bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
Using Chefspec, is there a way to stub this external server (the localhost:2181 part above)?
Thank you!
Two parts to the answer: first ChefSpec is used for unit testing, and is unrelated to Test Kitchen and integration testing. Second, you would need to make a minimal test recipe to install a 1-node ZK server and use that for integration testing. Generally you would do this by putting a test cookbook under test/cookbook and then add it to your Berksfile with a path source. You could use a "real" ZK cookbook, or you could use something simpler and more dedicated. Just an example of minimalism for testing, see my MongoDB recipe. You can probably use something similar for ZK in this situation.
Is there a way for a client to get notified about failover events in the Redis cluster? If so, which client library would support this? I am currently using Jedis but have the flexibility to switch to any other Java client.
There are two ways that I can think of to check this, one of them is to grep for master nodes on the cluster, keeping in mind their IDs, if the ports changed for any of them then a failover happened.
$ redis-cli -p {PORT} cluster nodes | grep master
Another way, but it is not as robust of a solution is using the consistency checker ruby script, that will start showing errors in writes as an output, which you can monitor and send notifications depending on it, since that happens when the read server is trying to take its master's role.
Sentinel (http://redis.io/topics/sentinel) has the ability to monitor the cluster member, and send a publish/subscribe notification upon failure. The link contains a more in-depth explanation and tutorial.
When I was trying to display rabbitmq queue details as follows, It display result as follows:
sudo rabbitmqctl list_queues | grep notifications.info
notifications.info 37
Now my question is that how to fetch or view those messages or information contained in notifications.info.
In case you have the admin plugin installed, you can peek inside those messages using the admin UI. Usually available on port 15672 of your rabbitmq host.
You can see if this plugin is installed by running:
rabbitmq-plugins list
Another way to receive messages from the queue is by using one of the many rabbitmq clients. E.g. the RabbitMq java client: https://www.rabbitmq.com/java-client.html. What's your favorite programming language? Chances are that there is a client for you. Here is an overview of available clients: https://www.rabbitmq.com/devtools.html
I'm looking for a client (as in GUI client, not client library) to play with our MQ server and familiarize myself with its semantics. Something that will send and receive messages at the press of a button (or a text command) and maybe even update me about the status of the server queues and messages. Administration would be a bonus. The UI doesn't have to be graphical (i.e. command line clients are fine).
The server will probably run RabbitMQ so anything RabbitMQ-specific is fine, as is ActiveMQ. But I'd rather have a generic AMQP or STOMP tool.
So, does anything of the sort exist?
I know some management and monitoring tools come with both server distributions, but no clients, right?
For Apache ActiveMQ, there is
the web admin console at http://localhost:8161/admin/
the ApacheActiveMQBrowser project on Sourceforge:
An open source project of developing
Message admin gui based tools for
Apache ActiveMQ.
HermesJMS, it does not mention ActiveMQ 5 (only 3 and 4) on the plugin page, but there is an active user forum
The rabbitmq-management plugin that comes with RabbitMQ (and enabled by rabbitmq-plugins enable rabbitmq_management) has a web-based interface that listens on the port 15672 and can do everything you are (I was) asking for.
Check out the BQL RabbitMQ plugin.
It gives you an SQL-style language for AMQP. For instance,
BQL> create exchange myexchange;
ok
BQL> create durable queue 'myqueue'
ok
BQL> select name,messages from queues where 'durable'=true order by name
----------------------
| name | messages |
----------------------
| myqueue | 0 |
Obviously, it's RabbitMQ specific.
If you're willing to do a bit of coding, you could take a look at the examples in the RabbitMQ Java and .NET clients:
Java examples
.NET examples
They're not quite graphical, but trying to understand them forces you to ask the right questions.
It's been a while, but I remember thinking that the best way to familiarize yourself with AMQP is to read the 0-9-1 spec and write some simple programs; in particular, the protocol documentation on that site gives a lot of examples.
Command line tools (written in C) to send and receive AMQP messages: http://github.com/rmt/amqptools