forked from openiap/opencore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathamqp.html
More file actions
276 lines (258 loc) · 10.3 KB
/
Copy pathamqp.html
File metadata and controls
276 lines (258 loc) · 10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<script type="text/x-red" data-template-name="amqp-connection">
<div class="form-row">
<label><i class="icon-host"></i> Host</label>
<input type="text" id="node-config-input-host">
</div>
<div class="form-row">
<label><i class="icon-bookmark"></i> Username</label>
<input type="text" id="node-config-input-username">
</div>
<div class="form-row">
<label><i class="icon-bookmark"></i> Password</label>
<input type="text" id="node-config-input-password" style="-webkit-text-security: disc;">
</div>
<div class="form-row">
<label ><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-config-input-name" placeholder="Node name">
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('amqp-connection', {
category: 'config',
defaults: {
host: { value: "", required: true },
name: { value: "" },
},
credentials: {
username: { type: "text" },
password: { type: "password" }
},
label: function () {
return (this.name || this.host) || "amqp credentials";
}
});
</script>
<script type="text/x-red" data-template-name="amqp consumer">
<div class="form-row">
<label for="node-input-config"><i class="fa fa-globe"></i> Config</label>
<input type="text" id="node-input-config">
</div>
<div class="form-row">
<label><i class="fa fa-tag"></i> Queue name</label>
<input type="text" id="node-input-queue" placeholder="Queue name">
</div>
<div class="form-row">
<label><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Node name">
</div>
</script>
<script type="text/x-red" data-help-name="amqp consumer">
AMQP consumer, listening for messages.<br>
if no connection is added, it will connect to your current openflow, but you
can add a connection to another openflow and send/receive message queue message using that.<br>
Remember that your queue maybe get prefixed with your usename, if amqp_force_queue_prefix is enabled in the openflow api<br>
</script>
<script type="text/javascript">
RED.nodes.registerType('amqp consumer', {
category: 'amqp',
color: "#a6bbcf",
defaults: {
queue: { value: "", required: true },
name: { value: "" },
config: { value: "", type: "amqp-connection", required: false }
},
inputs: 0,
outputs: 1,
outputLabels: ["completed", "error"],
icon: "bridge.png",
label: function () {
return this.name || "amqp consumer";
},
labelStyle: function () {
return this.name ? "node_label_italic" : "";
},
});
</script>
<script type="text/x-red" data-template-name="amqp publisher">
<div class="form-row">
<label for="node-input-config"><i class="fa fa-globe"></i> Config</label>
<input type="text" id="node-input-config">
</div>
<div class="form-row">
<label><i class="fa fa-tag"></i> Queue name</label>
<input type="hidden" id="node-input-queuetype">
<input style="width:70%" type="text" id="node-input-queue" placeholder="Queue name">
</div>
<div class="form-row">
<label><i class="fa fa-tag"></i> Exchange name</label>
<input type="hidden" id="node-input-exchangetype">
<input style="width:70%" type="text" id="node-input-exchange" placeholder="Queue name">
</div>
<div class="form-row">
<label><i class="fa fa-tag"></i> Routing key</label>
<input type="hidden" id="node-input-routingkeytype">
<input style="width:70%" type="text" id="node-input-routingkey" placeholder="Routing key">
</div>
<div class="form-row">
<label><i class="fa fa-tag"></i> Local queue name</label>
<input type="text" id="node-input-localqueue" placeholder="Queue name">
</div>
<div class="form-row">
<label><i class="fa fa-tag"></i> Striptoken</label>
<input type="checkbox" id="node-input-striptoken" style="width: auto;">
</div>
<div class="form-row">
<label><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Node name">
</div>
</script>
<script type="text/x-red" data-help-name="amqp publisher">
AMQP publisher, sends messages to queue or exchange. queue is the exchange to send message too.<br>
localqueue is this nodes personal queue, leave blank for auto generated ( will change on every restart/Deploy )<br>
use msg.expiration to define how long a message will wait for a consumer to pick it up<br>
if no connection is added, it will connect to your current openflow, but you
can add a connection to another openflow and send/receive message queue message using that.<br>
Remember that your <b>consumer queue</b> maybe get prefixed with your usename, if amqp_force_queue_prefix is enabled in the openflow api<br>
</script>
<script type="text/javascript">
function isValid() {
const queue = this.queue == null || this.queue == "";
const exchange = this.exchange == null || this.exchange == "";
const routingkey = this.routingkey == null || this.routingkey == "";
if (queue == false) return true;
if (exchange == false) return true;
// if (!exchange && !routingkey) return true;
return false;
}
RED.nodes.registerType('amqp publisher', {
category: 'amqp',
color: "#a6bbcf",
defaults: {
queue: { value: "", validate: RED.validators.typedInput("queuetype"), validate: isValid },
queuetype: { value: "" },
exchange: { value: "", validate: RED.validators.typedInput("exchangetype"), validate: isValid },
exchangetype: { value: "" },
routingkey: { value: "", validate: RED.validators.typedInput("routingkeytype") },
routingkeytype: { value: "" },
localqueue: { value: "" },
striptoken: { value: false },
config: { value: "", type: "amqp-connection", required: false },
name: { value: "" }
},
inputs: 1,
outputs: 2,
outputLabels: ["completed", "error"],
icon: "bridge.png",
label: function () {
return this.name || "amqp publisher";
},
labelStyle: function () {
return this.name ? "node_label_italic" : "";
},
oneditprepare: function () {
if (this.queuetype === 'val') $("#node-input-queuetype").val('str');
$("#node-input-queue").typedInput({
default: 'str',
typeField: $("#node-input-queuetype"),
types: ['msg', 'str', 'flow', 'global', 'json']
});
if (this.exchangetype === 'val') $("#node-input-exchangetype").val('str');
$("#node-input-exchange").typedInput({
default: 'str',
typeField: $("#node-input-exchangetype"),
types: ['msg', 'str', 'flow', 'global', 'json']
});
if (this.routingkeytype === 'val') $("#node-input-routingkeytype").val('str');
$("#node-input-routingkey").typedInput({
default: 'str',
typeField: $("#node-input-routingkeytype"),
types: ['msg', 'str', 'flow', 'global', 'json']
});
},
});
</script>
<script type="text/x-red" data-template-name="amqp acknowledgment">
<div class="form-row">
<label ><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Node name">
</div>
</script>
<script type="text/x-red" data-help-name="amqp acknowledgment">
Acknowledgment processing a AMQP message.
</script>
<script type="text/javascript">
RED.nodes.registerType('amqp acknowledgment', {
category: 'amqp',
color: "#a6bbcf",
defaults: {
name: { value: "" }
},
inputs: 1,
outputs: 1,
icon: "bridge.png",
align: "right",
label: function () {
return this.name || "amqp acknowledgment";
},
labelStyle: function () {
return this.name ? "node_label_italic" : "";
},
});
</script>
<script type="text/x-red" data-template-name="amqp exchange">
<!-- readonly onfocus="this.removeAttribute('readonly');" autocomplete="off" -->
<div class="form-row">
<label for="node-input-config"><i class="fa fa-globe"></i> Config</label>
<input type="text" id="node-input-config">
</div>
<div class="form-row">
<label><i class="fa fa-tag"></i> Exchange name</label>
<input type="text" id="node-input-exchange" placeholder="Exchange name">
</div>
<div class="form-row">
<label><i class="fa fa-tag"></i> Algorithm</label>
<select id="node-input-algorithm">
<option value="direct">Direct</option>
<option value="fanout">Fanout</option>
<option value="topic">Topic</option>
<option value="header">Header</option>
</select>
</div>
<div class="form-row">
<label><i class="fa fa-tag"></i> Routing Key</label>
<input type="text" id="node-input-routingkey" placeholder="Routing Key">
</div>
<div class="form-row">
<label><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Node name">
</div>
</script>
<script type="text/x-red" data-help-name="amqp exchange">
registers an exchange, and create an comsumer listening for messages on the exchange.<br>
if no connection is added, it will connect to your current openflow, but you
can add a connection to another openflow and send/receive message queue message using that.<br>
Remember that your queue maybe get prefixed with your usename, if amqp_force_exchange_prefix is enabled in the openflow api<br>
</script>
<script type="text/javascript">
RED.nodes.registerType('amqp exchange', {
category: 'amqp',
color: "#a6bbcf",
defaults: {
exchange: { value: "", required: true },
name: { value: "" },
routingkey: { value: "" },
algorithm: { value: "fanout", required: true },
config: { value: "", type: "amqp-connection", required: false }
},
inputs: 0,
outputs: 1,
outputLabels: ["completed", "error"],
icon: "bridge.png",
label: function () {
return this.name || "amqp exchange";
},
labelStyle: function () {
return this.name ? "node_label_italic" : "";
},
});
</script>