My Play Framework Systemd script

Ubuntu deprecated Upstart so I had to turn to Systemd for my app controls in Ubuntu 18.04. In this script I set 2 environment variables (HOME and LANG), change directory to the app directory and starts the Play Framework application

# Myapp systemd script
#
# Location:/lib/systemd/system/myapp.service
#
# Useful commands:
#
# Start Myapp: 		systemctl start myapp.service
# Stop Myapp:		systemctl stop myapp.service
# Restart Myapp:	systemctl restart myapp.service
# Show status:		systemctl status myapp.service
# Enable start on boot:	systemctl enable myapp.service
# Disable start on boot:systemctl disable myapp.service
#
# List all services running: systemctl
# Check config: systemd-analyze verify myapp.service
#
####################################################################################

[Unit]
Description=Job that runs my app daemon

[Service]
Type=forking
Environment=HOME=/opt/tankmin/app
Environment=LANG=en_US.UTF-8
ExecStartPre=/bin/bash -c 'cd /opt/myapp/app'
ExecStart=/bin/bash -c 'bin/myapp -J-Xms256M -J-Xmx768m -J-server -Dhttp.port=80 -Dconfig.file=conf/application.conf -Dlogger.file=conf/application-logger.xml'

[Install]
WantedBy=multi-user.target

The arguments for the Play service are what I normally use for AWS. You might need other settings

Tested on Ubuntu 18.04 and Play Framework 2.3

Add custom solution to IS Admin page

Since I do not do this often I will put the description of how here

1. Create a flow service called “callback” in your package (or actually anywhere the IS can run it)
This flow service should contain at least one MAP with the following values:

name - description of menu item. Example: MYKPI
text - name of menu item. Example MYKPI 
url - URL to dsp page. Example: ../MYPackage
target - name of start page. Example: index.dsp

2. Create a flow service called “addSolution”
This service should contain one service from the WmRoot package: wm.server.ui:addSolution with the input: path to your “callback” service

3. Create a flow service called “removeSolution”
This service should also contain one service from the WmRoot package: wm.server.ui:removeSolution with the input: path to your “callback” service

4. Lastly we need to make sure that the solution is added to the IS Admin page every time the package gets reloaded
In your manifest.v3 file at the root of your package (example: MYPACKAGE/manifest.v3) there is a line like this:

<null name="startup_services"/>

This needs to be changed to:


    <null name="MYPACKAGE.processing:addSolution"/>
 

5. Run the “addSolution” service once
The link to your solution should now be visible in the IS Admin (after a refresh)

6. Done

Tested on webMethods 9.9 on Red Hat Linux 7.5

IBM MQ: Setup a simple REST API environment with MQWEB and cURL

I’m here going to show you how I setup a small environment for the MQWEB REST API, mainly to try it out. It is actually not much to be done to get this up and running

First choose the security settings. For this IBM provide us with four sample configurations (/<installation path>/mqserver/web/mq/samp/configuration/):

basic_registry.xml  
ldap_registry.xml  
local_os_registry.xml
no_security.xml  

Out of these I’m going to choose local_os_registry.xml because it uses the groups and users already setup on the OS. This saves me from setting up new groups and users somewhere else

Copy desired configuration to MQWEB server settings

cp local_os_registry.xml /var/mqm/web/installations/<installation name>/servers/mqweb/mqwebuser.xml 

Start MQWEB server

strmqweb

That is pretty much it. Time to test

Put message on queue

curl -k -X POST -d 'helloworld' -u user:password -H "ibm-mq-rest-csrf-token: nothing" -H "Content-Type: text/plain"  https://localhost:9443/ibmmq/rest/v1/messaging/qmgr/MYQM01/queue/MYQUEUE/message

Here I feel we need some explaining:
-k: The default SSL certificate on the MQWEB server is self-signed. This option ignores that
-X POST: Use POST for putting messages onto MQ
-d: This is the data (string) that eventually will land on the queue
-u: The OS user and password (part of the mqm group in this example)
-H: The “ibm-mq-rest-csrf-token” needs to exist as a header but can contain anything, can even be completely blank
-H: We need to set a content type for the payload (from the -d option above). Valid content types include:

text/plain;charset=utf-8
text/html;charset=utf-8
text/xml;charset=utf-8
application/json;charset=utf-8
application/xml;charset=utf-8

NOTE: if omitting the charset, utf-8 is assumed
URL: Default URL and port: host:9443/ibmmq/rest/v1/. On top of this we add the default URL for handling messages on queues: /messaging/qmgr/<queue manager name>/queue/<queue name>/message

Get messages from queue

curl -k -X DELETE -u user:password -H "ibm-mq-rest-csrf-token: nothing" https://localhost:9443/ibmmq/rest/v1/messaging/qmgr/MYQM01/queue/MYQUEUE/message

Here I believe that I only need to explain one option:
-X DELETE: When fetching messages from MQ we use the REST DELETE operation

Done!

A couple of useful commands:

 
# Stop IBM MQ REST SERVER
endmqweb

# Show status of MQWEB (will also show the base URL for MQWEB REST API)
dspmqweb

Tested on IBM MQ 9.0.5.0 and Red Hat Linux 7.5 with curl 7.29.0