How to use activemq wildcards for sending messages - activemq

I try to send message to multiple queues according this documentation ActiveMQ Wildcards. The idea is to send message to PRICE.> queue and receive them in queues PRICE.STOCK.NASDAQ.ORCL and PRICE.STOCK.NYSE.IBM (queues are created). But instead of forwarding messages to PRICE.STOCK.NASDAQ.ORCL and PRICE.STOCK.NYSE.IBM activemq create new queue PRICE.> that become this message.
I tried to send message with activemq admin tool (send mask) and spring boot application. Behavior is the same - message is placed in new created queue PRICE.>.Activemq was not additionally configured, I'm using configuration provided with activemq 5.15.7.

The feature is only supported for subscribers, you need to send to a specific named destination when publishing a message. You can use the Virtual Destinations feature of ActiveMQ to define a target destination that forwards to some defined set.

Related

How to create a topic exchange in Qpid JMS for ActiveMQ like RabbitMQ?

I've got a Java application that uses RabbitMQ. This application creates a TOPIC exchange and pushes messages to the TOPIC with its own routing key. From this way if I want the data from any application I create a queue binding with the exchange TOPIC and the routing key I want to.
I want to do the same thing by using a Java application with Qpid JMS as the client and ActiveMQ as the server. The information says it's possible, but I don't know how. I cannot found a specific example seems to RabbitMQ. I can create queues but I don't know how to create the exchange and the binding. What steps should I follow to achieve it?
You might consider using ActiveMQ Artemis instead of ActiveMQ 5.x as the address model of Artemis is much more similar to RabbitMQ's than 5.x's address model (which is more JMS-centric).
As far as JMS goes I think what you need is:
A topic. This is analogous to the "exchange" from RabbitMQ. Any message sent to a JMS topic is delivered to every subscriber. It's basic publish/subscribe semantics.
A topic subscriber with a selector. As noted in #1, every subscriber on a topic will get any message sent to that topic, but a JMS "selector" can be used to filter messages similar to the routing key in RabbitMQ.
An agreed-upon key for a message property. In order to create a viable selector for the topic subscriber the producer and the subscriber must agree upon the property key to filter on.
If each subscription is going to have lots of messages and those messages need to be shared among multiple subscribers/consumers (e.g. for load-balancing/distribution) then you will need to use a JMS "shared subscription." However, shared subscriptions are only part of JMS 2 and only ActiveMQ Artemis implements JMS 2. You can't use ActiveMQ 5.x with JMS shared subscriptions as it only supports JMS 1.1.
Both ActiveMQ 5.x and ActiveMQ Artemis create server-side resources (e.g. topics, queues, etc.) on-demand by default so all you need to do is write your JMS application.

How to copy messages to another queue on RabbitMQ?

Using RabbitMQ as broker, I would like to copy all the messages from one queue to another queue for test/debug purpose. What's the simplest way via RabbitMQ web management console / cli?
P.S. Under web console for specified queue, I could only Move messages instead of Copy messages to new queue.
When I need to perform such tasks, I do as follows (assuming you want to copy all of the messages from your reference queue):
create a fanout exchange or use the default one (amq.fanout) if he isn't bound to any queue
bind the reference queue to it
bind the "duplicate" queue to it
configure a shovel to send all the messages in the reference queue to the exchange you bound to both queues, with auto-delete set to "After initial length transferred"
But it does mean that if messages arrived to the reference queue through it's normal flow, they will end up at the top of the queue, with the "copied" messages behind/mixed with them
just create another queue with the same routing key if the exchange is a direct exchange
Go to http://localhost:15672/#/queues
Create vhost (vhost=testhost)
Create two queue using vhost( Test1, Test2)
Create exchange Test_exchange: http://localhost:15672/#/exchanges
Bind these queue(Test1 & Test2) on Test_exchange
Install shovel
sudo rabbitmq-plugins enable rabbitmq_shovel
sudo rabbitmq-plugins enable rabbitmq_shovel_management
Add shovel using admin shovel tab
URI: amqp://{user}:{pass}#{localhost}:5672/vhost (this is for reference queue which u want to create copy, vhost if it has)
source
Destination URI: amqp://user:pass#localhost:5672/Test_exchnage
Queue Name: “Test_exchange”
You can can send msg to your reference queue.
There's a commercial tool, QueueExplorer (disclaimer - I'm the author) which allows you to copy messages, among other things.

RabbitMQ Manual Retry

How can manual retry work in RabbitMQ after a message has been put onto dead letter queue?
Does RabbitMQ provide an user interface through which you can do this? I assume here that RabbitMQ console does not provide you this capability.
The Rabbit MQ management interface would let you do this crudely, you can go into the deadletter queue, 'get' the message then copy the content. Go to the queue you want to retry the message on and 'publish' it directly to that queue.
Alternatively, you can enable the shovel plugin which allows you to move messages from one queue to another. The RabbitMQ Management plugin directly contains instructions on how to do this.
You can write a consumer / producer using a number of various client libraries. For python a popular library is pika (https://pypi.python.org/pypi/pika).
The script can consume all the messages in a queue, then publish them to another queue.

move hornetq message from a queue to another without reading it out

We have a use case where we would like to get a certain messages in a queue distributed into other queues after we browse the queue and get the message properties. Can that be done with JMS API for hornetq or should we use a JMX client as that seems to be a possible operation in jvisualvm?
I don't know if I understand You correctly but if You would like to copy from one queue to another only filtered messages You can use bridge.
http://docs.jboss.org/hornetq/2.3.0.CR2/docs/user-manual/html/core-bridges.html
In bridge configuration You can define which messages should be copied from one queue to another
It seems that org.hornetq.api.jms.management.JMSQueueControl from the HornetQ Management API will do the trick. I was hoping for some generic JMS API that would allow that as well but this will work.

Stomp ActiveMQ questions

I am new to Stomp ActiveMQ. I want to create a login from an android client and I don't know how to use ActiveMq. I\ve installed active mq, configured stomp and run the stompexample.
1. I have an error when running activemq from command line if I add in in the activemq.xml the following line:
<transportConnector name="stomp+nio" uri="stomp+nio://localhost:61612"/>
<transportConnector name="stomp+ssl" uri="stomp+ssl://localhost:61612"/>
Can someone please explain what is with tx1 and tx2? Is there a way to send on the queue a message to a specific client? how?
connection.connect("system", "manager");
connection.begin("tx1");
connection.send("/queue/test", "message1");
connection.send("/queue/test", "message2");
connection.commit("tx1");
connection.subscribe("/queue/test", Subscribe.AckModeValues.CLIENT);
connection.begin("tx2");
StompFrame message = connection.receive();
System.out.println(message.getBody());
connection.ack(message, "tx2");
message = connection.receive();
System.out.println(message.getBody());
connection.ack(message, "tx2");
connection.commit("tx2");
connection.disconnect();
Can someone please tell me how to create an application that sends on a queue a text containing username, password and receives an answer if the register was successful?
You need to configure the transport connectors with different port numbers, they can't both share port 61612. Your configure is create a Stomp NIO connector and a different Stomp SSL Connector.
You can't send messages to a distinct client, you just place them on a Queue and if there is a client subscribed it will get the message, that's the nature of Queue based messaging. The TX1 TX2 stuff is sending the messages within a transaction.
Recommend you take some time to read up of JMS Messaging, the Stomp spec and some other messaging based tutorials.