I've updated rabbitmqadmin file to support file content publishing. Try to find line containing EXTRA_VERBS = {
as well as def invoke_publish(self):
and update their related code as follows
EXTRA_VERBS = {
'publish': {'mandatory': ['routing_key'],
'optional': {'payload': None,
'pfile': None,
'properties': {},
'exchange': 'amq.default',
'payload_encoding': 'string'},
'json': ['properties'],
'uri': '/exchanges/{vhost}/{exchange}/publish'},
'get': {'mandatory': ['queue'],
'optional': {'count': '1', 'requeue': 'true',
'payload_file': None, 'encoding': 'auto'},
'uri': '/queues/{vhost}/{queue}/get'}
}
and
def invoke_publish(self):
(uri, upload) = self.parse_args(self.args, EXTRA_VERBS['publish'])
if not 'payload' and 'pfile' in upload:
data = sys.stdin.read()
upload['payload'] = b64(data)
upload['payload_encoding'] = 'base64'
elif not 'payload' in upload:
with open('populate/' + upload['pfile']) as f: data = f.read()
upload['payload'] = b64(data)
upload['payload_encoding'] = 'base64'
resp = json.loads(self.post(uri, json.dumps(upload)))
if resp['routed']:
self.verbose("Message published")
else:
self.verbose("Message published but NOT routed")
Remove 'populate/' +
from the following line if you want to provide file using absolute path.
with open('populate/' + upload['pfile']) as f: data = f.read()
Without updates to open(...) following command worked for me fine, assuming that file rules.json was placed in relative directory "populate"
python rabbitmqadmin.py publish exchange=feed-mgmt-in routing_key='#' properties='{"type":"domain-collections/rules"}' pfile="rules.json"