|
1 | | -Class RabbitMQ.Common Extends %RegisteredObject [ Abstract ] |
| 1 | +Class isc.rabbitmq.Common Extends %RegisteredObject [ Abstract ] |
2 | 2 | { |
3 | 3 |
|
4 | | -/// This is the ID name of the set of credentials values (Username, Password) to be used to access the HTTP server |
5 | | -/// Property Credentials As %String [ InitialExpression = "None" ]; |
6 | | -Property Host As %String [ InitialExpression = "localhost" ]; |
| 4 | +/// Either host or Connection URI: amqp:\\ |
| 5 | +/// If Connection URI is passed, then Port, Credentials and Virtual host properties are ignored. |
| 6 | +Property Host As %VarString [ InitialExpression = "localhost" ]; |
7 | 7 |
|
8 | 8 | Property Port As %Integer [ InitialExpression = -1 ]; |
9 | 9 |
|
10 | 10 | Property VirtualHost As %String [ InitialExpression = "/" ]; |
11 | 11 |
|
12 | | -/// Outbound adapter only (ignored for inbound adapter) |
13 | | -/// If Exchange is not set, then Queue name. |
14 | | -/// If Exchange is set, then Routing key. |
15 | 12 | Property Queue As %String; |
16 | 13 |
|
17 | | -/// Exchange name. Optional, empty by default. |
18 | | -Property Exchange As %String; |
19 | | - |
20 | 14 | /// Config Name of the Java Gateway service controlling the Java Gateway server this item will use. |
21 | 15 | /// Alternatively use JGHost and JGPort Settings, to specify Java gateway outside of Ensemble scope. |
22 | 16 | Property JGService As %String; |
@@ -45,18 +39,8 @@ Property Encoding As %String; |
45 | 39 | /// See property AdditionalPaths in that class. |
46 | 40 | Property ClassPath As %String(MAXLEN = 32000); |
47 | 41 |
|
48 | | -/// How many times have we tried reconnecting |
49 | | -/// empty - do not retry |
50 | | -/// 0 - retry ad infinitum |
51 | | -/// n - retry n times |
52 | | -Property RetryCount As %Integer [ InitialExpression = 5 ]; |
53 | | - |
54 | | -/// How frequently to retry access to the output system. |
55 | | -/// Pause in seconds between retry attempts. |
56 | | -Property RetryInterval As %Numeric(MINVAL = 0) [ InitialExpression = 5 ]; |
57 | | - |
58 | 42 | /// These are the production settings for this object |
59 | | -Parameter SETTINGS = "Host:Basic,Port:Basic,VirtualHost:Basic,Queue:Basic,Credentials:Basic:credentialsSelector,JGHost:Java Gateway,JGPort:Java Gateway,JGService:Java Gateway:selector?context={Ens.ContextSearch/ProductionItems?targets=0&productionName=@productionId},ClassPath:Basic,Encoding:Basic,RetryCount:Alerting,RetryInterval:Alerting"; |
| 43 | +Parameter SETTINGS = "Host:Basic,Port:Basic,VirtualHost:Basic,Queue:Basic,Credentials:Basic:credentialsSelector,JGHost:Java Gateway,JGPort:Java Gateway,JGService:Java Gateway:selector?context={Ens.ContextSearch/ProductionItems?targets=0&productionName=@productionId},ClassPath:Basic,Encoding:Basic"; |
60 | 44 |
|
61 | 45 | /// Connect to running JGW |
62 | 46 | Method Connect() As %Status |
@@ -97,44 +81,14 @@ Method ConnectToRabbitMQ() As %Status |
97 | 81 | Set pass = "guest" |
98 | 82 | } |
99 | 83 |
|
100 | | - Set port = $select(..Port="":-1, 1:..Port) |
101 | | - |
102 | 84 | Try { |
103 | | - Set ..API = ##class(isc.rabbitmq.API).%New(..JGW, ..Host, port, user, pass, ..VirtualHost, ..Queue, $$$YES, ..Exchange) |
104 | | - } Catch ex { |
| 85 | + Set ..API = ##class(isc.rabbitmq.API).%New(..JGW, ..Host, ..Port, user, pass, ..VirtualHost, ..Queue, $$$YES) |
| 86 | + } Catch ex { |
105 | 87 | Set sc = $$$ADDSC(ex.AsStatus(),$g(%objlasterror)) |
106 | 88 | } |
107 | 89 |
|
108 | 90 | Quit sc |
109 | 91 | } |
110 | 92 |
|
111 | | -Method IsOpen() As %Status |
112 | | -{ |
113 | | - #Dim sc As %Status = $$$OK |
114 | | - Set retryCount = 1 |
115 | | - Try { |
116 | | - While '..API.isOpen() { |
117 | | - If ..RetryCount = "" { |
118 | | - Set sc = $$$ERROR($$$GeneralError, "Connection problems. Consider specifying RetryCount and RetryInterval settings") |
119 | | - } ElseIf ((..RetryCount = 0) || (retryCount < ..RetryCount)) { |
120 | | - // wait and retry connecting |
121 | | - Set retryCount = retryCount + 1 |
122 | | - Hang ..RetryInterval |
123 | | - |
124 | | - // reconnect happens in isOpen method |
125 | | - } Else { |
126 | | - // we're out of reconnect attempts |
127 | | - Set sc = $$$ERROR($$$GeneralError, $$$FormatText("Connection still closed after %1 attempts at reconnecting.", ..RetryCount)) |
128 | | - } |
129 | | - Quit:$$$ISERR(sc) |
130 | | - } |
131 | | - } Catch ex { |
132 | | - #Dim ex As %Exception.General |
133 | | - Set sc = ex.AsStatus() |
134 | | - } |
135 | | - |
136 | | - Quit sc |
137 | | -} |
138 | | - |
139 | 93 | } |
140 | 94 |
|
0 commit comments