{"id":4388,"date":"2018-05-08T16:31:01","date_gmt":"2018-05-08T16:31:01","guid":{"rendered":"http:\/\/www.ssec.wisc.edu\/datacenter\/?p=4388"},"modified":"2018-05-09T21:37:59","modified_gmt":"2018-05-09T21:37:59","slug":"rabbitmq-utility-amqpfind-single-server","status":"publish","type":"post","link":"https:\/\/www.ssec.wisc.edu\/datacenter\/2018\/05\/08\/rabbitmq-utility-amqpfind-single-server\/","title":{"rendered":"amqpfind &#8211; Single Server"},"content":{"rendered":"<div class=\"section\">\n<div class=\"line\">\n<h2>Usage<\/h2>\n<hr \/>\n<p>In single server mode, amqpfind creates a connection to a single RabbitMQ server and returns messages for the topics specified. Satellite Data Services ingests data from multiple sources. Each of these ingest process may publish identical messages. Using ampfind in this mode requires users&#8217;s scripts to be written to guard against the possibility of processing the data multiple times.<\/p>\n<p class=\"bold\">amqpfind -H -u -p [-t] [-X] [-j'{key} {key}&#8217; | &#8216;{?}&#8217;] [-C key | key]<\/p>\n<\/div>\n<\/div>\n<table cellspacing=\"5\">\n<tbody>\n<tr valign=\"top\">\n<td>-H<\/td>\n<td valign=\"top\">host ip address of the Satellite Data Services RabbitMQ server mq1(2).ssec.wisc.edu<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td>-u<\/td>\n<td valign=\"top\">user for SDS RabbitMQ server (sdsuser)<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td>-p<\/td>\n<td>password for SDS RabbitMQ server (sdsmq)<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td>-j<\/td>\n<td colspan=\"4\">outputs subset of json key values of the message; must be a single quoted string, each key must be surrounded by curly braces; for example: -j &#8216;{start_time} {band} {status}&#8217;<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td>-j<\/td>\n<td>&#8216;{?}&#8217; &#8211; lists all keys and values from message<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td>-t<\/td>\n<td>sets timeout in seconds before amqpfind ends, default = 0, no timeout<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td>-X<\/td>\n<td>SDS RabbitMQ server exchange; valid options are satellite or himawari<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td>-C<\/td>\n<td>period-separated list of nine subscription keys; specific values or wild card must be specified for all nine keys<\/td>\n<\/tr>\n<tr valign=\"top\">\n<td>-v<\/td>\n<td>debug level<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Examples<\/h2>\n<hr \/>\n<p style=\"padding-left: 30px\">amqpfind -H mq1.ssec.wisc.edu -u sdsuser -p sdsmq -C geo.goes.g16.abi.*.*.*.band.end<\/p>\n<p style=\"padding-left: 60px\"><strong>Output<br \/>\n<\/strong>geo.goes.g16.abi.adde.sdi.ncdf.band.end: &#8216;{&#8220;message_type&#8221;: &#8220;band&#8221;, &#8220;status&#8221;: &#8220;end&#8221;, &#8220;satellite_family&#8221;: &#8220;GOES&#8221;, &#8220;satellite_ID&#8221;: &#8220;G16&#8221;, &#8220;medium&#8221;: &#8220;adde&#8221;, &#8220;start_time&#8221;: &#8220;2018-02-02 16:20:34.6&#8221;, &#8220;coverage&#8221;: &#8220;Mesoscale-1&#8221;, &#8220;satellite_location&#8221;: &#8220;GOES-East&#8221;, &#8220;create_time&#8221;: &#8220;2018-02-02 16:20:44.4&#8221;, &#8220;data_type&#8221;: &#8220;RadM1&#8221;, &#8220;instrument&#8221;: &#8220;ABI&#8221;, &#8220;end_time&#8221;: &#8220;2018-02-02 16:20:40.3&#8221;, &#8220;signal_type&#8221;: &#8220;grb&#8221;, &#8220;server_ip&#8221;: &#8220;satbuf1.ssec.wisc.edu&#8221;, &#8220;mode&#8221;: &#8220;3&#8221;, &#8220;path&#8221;: &#8220;\/data\/goes\/grb\/goes16\/2018\/2018_02_02_033\/abi\/L1b\/RadM1\/OR_ABI-L1b-RadM1-M3C14_G16_s20180331620346_e20180331620403_c20180331620444.nc&#8221;, &#8220;adde_dataset&#8221;: &#8220;EASTA\/M1&#8221;, &#8220;title&#8221;: &#8220;ABI L1b Radiances&#8221;, &#8220;server_type&#8221;: &#8220;sdi&#8221;, &#8220;band&#8221;: 14}&#8217;<\/p>\n<p style=\"padding-left: 30px\">amqpfind -H mq1.ssec.wisc.edu -u sdsuser -p sdsmq -j &#8216;{adde_dataset} {start_time} {band}&#8217; -C geo.goes.abi.*.*.*.band.end<\/p>\n<p style=\"padding-left: 60px\"><strong>Output<br \/>\n<\/strong>EASTA\/M1 2018-01-23 21:54:29.8 8<\/p>\n<p>&nbsp;<\/p>\n<h2>Scripting<\/h2>\n<hr \/>\n<p>One method to implement amqpfind is to write a wrapper script. The script can set an environment and start anqpfind. One advantage of using this method is that your processing script can be updated without having to stop and restart the wrapper script.<\/p>\n<h3 style=\"padding-left: 30px\">Wrapper Script <a href=\".code\/start-remap.bash\">code<\/a><\/h3>\n<p style=\"padding-left: 30px\">#! \/bin\/bash<\/p>\n<p style=\"padding-left: 30px\">#<br \/>\n# Script that starts up bash script based on amqpfind messages<br \/>\n#<\/p>\n<p style=\"padding-left: 30px\"># Note &#8211; when using Full Disk make sure -n is set to 7. Otherwise, &#8216;Disk&#8217; will be passed to the next call to the script.<\/p>\n<p style=\"padding-left: 30px\">export COVERAGE=CONUS<br \/>\nexport PATH=$HOME\/remap\/bin:$HOME\/amqpfind:$PATH<br \/>\nexport MCPATH=$HOME\/remap\/data\/home\/mcidas\/data<\/p>\n<p style=\"padding-left: 30px\">while true; do<\/p>\n<p style=\"padding-left: 30px\">amqpfind -H mq1.ssec.wisc.edu -X satellite -j &#8216;{start_time} {adde_dataset} {server_ip} {satellite_location} {coverage}&#8217; -p sdsmq -u sdsuser -C geo.goes.*.abi.*.*.*.image.complete | grep &#8211;line-buffered -i ${COVERAGE} | xargs -P1 -n6 $HOME\/remap\/bin\/remap-script.bash<\/p>\n<p style=\"padding-left: 30px\">echo $(date -u) amqpfind died in $0<br \/>\ndone<\/p>\n<hr \/>\n<h3 style=\"padding-left: 30px\">Processing Script <a href=\".code\/remap.bash\">code<\/a><\/h3>\n<p style=\"padding-left: 30px\">#!\/bin\/ksh<\/p>\n<p style=\"padding-left: 30px\"># Basic script that takes in arguments from an amqpfind command and runs McIDAS commands<\/p>\n<p style=\"padding-left: 30px\">export LOG=$HOME\/remap\/log\/remap_script.log<br \/>\nexec &gt;&gt;$LOG<br \/>\nexec 2&gt;&gt;$LOG<\/p>\n<p style=\"padding-left: 30px\">echo &#8216;started script&#8217;<\/p>\n<p style=\"padding-left: 30px\">DAY=$1<br \/>\nTIME=$2<br \/>\nADDE_DATASET=$3<br \/>\nADDE_SERVER=$4<br \/>\nSATELLITE=$5<br \/>\nCOVERAGE=$6<\/p>\n<p style=\"padding-left: 30px\"># McIDAS does not deal with fractional times<br \/>\nTIME=&#8221;$(date -d ${TIME} +%H:%M:%S)&#8221;<br \/>\nexport DAY TIME BAND ADDE_DATASET ADDE_SERVER SATELLITE<\/p>\n<p style=\"padding-left: 30px\"># Split apart the adde data<br \/>\nADDE_GROUP=&#8221;$(echo ${ADDE_DATASET}| cut -d&#8217;\/&#8217; -f1)&#8221;<br \/>\nADDE_DESCRIPTOR=&#8221;$(echo ${ADDE_DATASET} | cut -d&#8217;\/&#8217; -f2)&#8221;<br \/>\nexport ADDE_DESCRIPTOR ADDE_GROUP<\/p>\n<p># Define a local ADDE datasets<br \/>\nIMGCOPY_DATASET=IMGCOPY\/AREAS<br \/>\nIMGREMAP_DATASET=IMGREMAP\/AREAS<br \/>\nexport IMGCOPY_DATASET IMGREMAP_DATASET<\/p>\n<p style=\"padding-left: 30px\"># Make the script a little easier to update if you need to update center point and size<br \/>\nREMAP_LAT=&#8217;45:30:00&#8242;<br \/>\nREMAP_LON=&#8217;085:30:00&#8242;<br \/>\nRES=&#8217;3.5&#8242;<br \/>\nREMAP_LINES=970<br \/>\nREMAP_ELES=1100<br \/>\nPROJECTION=&#8217;PS&#8217;<br \/>\nBAND=13<br \/>\nexport REMAP_LAT REMAP_LON RES REMAP_LINES REMAP_ELES PROJECTION BAND<\/p>\n<p style=\"padding-left: 30px\"># Generate a day\/time based file name &#8211; first remove quotes from time<br \/>\nFILE_TIME=&#8221;$(echo ${TIME} | tr -d &#8216;:&#8217;)&#8221;<br \/>\nexport FILE_TIME<br \/>\nFILENAME=${SATELLITE}_sector_001_${DAY}_${FILE_TIME}.gif<br \/>\nexport FILENAME<\/p>\n<p style=\"padding-left: 30px\"># SSEC needs user initials and project number<br \/>\nMCUSER=USER<br \/>\nMCPROJ=PROJ<br \/>\nexport MCUSER MCPROJ<\/p>\n<p style=\"padding-left: 30px\"># Startup McIDAS<br \/>\nmcenv -i 200 -f 1@${REMAP_LINES}x${REMAP_LINES} &lt;&lt; &#8216;EOF&#8217;<\/p>\n<p style=\"padding-left: 60px\">logon.k ${MCUSER} ${MCPROJ}<\/p>\n<p style=\"padding-left: 60px\"># Define local dataset<br \/>\ndsserve.k ADD ${IMGCOPY_DATASET} AREA 1001 1010<br \/>\ndsserve.k ADD ${IMGREMAP_DATASET} AREA 1011 1011<\/p>\n<p style=\"padding-left: 60px\"># Setup MCTABLE entry<br \/>\ndataloc.k ADD $ADDE_GROUP ${ADDE_SERVER}<\/p>\n<p style=\"padding-left: 60px\"># One way of guarding agains processing the data more than one time is to first use IMGCOPY<br \/>\n# to copy down a tiny 4&#215;4 part of the dataset into the LOCAL_DATASET. If the date\/time already<br \/>\n# exists, you don&#8217;t process the data.<br \/>\nmceval.k IMGCOPY ${ADDE_DATASET} ${IMGCOPY_DATASET} SIZE=4 4 BAND=${BAND}<br \/>\nret=$?<\/p>\n<p style=\"padding-left: 60px\">if [[ $ret -ne 0 ]]; then<br \/>\nexit<br \/>\nfi<\/p>\n<p style=\"padding-left: 60px\">mceval.k IMGREMAP ${ADDE_DATASET} ${IMGREMAP_DATASET}.1 LATLON=${REMAP_LAT} ${REMAP_LON} SIZE=${REMAP_LINES} ${REMAP_ELES} PRO=${PROJECTION} RES=${RES} BAND=${BAND}<br \/>\nmceval.k IMGDISP ${IMGREMAP_DATASET}.1<br \/>\nmceval.k MAP<br \/>\nmceval.k FRMLABEL \\&#8221;${SATELLITE} \\(BAND\\) SECTOR 001 \\(DAY\\) \\(HHMMSS\\)<br \/>\nmceval.k FRMSAVE X ${FILENAME}<\/p>\n<p style=\"padding-left: 30px\">exit 0<br \/>\nEOF<\/p>\n<p style=\"padding-left: 30px\">exit 0<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Usage In single server mode, amqpfind creates a connection to a single RabbitMQ server and returns messages for the topics specified. Satellite Data Services ingests data from multiple sources. Each of these ingest process may publish identical messages. Using ampfind in this mode requires users&#8217;s scripts to be written to guard against the possibility of [&hellip;]<\/p>\n","protected":false},"author":23,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4388","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ssec.wisc.edu\/datacenter\/wp-json\/wp\/v2\/posts\/4388","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ssec.wisc.edu\/datacenter\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ssec.wisc.edu\/datacenter\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ssec.wisc.edu\/datacenter\/wp-json\/wp\/v2\/users\/23"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ssec.wisc.edu\/datacenter\/wp-json\/wp\/v2\/comments?post=4388"}],"version-history":[{"count":9,"href":"https:\/\/www.ssec.wisc.edu\/datacenter\/wp-json\/wp\/v2\/posts\/4388\/revisions"}],"predecessor-version":[{"id":4398,"href":"https:\/\/www.ssec.wisc.edu\/datacenter\/wp-json\/wp\/v2\/posts\/4388\/revisions\/4398"}],"wp:attachment":[{"href":"https:\/\/www.ssec.wisc.edu\/datacenter\/wp-json\/wp\/v2\/media?parent=4388"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ssec.wisc.edu\/datacenter\/wp-json\/wp\/v2\/categories?post=4388"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ssec.wisc.edu\/datacenter\/wp-json\/wp\/v2\/tags?post=4388"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}