Skip to content

Instantly share code, notes, and snippets.

@ejlp12
Last active March 10, 2017 10:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ejlp12/877fe46edfb86f70171a to your computer and use it in GitHub Desktop.
Save ejlp12/877fe46edfb86f70171a to your computer and use it in GitHub Desktop.

Reference:

Set web-demo (REST interface)

Make sure one of the following repo URL in your setting.xml

  jboss-public-resository (http://repository.jboss.org/nexus/content/repositories/public/, releases=true, snapshots=true),
  jboss-ga-repository (http://maven.repository.redhat.com/techpreview/all, releases=true, snapshots=true),
  redhat-earlyaccess (https://maven.repository.redhat.com/earlyaccess/all, releases=true, snapshots=true),
  repository-apache-org (https://repository.apache.org/content/groups/public/, releases=true, snapshots=false),

Get the artifact to your local maven repo:

mvn dependency:get  -DgroupId=org.apache.activemq -DartifactId=activemq-web-demo -Dversion=5.11.0.redhat-621050 -Dtransitive=false

start A-MQ

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

Install the web-demo using following command in Karaf console:

install -s war:mvn:org.apache.activemq/activemq-web-demo/5.11.0.redhat-621050/war?Webapp-Context=demo

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.

No user found in etc/users.properties. Please use the 'amq:create-admin-user'
command to create one.

JBossA-MQ:karaf@root> install -s war:mvn:org.apache.activemq/activemq-web-demo/5.11.0.redhat-621050/war?Webapp-Context=demo
Bundle ID: 200
JBossA-MQ:karaf@root> list | grep web-demo
[ 200] [Active     ] [            ] [       ] [   80] activemq-web-demo (5.11.0.redhat-621050)

ERROR NOTE: Try accessing http://locahost:8181/demo as desribed in the documentation but got nothing (404 - Not found)? Even after you try changing the install command to Web-ContextApp=demo you still get 404?

Try accessing http://localhost:8181/activemqdemo.

It should be work!

Create test queue

  • Open A-MQ web console http://localhost:8181
  • Klik menu ActiveMQ and submenu +Create
  • Give a queue name FOO.BAR then select radio button Queue and klik button Create Queue
  • Klik left tree menu amq > Queue > FOO.BAR then clik Browse button in the right window

Test to put message using REST

Open terminal, in the shell prompt type:

curl -XPOST -d "body=message" http://admin:admin@localhost:8181/activemqdemo/message?destination=queue://FOO.BAR

$ curl -XPOST -d "body=message" http://admin:admin@localhost:8181/activemqdemo/message?destination=queue://FOO.BAR
Message sent

Test to browse queue using REST

curl http://admin:admin@localhost:8181/activemqdemo/queueBrowse/FOO/BAR

$ curl http://admin:admin@localhost:8181/activemqdemo/queueBrowse/FOO/BAR

<messages queue='queue://FOO.BAR'>
<message id='ID:ejlp-macbook-53159-1447327208004-3:5:1:1:1'/>
</messages>

Test to get message from queue

curl http://admin:admin@localhost:8181/activemqdemo/message/FOO/BAR?type=queue

or

curl http://admin:admin@localhost:8181/activemqdemo/message/FOO/BAR?readTimeout=10000&type=queue

Set HTTPS inteface

Create certificate in the etc/ directory:

keytool -genkey -keyalg RSA -validity 365 -alias serverkey -keypass password -storepass password -keystore keystore.jks
keytool -genkey -keyalg RSA -validity 365 -alias clientkey -keypass password -storepass password -keystore client.jks

Open using editor this file: /Servers/A-MQ_6.2/jboss-a-mq-6.2.0.redhat-133/etc/org.ops4j.pax.web.cfg

Uncomment following line and change the keystore from etc/servicemix.jks to etc/keystore.jks

org.osgi.service.http.secure.enabled=true
org.ops4j.pax.web.ssl.keystore=etc/keystore.jks
org.ops4j.pax.web.ssl.password=password
org.ops4j.pax.web.ssl.keypassword=password
org.osgi.service.http.port.secure=8443

Restart A-MQ

Access https://localhost:8443/activemqdemo/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment