new Common(amqpUri, channelName, configurationopt)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
amqpUri |
AmqpURI
|
||
channelName |
ChannelName
|
||
configuration |
Configuration
|
<optional> |
Members
(protected) _E :*|EventEmitter
Used to emit messages and statues.
Type:
-
*|EventEmitter
(protected) _isReady :boolean
Internal flag for signaling of the connection if ready.
Type:
-
boolean
(protected) _name :string
Name associated with this instance - displayed in the logs. Each instance should override this with some relevant name.
Type:
-
string
Methods
_commonPublishPreparations(contentToPublish) → {*|null}
Parameters:
| Name | Type | Description |
|---|---|---|
contentToPublish |
number
|
string
|
boolean
|
Object
|
Array
|
Returns:
- Type:
-
*|null
(protected) _emitAndDispatchError(errorMessage)
Parameters:
| Name | Type | Description |
|---|---|---|
errorMessage |
string
|
(protected) _logData(data, description)
Log the data that was received or send in the channels.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
Object
|
Buffer
|
|
description |
string
|
some additional information to be logged with the data |
(protected) _messageDispatcherWrapper(logType, message)
Wrapper for common message handling.
Parameters:
| Name | Type | Description |
|---|---|---|
logType |
'log'
|
'info'
|
'warn'
|
'error'
|
one of |
message |
string
|
message to print |
(protected) _parseConsumedMessage(message) → {number|string|Object|boolean|Array|null}
Parse the message that was consumed.
The parsing tries parsing via the JSON.parse.
If this fails, it just tries to return a string representation.
It can parse:
- number
- string
- plain Object
- Array
- boolean
Parameters:
| Name | Type | Description |
|---|---|---|
message |
Object
|
as received by the consumer; it expects a property |
Returns:
- Type:
-
number|string|Object|boolean|Array|null
null is returned if the message was not parsed
(protected) _preparePublishingMessage(message) → {Buffer|null}
Prepare the data to be published.
Parameters:
| Name | Type | Description |
|---|---|---|
message |
string
|
Object
|
number
|
boolean
|
Array
|
Returns:
- Type:
-
Buffer|null
closeConnection() → {boolean}
Close the connection. The client will not preform an automatic reconnect when this is called.
Returns:
- Type:
-
boolean
false if there was an error
getEventer() → {EventEmitter}
Get the EventEmitter that emits messages and errors.
Returns:
- Type:
-
EventEmitter
isReady() → {boolean}
Check if the connection is operational.
Returns:
- Type:
-
boolean