Code Monkey home page Code Monkey logo

a's Introduction

A

A is a JMS testing/admin utility specialized for ActiveMQ.

Used to send, browse and put messages on queues. License Build Status

usage: java -jar a-<version>-with-dependencies.jar [-A] [-a] [-b <arg>]
       [-B <property=value>] [-c <arg>] [-C <arg>] [-d <arg>] [-e <arg>]
       [-E <arg>] [-f <arg>] [-F <arg>] [-g] [-H <property=value>] [-i
       <arg>] [-I <property=value>] [-j] [-J <arg>] [-k <arg>] [-l] [-L
       <property=value>] [-M <arg>] [-n] [-o <arg>] [-O] [-p <arg>] [-P
       <arg>] [-r <arg>] [-R <arg>] [-s <arg>] [-S <arg>] [-t <arg>] [-T]
       [-U <arg>] [-v] [-w <arg>] [-W <arg>] [-x <arg>] [-X <arg>] [-y
       <arg>] [-z <arg>]
 -A,--amqp                     Set protocol to AMQP. Defaults to OpenWire
 -a,--artemis-core             Set protocol to ActiveMQ Artemis Core.
                               Defaults to OpenWire
 -b,--broker <arg>             URL to broker. defaults to:
                               tcp://localhost:61616
 -B <property=value>           use value for given Boolean property. Can
                               be used several times.
 -c,--count <arg>              A number of messages to browse,get,move or
                               put (put will put the same message <count>
                               times). 0 means all messages.
 -C,--copy-queue <arg>         Copy all messages from this to target.
                               Limited by maxBrowsePageSize in broker
                               settings (default 400).
 -d,--durable <arg>            the subscription is durable, specify
                               subscription-name
 -e,--encoding <arg>           Encoding of input file data. Default UTF-8
 -E,--correlation-id <arg>     Set CorrelationID
 -f,--find <arg>               Search for messages in queue with this
                               value in payload. Use with browse.
 -F,--jndi-cf-name <arg>       Specify JNDI name for ConnectionFactory.
                               Defaults to connectionFactory. Use with -J
 -g,--get                      Get a message from destination
 -H <property=value>           use value for given String property. Can be
                               used several times.
 -i,--priority <arg>           sets JMSPriority
 -I <property=value>           use value for given Integer property. Can
                               be used several times.
 -j,--jms-headers              Print JMS headers
 -J,--jndi <arg>               Connect via JNDI. Overrides -b and -A
                               options. Specify context file on classpath
 -k,--clientid <arg>           Specify connection ClientID
 -l,--list-queues              List queues and topics on broker (OpenWire
                               only)
 -L <property=value>           use value for given Long property. Can be
                               used several times.
 -M,--move-queue <arg>         Move all messages from this to target
 -n,--non-persistent           Set message to non persistent.
 -o,--output <arg>             file to write payload to. If multiple
                               messages, a -1.<ext> will be added to the
                               file. BytesMessage will be written as-is,
                               TextMessage will be written in UTF-8
 -O,--openwire                 Set protocol to OpenWire. This is default
                               protocol
 -p,--put <arg>                Put a message. Specify data. if starts with
                               @, a file is assumed and loaded
 -P,--pass <arg>               Password to connect to broker
 -r,--reply-to <arg>           Set reply to destination, i.e. queue:reply
 -R,--read-folder <arg>        Read files in folder and put to queue. Sent
                               files are deleted! Specify path and a
                               filename. Wildcards are supported '*' and
                               '?'. If no path is given, current directory
                               is assumed.
 -s,--selector <arg>           Browse or get with selector
 -S,--transform-script <arg>   JavaScript code (or @path/to/file.js). Used
                               to transform messages with the dump
                               options. Access message in JavaScript by
                               msg.JMSType = 'foobar';
 -t,--type <arg>               Message type to put, [bytes, text, map] -
                               defaults to text
 -T,--no-transaction-support   Set to disable transactions if not
                               supported by platform. I.e. Azure Service
                               Bus. When set to false, the Move option is
                               NOT atomic.
 -U,--user <arg>               Username to connect to broker
 -v,--version                  Show version of A
 -w,--wait <arg>               Time to wait for a message on get or move 
                               operations in milliseconds. Default 100. 
                               0 equals infinity.
 -W,--batch-file <arg>         Line separated batch file. Used with -p to
                               produce one message per line in file. Used
                               together with Script where each batch line
                               can be accessed with variable 'entry'
 -x,--write-dump <arg>         Write a dump of messages to a file. Will
                               preserve metadata and type. Can  be used
                               with transformation option.  Warning! Will
                               consume queue!
 -X,--restore-dump <arg>       Restore a dump of messages in a
                               file,created with -x. Can be used with
                               transformation option.
 -y,--jms-type <arg>           Sets JMSType header
 -z,--ttl <arg>                sets JMSExpiry

A quick note about ActiveMQ maxBrowsePageSize limit

ActiveMQ 5 is limited how many messages can be browsed/read from a queue without consuming them. This is limited by the setting - maxBrowsePageSize in broker, default is 400. This is a server side setting! This makes it impossible to use browse and copy commands for more than 400 or whatever value is configured at a time. Increasing this value may affect broker memory consumption. For other JMS compliant brokers, this limit may not exists or other limits may apply instead.

Examples

Example 1. Put message with payload "foobar" to queue q on local broker:

$a -p "foobar" q

Example 2. Put message with payload of file foo.bar to queue q on local broker, also set a property

$a -p "@foo.bar" -Hfoo=bar q

Example 3. Browse five messages from queue q.

$a -c 5 q

Example 4. Put 100 messages to queue q (for load test etc)

$a -p "foobar" -c 100 q

Example 5. Get message from queue and show JMS headers

$a -g -j q

Example 6. Put file foo.bar as a byte message on queue q

$a -p "@foo.bar" -t bytes q

Example 7. Put file foo.bar as text message on queue q, with encoding EBCDIC CP037 (any charset known on server/JVM should work)

$a -p "@foo.bar" -e CP037 q

Example 8. Read all XML files in a folder input an put them on queue q. Files are deleted afterwards.

$a -R "input/*.xml" q

Example 9. Put file foo.json as map message on queue q

$a -p "@foo.json" -t map q

Example 10. Put a map message on a queue using json format.

$a -p "{\"a\":\"a message tool\"}" -t map q

Example 11. Backup/dump messages on a queue with metadata

$a -x dump.json q

Example 12. Restore dump of messages with metadata to a queue

$a -X dump.json q2

Example 12. Restore and transform messagse

$a -X dump.json -S @transform.js q2

Use AMQP 1.0

A defaults to ActiveMQ default protocol, OpenWire. You can also use AMQP 1.0. In theory, it should work with all AMQP 1.0 compliant brokers. It does not work with older versions of AMQP.

$a -A -b "amqp://guest:guest@localhost:5672" -p "foobar" q

Azure Service Bus

Service Bus supports AMQP 1.0 so it's possible to use A to connect. However, it does not support transactions, so the -T option has to be set to deal with that.

To connect, you will need a "username" and "password". The username will be the "shared access policy name". The password is the URL-encoded key for that policy. These are found in the Azure portal.

Example command to send a message to Azure Service Bus:

$a -A -T -b "amqps://mypolicyname:[email protected]" -p "Test msg" q

A word of warning! There are some features not working with AMQP 1.0 in Service Bus. Some of which are mandatory to support the JMS API fully. This means some of the features of A will not work - or behave strangely.

Use Artemis Core

Use Artemis core protocol (HornetQ) with the -a option.

$a -a -b "tcp://localhost:61616" -p "foobar" q

Please note that this won't auto deploy the queue in current versions of Artemis. Using OpenWire will autodeploy the queue.

Use JNDI to connect

To connect in a protocol agnostic way, you can specify a JNDI file that points out the JMS provider and settings.

Simply create a jndi.properties file "at classpath". Then link to it jusing the -J (--jndi) option. Please name your ConnectionFactory "connectionFactory". Otherwise, the name has to be supplied using the -F (--jndi-cf-name) option.

$a -J jndi.properties -p "foobar" q

This way, you can even connect to non ActiveMQ/AMQP brokers. You simply need to provide a JNDI config and the client at classpath.

Build

If you want to build the project.

$mvn clean install

However, it is probably easiest to simply build a Docker container.

Download

Download the distribution from the latest release. https://github.com/fmtn/a/releases/latest

Install in Unix environment

  1. Unzip distribution somewhere
  2. Make sure the extracted folder is on path.
  3. chmod +x a
  4. Run a from any place.

Install in Windows environment

  1. Unzip distribution somewhere
  2. Make sure the extracted folder is on path.
  3. Run a.bat from any place.

Use with docker

There is a Docker file with the project. You can build a Docker image and use A from Docker.

    docker build -t a:latest .
    docker run --rm a:latest a -p "foobar" q

You can also use prebuilt docker images.

    docker run --rm fmtn/a-util:1.6.0 a -p "foobar" q 

Please note that you need to pass the entire command to the docker run

The default hostname has been replaced with host.docker.internal as the original hostname localhost points to a location within the docker container. If the broker is not on the docker host, the actual broker hostname still needs to be specified as usual. The hostname of the broker may vary depending on the container environment, Kubernetes, Docker Compose, plain vanilla Docker or what have you.

Use SSL

Given you have a truststore and a keystore in JKS format, you can edit your a start script, or run it manually like this. Note that the -Djavax parameters has to come before -jar. This applies to OpenWire connections:

java -Djavax.net.ssl.keyStore=/Users/petter/client.jks -Djavax.net.ssl.keyStorePassword=password -Djavax.net.ssl.trustStore=/Users/petter/truststore.jks -Djavax.net.ssl.trustStorePassword=password -jar a-1.6.0-jar-with-dependencies.jar -b ssl://example.org:61618 MY.QUEUE 

For AMQP based connections, you need to provide the keystore in the URL instead, like this.

java -jar -Djavax.net.debug=ssl:keymanager:sslcontext a-1.6.0-jar-with-dependencies.jar -A -b "amqp://broker:5671?ssl=true&ssl-cert-alias=myalias&trust-store=client.ts&trust-store-password=password&key-store=client.ks&key-store-password=password" -p "foo" bar

Listing queues

Listing queues only works for ActiveMQ 5 brokers with Advisory messages not deactivated. Since the ActiveMQ client get a list of queues async, the functionallity to list queues may not work very well on some systems. Try these things if you think you got bad queue lists for your broker.

  1. Add more wait time. Defaults to 50ms but you may need much more. Try add -w 10000 and check your results.
  2. If you still have problems, try to subscribe to the Advisory manually to check that it works. Something like this: a -g topic://ActiveMQ.Advisory.Queue -c 0 -w 0

Apply transformations

Using the -S command, a JavaScript transformation can be supplied that will run on each message. The purpose of this feature is to deal with poison-messages that has to be fixed "on-the-fly", removing sensitive data from messages before exporting them from production to a development environment, or to generally help during migrations.

The script is used to modifiy the msg variable that will be written or restored.

Example: msg.JMSPriority = 2; to change JMS priority of each message.

The msg.body parameter depends on msg.type. If type is TextMessage, then msg.body is a simple String that can altered in any way. However, if type is BytesMessage, msg.body will be a Base64 encoded byte-array which is not convenient in JavaScript. ObjectMessage bodies are also Base64 encoded, but can't be decoded/encoded. Other message types are not yet implmenteted for dump/restore and transformations.

To deal with a BytesMessage use

msg.encode('Some string', 'UTF-8');

and

var contentAsString = msg.decode('UTF-8');

This can be powerful, for instance, convert TextMessages to BytesMessages:

    // TextMessage to BytesMessage encoded as UTF-8
    msg.type = 'BytesMessage';
    msg.encode(msg.body, 'UTF-8');

or set some message property that is missing

    msg.stringProperties.put('foo', 'bar');

Batch files

If you want to send a large amount of similar messages, where only a small value is alterd. You can use the batch command -W

So, create a file where all those different values are, like id:s, names or whatnot. One entry per line. batch.txt:

    id1
    id2
    id3

Then use a script together with put, like this:

a -p "<xml>PLACEHOLDER</xml>" -S "msg.body=msg.body.replace('PLACEHOLDER',entry);" -W /path/to/batch.txt SOME.QUEUE

will produce three messages on SOME.QUEUE.

    <xml>id1</xml>
    <xml>id2</xml>
    <xml>id3</xml>

Using -W is much faster than invoking A for each message, since it does not require a reconnection per message.

a's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar erwindon avatar johntdyer avatar kalcijs avatar languitar avatar lukaskusterbi avatar northlander avatar nunojesus avatar odevarc avatar orrc avatar petternordlander avatar tom-ohare avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

a's Issues

Docker support

It would be useful to have a Docker container to run A from.

Write dump might hang during export

There has been reports of -x operation hanging, consuming the message while not producing the output json. It's not yet known what causes the problem. A warning should be issues that a dump operation cannot rollback if an error occurrs.

Azure support question

In the usage description it says:

Set to disable transactions if not supported by platform. I.e. Azure Service Bus. When set to false, the Move option is NOT atomic.

To be more precise, the "Azure ServiceBus Basic" does not support transactions.
"Azure ServiceBus Standard" does support transactions (and topics).
I did not use "Azure ServiceBus Premium" yet, but that should at least be the same as "Standard".


In the read-me file, Azure ServiceBus is mentioned with:

A word of warning! There are some features not working with AMQP 1.0 in Service Bus. Some of which are mandatory to support the JMS API fully. This means some of the features of A will not work - or behave strangely.

Do you have more details on what "some features" includes?

Move/Copy Queues Inverted

Hi,

Great project!

However, move and copy didn't work as I expected and I think the problem is just a typo (repeated). Both the executeMove and executeCopy method of A.java begin with the 2 statements:

    Queue tq = tsess.createQueue(cmdLine.getArgs()[0]);
    Queue q =  tsess.createQueue(cmdLine.getOptionValue(CMD_MOVE_QUEUE)); // Source

But I think q and tq should be swapped:

    Queue q = tsess.createQueue(cmdLine.getArgs()[0]); // Source
    Queue tq =  tsess.createQueue(cmdLine.getOptionValue(CMD_MOVE_QUEUE)); // Target

Do you agree?

value 0 for --wait does not work with AMQP

Due to a bug in library org.apache.qpid:qpid-amqp-1-0-client-jms:0.32, the value 0 for --wait does not work when using AMQP.
The value 0 is interpreted as no-wait, completely opposite the expected behavior of waiting infinitely.

The bug is already clearly marked in the original source code as a "TODO" change.
see package org.apache.qpid.amqp_1_0.jms.impl, file MessageConsumerImpl.java, line 258.

I see at least 3 solutions for this:

  1. instead, use function receive() (no parameters) when wait=0, that function does not have the above problem; or
  2. fix the bug upstream and later update to the new version of the client library when dependabot warns for it; or
  3. switch to another client library for amqp.

nr 1 is the quickest solution, nr 2 is the best solution.

what is your preference?

Can I transform message by js-file?

Hi. Thanks for this utility!
I try to convert message with command parameter:
-S @transform.js
transform.js contains single row:
msg.stringProperties.set('foo', 'bar');
But result message hasn't this property in web-console. I tried set jms ttl property and many other, but all time cann't see some changes.
Can you describe what I should do for insert properties or jms ttl by using transformation with -S?

Do you need a logo?

Hi Hello I am looking for open source projects to contribute graphical design, I have done several jobs for free in opensource projects, I would like to know if you are interested that I make a logo for this your project ?.

Greetings

Nuno Jesus

ability to get the count in a queue AND/OR know if a queue is empty

It would be nice to have the ability to get the count in a queue AND/OR know if a queue is empty.
A new commuters :
--get_count -N : return integer of count : -1 is queue does not exist
--is_empty -Z : return 1 for empty queue / 0 not empty : -1 is queue does not exist

thank U for your nice work

Command not showing output.

java -jar a-1.4.9-SNAPSHOT-jar-with-dependencies.jar -b tcp://10.70.20.124:24152 -P admin -U admin -l

avax.jms.JMSException: Cannot send, channel has already failed: tcp://10.70.20.124:24152
	at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:72)
	at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1413)
	at org.apache.activemq.ActiveMQConnection.ensureConnectionInfoSent(ActiveMQConnection.java:1478)
	at org.apache.activemq.ActiveMQConnection.createSession(ActiveMQConnection.java:329)
	at co.nordlander.a.A.connect(A.java:378)
	at co.nordlander.a.A.run(A.java:189)
	at co.nordlander.a.A.main(A.java:157)
Caused by: org.apache.activemq.transport.InactivityIOException: Cannot send, channel has already failed: tcp://10.70.20.124:24152
	at org.apache.activemq.transport.AbstractInactivityMonitor.doOnewaySend(AbstractInactivityMonitor.java:328)
	at org.apache.activemq.transport.AbstractInactivityMonitor.oneway(AbstractInactivityMonitor.java:317)
	at org.apache.activemq.transport.TransportFilter.oneway(TransportFilter.java:94)
	at org.apache.activemq.transport.WireFormatNegotiator.oneway(WireFormatNegotiator.java:116)
	at org.apache.activemq.transport.MutexTransport.oneway(MutexTransport.java:68)
	at org.apache.activemq.transport.ResponseCorrelator.asyncRequest(ResponseCorrelator.java:81)
	at org.apache.activemq.transport.ResponseCorrelator.request(ResponseCorrelator.java:86)
	at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1388)

Provide built .jar package for download

Hi,

At datacenters behind firewall it is impossible to download maven and .jar package would be appreciated.

Please, provide a way to download the a.jar package, if possible.

Thanks.

javax.jms.JMSSecurityException: User name [null] or password is invalid.

The command line tool looks great! However I'm facing an error, please refer to below for details.

  • Platform: Windows 10
  • JDK: 1.8.0_172
  • Connecting to ActiveMQ server with SSL enabled.

I ran following command but got error as below.

a -b ssl://amq-dev.api.my.com.au:443 -U admin -p adminpass -l

I also modified a.bat to include the JVM args javax.net.ssl.keyStore and javax.net.ssl.keyStorePassword but the issue persists. In fact I don't need to do this because I have added the cert into default JRE lib\security\cacerts file.

javax.jms.JMSSecurityException: User name [null] or password is invalid.
        at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:52)
        at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1399)
        at org.apache.activemq.ActiveMQConnection.ensureConnectionInfoSent(ActiveMQConnection.java:1478)
        at org.apache.activemq.ActiveMQConnection.createSession(ActiveMQConnection.java:329)
        at co.nordlander.a.A.connect(A.java:383)
        at co.nordlander.a.A.run(A.java:185)
        at co.nordlander.a.A.main(A.java:156)
Caused by: java.lang.SecurityException: User name [null] or password is invalid.
        at org.apache.activemq.security.JaasAuthenticationBroker.authenticate(JaasAuthenticationBroker.java:89)
        at org.apache.activemq.security.JaasAuthenticationBroker.addConnection(JaasAuthenticationBroker.java:68)
        at org.apache.activemq.broker.BrokerFilter.addConnection(BrokerFilter.java:97)
        at org.apache.activemq.broker.MutableBrokerFilter.addConnection(MutableBrokerFilter.java:102)
        at org.apache.activemq.broker.TransportConnection.processAddConnection(TransportConnection.java:842)
        at org.apache.activemq.broker.jmx.ManagedTransportConnection.processAddConnection(ManagedTransportConnection.java:77)
        at org.apache.activemq.command.ConnectionInfo.visit(ConnectionInfo.java:139)
        at org.apache.activemq.broker.TransportConnection.service(TransportConnection.java:326)
        at org.apache.activemq.broker.TransportConnection$1.onCommand(TransportConnection.java:190)
        at org.apache.activemq.transport.MutexTransport.onCommand(MutexTransport.java:50)
        at org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:113)
        at org.apache.activemq.transport.AbstractInactivityMonitor.onCommand(AbstractInactivityMonitor.java:300)
        at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
        at org.apache.activemq.transport.tcp.SslTransport.doConsume(SslTransport.java:102)
        at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:214)
        at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:196)
        at java.lang.Thread.run(Thread.java:748)
Caused by: javax.security.auth.login.FailedLoginException: user name is null
        at org.apache.activemq.jaas.PropertiesLoginModule.login(PropertiesLoginModule.java:84)
        at sun.reflect.GeneratedMethodAccessor119.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at javax.security.auth.login.LoginContext.invoke(LoginContext.java:755)
        at javax.security.auth.login.LoginContext.access$000(LoginContext.java:195)
        at javax.security.auth.login.LoginContext$4.run(LoginContext.java:682)
        at javax.security.auth.login.LoginContext$4.run(LoginContext.java:680)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.login.LoginContext.invokePriv(LoginContext.java:680)
        at javax.security.auth.login.LoginContext.login(LoginContext.java:587)
        at org.apache.activemq.security.JaasAuthenticationBroker.authenticate(JaasAuthenticationBroker.java:84)
        ... 16 more

NPE when displaying message properties that are null

When message contains properties that have null values, NullPointerException is thrown when displaying properties:

-----------------
Message Properties
java.lang.NullPointerException
    at co.nordlander.a.A.outputProperties(A.java:807)
    at co.nordlander.a.A.outputMessage(A.java:611)
    at co.nordlander.a.A.executeGet(A.java:442)
    at co.nordlander.a.A.run(A.java:246)
    at co.nordlander.a.A.main(A.java:122)

add message expiry support

"a" supports priority and persistence settings when sending a message.
Can expiry (aka TTL) also be added?
i.e. apply setJMSExpiration to the message with a given timeout before it is sent.

counting messages

Hi,

is there a method to count number of the messages in the queue via 'a' or this rather should be done with the JMX api or http layer on top of JMX api.

thanks

Setting replyto parameter does not set JMSReplyTo in delivered message

version :
Latest

JVM version (java -version):
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.6+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.6+10, mixed mode)

OS version (uname -a if on a Unix-like system):
Linux segotl2618 3.10.0-957.21.3.el7.x86_64 #1 SMP Fri Jun 14 02:54:29 EDT 2019 x86_64 x86_64 x86_64 GNU/Linux

Description of the problem including expected versus actual behavior:
I am sending a batch of messages.
In documentation, -r should set the JMSMessage replyTo attribute in the outgoing messages. But it doesn't. It is always null when entering the queue. The class MessageDump that is used for copying one object to a JMSMessage does not have a member for replyTo.
(Another thing is that using --reply-to instead of -r will not work at all)

Steps to reproduce:

  1. Create a message file "m.txt" containing one or more messages.
  2. send in the file with
    -p "PLACEHOLDER" -S "msg.body=msg.body.replace('PLACEHOLDER',entry);" -W ./m.txt
    --correlation-id anyID42 -r DEVICE.NOTIFY.RESPONSE
  3. Check that the AMQ got the message anyID42 and verify that the replyTo is null instead of DEVICE.NOTIFY.RESPONSE.

Don't depend on script being in ~/bin

Would be nice if the start script wouldn't depend on the JAR being in ~/bin
I.e. change the script to something like this:

BASEDIR=$(dirname "$0")
+java -jar $BASEDIR/a-*-jar-with-dependencies.jar "$@"

mvn clean install failing on tests for both master and feature/java8

Hello,

First, thanks for such a cool tool! I'm using it for random sorts of automation on our ActiveMQ servers.

When I try to git clone and then mvn clean install, it fails due to:

Tests in error:
testPutTopic(co.nordlander.a.AOpenWireTest)

I'm not sure exactly where to find the specific error -- this is the only thing I can see around the start of the tests:

Running co.nordlander.a.AOpenWireTest

0 messages cleared from queue://TARGET.QUEUE
0 messages cleared from queue://TEST.QUEUE
0 messages cleared from queue://SOURCE.QUEUE
Testing cmd: -b tcp://localhost:61916 -p "test-PLACEHOLDER" -W /tmp/junit7298892113214240993/junit661030776037202266/batch.txt -S "msg.body=msg.body.replace('PLACEHOLDER',entry);" TEST.QUEUE
3 messages sent
Message sent
Operation completed in 230ms (excluding connect)
0 messages cleared from queue://TARGET.QUEUE
0 messages cleared from queue://TEST.QUEUE
0 messages cleared from queue://SOURCE.QUEUE
4 msgs moved from SOURCE.QUEUE to TARGET.QUEUE
Operation completed in 52ms (excluding connect)
0 messages cleared from queue://TARGET.QUEUE
0 messages cleared from queue://TEST.QUEUE
0 messages cleared from queue://SOURCE.QUEUE
Writing 1 messages to dump file /tmp/junit7725678142798527935/junit998083138520055583/dump.json
Failed to write all messages to dump file. Reason: ReferenceError: "dummy" is not defined in at line number 1
Rolling back JMS transaction

Invalid version: 6, could not load org.apache.activemq.openwire.v6.MarshallerFactory

Really excited to try out an amq command line tool but running into a problem. We have ActiveMQ 5.4.x in production. Is there a minimum version of ActiveMQ that is supported? Here's the error:

[root@ewhserver1512 amqclient]# ./a -b tcp://localhost:61616
javax.jms.JMSException: Disposed due to prior exception
	at org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:72)
	at org.apache.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1413)
	at org.apache.activemq.ActiveMQConnection.ensureConnectionInfoSent(ActiveMQConnection.java:1478)
	at org.apache.activemq.ActiveMQConnection.createSession(ActiveMQConnection.java:329)
	at co.nordlander.a.A.connect(A.java:376)
	at co.nordlander.a.A.run(A.java:184)
	at co.nordlander.a.A.main(A.java:155)
Caused by: org.apache.activemq.transport.TransportDisposedIOException: Disposed due to prior exception
	at org.apache.activemq.transport.ResponseCorrelator.onException(ResponseCorrelator.java:125)
	at org.apache.activemq.transport.TransportFilter.onException(TransportFilter.java:114)
	at org.apache.activemq.transport.TransportFilter.onException(TransportFilter.java:114)
	at org.apache.activemq.transport.WireFormatNegotiator.onException(WireFormatNegotiator.java:173)
	at org.apache.activemq.transport.WireFormatNegotiator.negociate(WireFormatNegotiator.java:161)
	at org.apache.activemq.transport.WireFormatNegotiator.onCommand(WireFormatNegotiator.java:123)
	at org.apache.activemq.transport.AbstractInactivityMonitor.onCommand(AbstractInactivityMonitor.java:301)
	at org.apache.activemq.transport.TransportSupport.doConsume(TransportSupport.java:83)
	at org.apache.activemq.transport.tcp.TcpTransport.doRun(TcpTransport.java:233)
	at org.apache.activemq.transport.tcp.TcpTransport.run(TcpTransport.java:215)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Invalid version: 6, could not load org.apache.activemq.openwire.v6.MarshallerFactory
	at org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:46)
	... 7 more
Caused by: java.lang.IllegalArgumentException: Invalid version: 6, could not load org.apache.activemq.openwire.v6.MarshallerFactory
	at org.apache.activemq.openwire.OpenWireFormat.setVersion(OpenWireFormat.java:335)
	at org.apache.activemq.openwire.OpenWireFormat.renegotiateWireFormat(OpenWireFormat.java:614)
	at org.apache.activemq.transport.WireFormatNegotiator.negociate(WireFormatNegotiator.java:145)
	... 6 more
Caused by: java.lang.ClassNotFoundException: org.apache.activemq.openwire.v6.MarshallerFactory
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:348)
	at org.apache.activemq.openwire.OpenWireFormat.setVersion(OpenWireFormat.java:333)
	... 8 more

I'm on Java 8:

[root@ewhserver1512 amqclient]# /usr/bin/java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

And ActiveMQ is definitely running - this is not a new install - as my app uses it successfully (with the localhost:61616 url).

Appreciate your help and happy to provide any additional data if necessary.

SSL

Any way to ignore SSL certificate issues?

Browse Limited to 400 messages?

I recently discovered a fairly large dead letter queue and am trying too output (not dump; yet) the messages to files. When I run java -jar a-1.4.8-jar-with-dependencies.jar -b "ssl://localhost:61617" -U "procellaworkers" -P "dm9YDfSMKEKA0WB7qMcFkjoVKawOkuzw" ActiveMQ.DLQ -c 0 -j -o "messages/dlq" the output stops at 400.

I am concerned that if I do use dump in the future, that it will also be limited to 400.

Minor Issues With Unit Tests

Hi,

Thanks for the new release.

While playing around with it I noticed a few quirks, mainly in regard to the tests.

  1. The tests don't run during the normal maven build because the test class ATestCases doesn't match the maven defaults (Test*, *Test or *TestCase). Maybe that was intentional on your part. If not, the quickest fix is just to change the class name to ATestCase (though that name is a little misleading).
  2. When I first tried to run the tests I had some XML namespace-related errors referring the activemq.xml, specifically the broker tag. In the end, I found that including activemq-all as a test dependency in the pom instead of just activemq-broker made them go away. I'm still not entirely sure what was happening.
  3. In the broker tag in activemq.xml, I guess you meant to specify dataDirectory="target/amqdata" and not dataDirectory="taget/amqdata"
  4. You might choose to set a property for the encoding in the pom (of course, it's up to you):
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

The good news is that from the general, operational testing I've been able to do everything works!

Decrease filesize of binary

The fat-jar is pretty heavy by now. Most of the included jars are probably not needed.. Can it be refactored to include less junk?

Filter consumed messages (-g) with the selector (-s) ?

To cleanup a messy queue, I would like to consume (-g) all messages based on a specific selector.

Here is what I tried:

# Content of my queue:
########################

$ ./a  --broker tcp://test-broker-1:61616  test
-----------------
Message Properties
  event_category: trash
Payload:
{"logLevel":"INFO",
"messageId":"00004",
"serviceName":"auth",
"properties":{
        "inviteeName":"[email protected]",
        "initiatorName":"admin"},
"created":"2017-04-12T13:48:36.368+02:00"}

-----------------
Message Properties
  event_category: can
Payload:
{"logLevel":"INFO",
"messageId":"00004",
"serviceName":"auth",
"properties":{
        "inviteeName":"[email protected]",
        "initiatorName":"admin"},
"created":"2017-04-12T13:48:36.368+02:00"}

-----------------
Message Properties
  event_category: trash
Payload:
{"logLevel":"INFO",
"messageId":"00004",
"serviceName":"auth",
"properties":{
        "inviteeName":"[email protected]",
        "initiatorName":"admin"},
"created":"2017-04-12T13:48:36.368+02:00"}

Operation completed in 30067ms (excluding connect)

# Browse messages with selector
########################

$ ./a  --broker tcp://test-broker-1:61616 -s "event_category='trash'"  test
-----------------
Message Properties
  event_category: trash
Payload:
{"logLevel":"INFO",
"messageId":"00004",
"serviceName":"auth",
"properties":{
        "inviteeName":"[email protected]",
        "initiatorName":"admin"},
"created":"2017-04-12T13:48:36.368+02:00"}

-----------------
Message Properties
  event_category: trash
Payload:
{"logLevel":"INFO",
"messageId":"00004",
"serviceName":"auth",
"properties":{
        "inviteeName":"[email protected]",
        "initiatorName":"admin"},
"created":"2017-04-12T13:48:36.368+02:00"}

Operation completed in 30081ms (excluding connect)

# Trying to get messages with selector
########################

$ ./a  --broker tcp://test-broker-1:61616 -s "event_category='trash'" -g  test
No message received
Operation completed in 125ms (excluding connect)
$ ./a  --broker tcp://test-broker-1:61616 -s "event_category='trash'" -c 5 -g  test
No message received
Operation completed in 114ms (excluding connect)
$ ./a  --broker tcp://test-broker-1:61616 -s "event_category='trash'" -c 0 -g  test
No message received
Operation completed in 96ms (excluding connect)

Since the documentation says:

-s,--selector Browse or get with selector

So now it could be a bug ๐Ÿ› or PEBKAC ๐Ÿ˜Š . In any case, I hope you can help me out here.

Thanks in advance!

SSL Question - keyStore not used

Hi,

the readme states that SSL can be used by using "-Djavax.net.ssl.keyStore" and "-Djavax.net.ssl.trustStore":

java -Djavax.net.ssl.keyStore=/Users/petter/client.jks -Djavax.net.ssl.keyStorePassword=password -Djavax.net.ssl.trustStore=/Users/petter/truststore.jks -Djavax.net.ssl.trustStorePassword=password -jar a-1.6.0-jar-with-dependencies.jar -b ssl://example.org:61618 MY.QUEUE

As I'm working with self signed certs in my setup (2-way-SSL) I need both - a client keyStore and trustStore. While passing both arguments works perfectly fine for the trustStore, it does not work for the keyStore. It seems to me that -Djavax.net.ssl.keyStore is somehow 'ignored', so the keyStore is never used during the TLS/SSL handshake. The result is that the client certificate cannot be found and the handshake is not successful.

Any idea why this happens?

q required at end of command

The following does not work: ./a -p "Testing..." myQueueName. I need to do the following instead: ./a -p "Testing..." myQueueName q. No error message is presented. The command says the message was sent, but it was not.

The following commands result in java exceptions stating the parameter name is unknown:

./a -v
./a -l

But if I do the following they work:

./a -v q
./a -l q

System.exit with status codes

It would be nice to use System.exit with nonzero codes to indicate errors for better integration with shell scripts.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.