Skip to content

Latest commit

 

History

History
211 lines (142 loc) · 9.51 KB

File metadata and controls

211 lines (142 loc) · 9.51 KB

REMReM Publish CLI

CLI

For using Eiffel REMReM Publish CLI self executing publish-cli.jar file should be executed in command line with parameters described below.

$ java -jar publish-cli.jar -h

You passed help flag.
usage: java -jar

-d,--debug                                    Enable debug traces.

-domain,--domainId <arg>                      Identifies the domain that produces the event.

-cc,--channelsCount <arg>                     Number of channels connected to messagebus, default is 1

-tto,--tcp_time_out <arg>                     Tcp Connection TimeOut value, default value is 60000 milliseconds.

-wcto,--wait_for_confirms_timeOut <arg>       Time out for wait for confirms ,default is 5000 ms/milliseconds.

-en,--exchange_name <arg>                     Exchange name.

-ce,--create_exchange <arg>                   option to denote if we need to create an exchange
                                              create_exchange or ce to true eg: -ce true or --create_exchange false.

-f,--content_file <arg>                       Event content file.

-h,--help                                     Show help.

-json,--json_content <arg>                    Event content in JSON string. The value can also be a dash (-)
                                              and the JSON will be read from the output of other programs if piped.
                                              Multiple JSON events are also supported.

-mb,--message_bus <arg>                       Host of message bus to use.

-mp,--message_protocol <arg>                  Name of messaging protocol to be used, e.g: eiffelsemantics.
                                              Default is eiffelsemantics.

-np,--non_persistent                          Remove persistence from message sending.

-tls,--tls <arg>                              tls version, specify a valid tls version: '1', '1.1', '1.2' or default.
                                              It is required for RabbitMQ secured port (5671).

-port,--port <arg>                            Port to connect to message bus, default is 5672.

-vh,--virtual_host <arg>                      Virtual host to connect to (optional).

-ud,--user_domain_suffix <arg>                User domain suffix.

-rk,--routing_key <arg>                       Routing key of the eiffel message.
                                              When provided routing key is not generated and the value provided is used.

-srkt,--semanticsRoutingKeyTypeOverrideFilepath <arg>

                                              Default implementation uses the routing key defined in Eiffel Sepia.
                                              To make it compatible to prior routing key structure provide the
                                              path to routing-key-overrides.properties

-tag,--tag <arg>                              Tag to be used in routing key.

-v,--list_versions                            Lists the versions of publish and all loaded protocols.

-un,--username <arg>                          Username to connect to Messagebus

-pwd,--password <arg>                         Encrypted Password to connect to MessageBus. Plaintext password
                                              should be encrypted using Base64 Encryption Mechanism.
-uri,--uri <uri>                              URI to message but, see https://www.rabbitmq.com/uri-spec.html.

For publish we have input only from file that can contain one or more messages in a JSON array (surrounded with square brackets) separated by comma.

The routing key is generated in the protocol library based on the event type. To get more information on routing key see here.

URI may contain username, password, etc, see https://www.rabbitmq.com/uri-spec.html for more details. If other options with the same meaning are provided their values overwrite values given by option --uri, regardless of their order on command line.

Examples

Typical examples of usage Eiffel REMReM Publish CLI are described below.

Publish on a given host, given exchange, given domain and given user domain suffix:

java -jar publish-cli.jar -f publishMessages.json -en mb-exchange -mb hostname -domain publish-domain -ud messageQueue -mp eiffelsemantics

To support default routing key prior to routing key structure defined in Eiffel Sepia:

java -jar publish-cli.jar -f publishMessages.json -en mb-exchange -mb hostname -domain publish-domain -ud messageQueue -mp eiffelsemantics -srkt /path/to/routing-key-overrides.properties

**Note:To get more information on mapping routing-key-overrides.properties see here.

If you want to have the message non persistent add np flag:

java -jar publish-cli.jar -f publishMessages.json -en mb-exchange -mb hostname -domain publish-domain -np -mp eiffelsemantics

For loading protocol jars other than eiffelsemantics:

java -Djava.ext.dirs="/path/to/jars/" -jar publish-cli.jar -f publishMessages.json -en mb-exchange -mb hostname -domain publish-domain -mp protocolType

NOTE: in the above example, protocol jar file must be present inside "/path/to/jars/" folder.

NOTE: -Djava.ext.dirs is no longer working in some JAVA8 versions and in JAVA9. So users should create a wrapper project to include both Generate/Publish and their protocol in or place the protocol library in the folder for external dependencies of their JVM installation.

If you want to have the message publishing logs add d flag:

java -jar publish-cli.jar -f publishMessages.json -en mb-exchange -mb hostname -domain publish-domain -mp eiffelsemantics -d

If you want to have the message publishing on RabbitMQ secured port (5671): -tls option is used to run REMReM on RabbitMQ secured port (5671). -tls option value is either 'default' or for secured port.

java -jar publish-cli.jar -f publishMessages.json -en mb-exchange -mb hostname -domain publish-domain -mp eiffelsemantics -tls 1.2

NOTE: for RabbitMQ default port 5672, no need to pass -tls option.

If you want to have the message publishing on RabbitMQ with given routing key:

java -jar publish-cli.jar -f publishMessages.json -en mb-exchange -mb hostname -domain publish-domain -mp eiffelsemantics -rk myroutingkey

If you want to change the number of channels connected to RabbitMQ to publish messages: channelsCount default value is 1. If the number of channels increases then the CPU load and memory usage on the RabbitMq increases.

java -jar publish-cli.jar -f publishMessages.json -en mb-exchange -mb hostname -domain publish-domain -mp eiffelsemantics -cc numberof-channels 

If you want to change the wait for confirms timeout connected to RabbitMQ to publish messages: waitForConfirmsTimeout default value is 5000 ms/milliseconds. As the waitForConfirmsTimeout value reduces sometimes it may leads to TimeoutException if channel unable to get acknowledgement within timeout.

java -jar publish-cli.jar -f publishMessages.json -en mb-exchange -mb hostname -domain publish-domain -mp eiffelsemantics -wcto timeout-in-seconds 

If you want to have the message publishing on RabbitMQ with given tag:

java -jar publish-cli.jar -f publishMessages.json -en mb-exchange -mb hostname -domain publish-domain -mp eiffelsemantics -tag production

If you want to change the tcp connection timeout value for rabbitmq connection

java -jar publish-cli.jar -f publishMessages.json -en mb-exchange -mb hostname -domain publish-domain -mp eiffelsemantics --tto tcp-timeout-value

To create an exchange passed while publishing the messages use --create_exchange or -ce property to true. Example:

java -jar publish-cli.jar -f EiffelActivityStartedEvent.json -en mb-exchange -ce true -mb hostname -domain publish-domain -mp eiffelsemantics

Output for these Example:

[
  {
    "id": "963da060-f2cf-4370-a68d-67fd872def36",
    "status_code": 200,
    "result": "SUCCESS",
    "message": "Event sent successfully"
  }
]

Output when exchange is not found in RabbitMQ, --create_exchange is set to false , Example:

[
  {
    "status_code": 404,
    "message": " Unavailable. To create the exchange specify -ce or --create_exchange to true
  }
]

Exit Codes

If CLI fails internally before trying to publish Eiffel message, user will get exit code. Exit codes are described in the table below.

Exit code Description
1 User will get this exit code in case of some error that is not described below
2 Some CLI options are missed
3 Passed message protocol or message bus configuration are not correct
4 Passed file path is wrong. File is not found
5 Unable to read content from passed file path
6 Unable to read passed JSON string from command line

Status Codes

For each user request Eiffel REMReM Publish generate response in JSON with internal status code and message, when publishing takes place.

To get information about internal status codes see here.

Note: publish-cli will not validate the message. It will check only if the message contains eventId and eventType.