Skip to content

Commit 8c9f79f

Browse files
committed
Shovel management: add local shovels
1 parent bb5e1d9 commit 8c9f79f

File tree

3 files changed

+140
-3
lines changed

3 files changed

+140
-3
lines changed

deps/rabbitmq_shovel_management/priv/www/js/shovel.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,27 @@ dispatcher_add(function(sammy) {
4242
//remove fields not required by the selected protocol
4343
if (this.params['src-protocol'] == 'amqp10') {
4444
remove_params_with(this, 'amqp091-src');
45+
remove_params_with(this, 'local-src');
46+
} else if (this.params['src-protocol'] == 'amqp091') {
47+
remove_params_with(this, 'amqp10-src');
48+
remove_params_with(this, 'local-src');
4549
} else {
4650
remove_params_with(this, 'amqp10-src');
51+
remove_params_with(this, 'amqp091-src');
4752
}
4853
if (this.params['dest-protocol'] == 'amqp10') {
4954
remove_params_with(this, 'amqp091-dest');
55+
remove_params_with(this, 'local-dest');
56+
} else if (this.params['dest-protocol'] == 'amqp091'){
57+
remove_params_with(this, 'amqp10-dest');
58+
remove_params_with(this, 'local-dest');
5059
} else {
60+
remove_params_with(this, 'amqp091-dest');
5161
remove_params_with(this, 'amqp10-dest');
5262
}
5363

5464
var trimProtoPrefix = function (x) {
55-
if(x.startsWith('amqp10-') || x.startsWith('amqp091-')) {
65+
if(x.startsWith('amqp10-') || x.startsWith('amqp091-') || x.startsWith('local-')) {
5666
return x.substr(x.indexOf('-') + 1, x.length);
5767
}
5868
return x;

deps/rabbitmq_shovel_management/priv/www/js/tmpl/dynamic-shovels.ejs

Lines changed: 97 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
<select name="src-protocol-selector" class="controls-appearance">
9696
<option value="amqp091-src">AMQP 0.9.1</option>
9797
<option value="amqp10-src">AMQP 1.0</option>
98+
<option value="local-src">Local</option>
9899
</select>
99100
<div id="amqp10-src-div" style="display: none;">
100101
<table class="subform">
@@ -206,6 +207,55 @@
206207
</tr>
207208
</table>
208209
</div>
210+
<div id="local-src-div" style="display: none;">
211+
<table class="subform">
212+
<tr>
213+
<td>
214+
<label>
215+
URI:
216+
<span class="help" id="shovel-uri"></span>
217+
</label>
218+
</td>
219+
<td>
220+
<select name="queue-or-exchange" class="controls-appearance">
221+
<option value="local-src-queue">Queue:</option>
222+
<option value="local-src-exchange">Exchange:</option>
223+
</select>
224+
<span class="help" id="shovel-queue-exchange"></span>
225+
</td>
226+
</tr>
227+
<tr>
228+
<td>
229+
<input type="text" name="local-src-uri" value="amqp://"/>
230+
<span class="mand">*</span>
231+
</td>
232+
<td>
233+
<div id="local-src-queue-div">
234+
<input type="text" name="local-src-queue"/>
235+
</div>
236+
<div id="local-src-exchange-div" style="display: none;">
237+
<input type="text" name="local-src-exchange"/>
238+
Routing key: <input type="text" name="local-src-exchange-key"/>
239+
</div>
240+
</td>
241+
</tr>
242+
<tr>
243+
<td>
244+
<label>
245+
Auto-delete
246+
<span class="help" id="shovel-local-auto-delete"></span>
247+
</label>
248+
</td>
249+
<td>
250+
<select name="local-src-delete-after">
251+
<option value="never">Never</option>
252+
<option value="queue-length">After initial length transferred</option>
253+
<option value="number">After num messages</option>
254+
</select>
255+
</td>
256+
</tr>
257+
</table>
258+
</div>
209259
</td>
210260
</tr>
211261
<tr>
@@ -214,6 +264,7 @@
214264
<select name="dest-protocol-selector" class="controls-appearance">
215265
<option value="amqp091-dest">AMQP 0.9.1</option>
216266
<option value="amqp10-dest">AMQP 1.0</option>
267+
<option value="local-dest">Local</option>
217268
</select>
218269
<div id="amqp10-dest-div" style="display: none;">
219270
<table class="subform">
@@ -279,7 +330,7 @@
279330
</div>
280331
<div id="dest-exchange-div" style="display: none;">
281332
<input type="text" name="amqp091-dest-exchange"/>
282-
Routing key: <input type="text" name="dest-exchange-key"/>
333+
Routing key: <input type="text" name="amqp091-dest-exchange-key"/>
283334
</div>
284335
</td>
285336
</tr>
@@ -299,6 +350,51 @@
299350
</tr>
300351
</table>
301352
</div>
353+
<div id="local-dest-div" style="display: none;">
354+
<table class="subform">
355+
<tr>
356+
<td>
357+
<label>
358+
URI
359+
<span class="help" id="shovel-uri"></span>
360+
</label>
361+
</td>
362+
<td>
363+
<select name="queue-or-exchange" class="narrow controls-appearance">
364+
<option value="local-dest-queue">Queue:</option>
365+
<option value="local-dest-exchange">Exchange:</option>
366+
</select>
367+
<span class="help" id="shovel-queue-exchange"></span>
368+
</td>
369+
</tr>
370+
<tr>
371+
<td><input type="text" name="local-dest-uri" value="amqp://"/><span class="mand">*</span></td>
372+
<td>
373+
<div id="local-dest-queue-div">
374+
<input type="text" name="local-dest-queue"/>
375+
</div>
376+
<div id="local-dest-exchange-div" style="display: none;">
377+
<input type="text" name="local-dest-exchange"/>
378+
Routing key: <input type="text" name="local-dest-exchange-key"/>
379+
</div>
380+
</td>
381+
</tr>
382+
<tr>
383+
<td>
384+
<label>
385+
Add forwarding headers:
386+
<span class="help" id="shovel-forward-headers"></span>
387+
</label>
388+
</td>
389+
<td>
390+
<select name="local-dest-add-forward-headers">
391+
<option value="false">No</option>
392+
<option value="true">Yes</option>
393+
</select>
394+
</td>
395+
</tr>
396+
</table>
397+
</div>
302398
</td>
303399
</tr>
304400
<tr>

deps/rabbitmq_shovel_management/test/http_SUITE.erl

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ groups() ->
3232
start_and_get_a_dynamic_amqp091_shovel_with_publish_properties,
3333
start_and_get_a_dynamic_amqp091_shovel_with_missing_publish_properties,
3434
start_and_get_a_dynamic_amqp091_shovel_with_empty_publish_properties,
35+
start_and_get_a_dynamic_local_shovel,
3536
create_and_delete_a_dynamic_shovel_that_successfully_connects,
3637
create_and_delete_a_dynamic_shovel_that_fails_to_connect
3738
]},
@@ -212,6 +213,20 @@ start_and_get_a_dynamic_amqp091_shovel_with_empty_publish_properties(Config) ->
212213

213214
ok.
214215

216+
start_and_get_a_dynamic_local_shovel(Config) ->
217+
remove_all_dynamic_shovels(Config, <<"/">>),
218+
Name = rabbit_data_coercion:to_binary(?FUNCTION_NAME),
219+
ID = {<<"/">>, Name},
220+
await_shovel_removed(Config, ID),
221+
222+
declare_local_shovel(Config, Name),
223+
await_shovel_startup(Config, ID),
224+
Sh = get_shovel(Config, Name),
225+
?assertEqual(Name, maps:get(name, Sh)),
226+
delete_shovel(Config, Name),
227+
228+
ok.
229+
215230
start_static_shovels(Config) ->
216231
http_put(Config, "/users/admin",
217232
#{password => <<"admin">>, tags => <<"administrator">>}, ?CREATED),
@@ -455,6 +470,22 @@ declare_amqp091_shovel_with_publish_properties(Config, Name, Props) ->
455470
}
456471
}, ?CREATED).
457472

473+
declare_local_shovel(Config, Name) ->
474+
Port = integer_to_binary(
475+
rabbit_ct_broker_helpers:get_node_config(Config, 0, tcp_port_amqp)),
476+
http_put(Config, io_lib:format("/parameters/shovel/%2f/~ts", [Name]),
477+
#{
478+
value => #{
479+
<<"src-protocol">> => <<"local">>,
480+
<<"src-uri">> => <<"amqp://localhost:", Port/binary>>,
481+
<<"src-queue">> => <<"local.src.test">>,
482+
<<"src-delete-after">> => <<"never">>,
483+
<<"dest-protocol">> => <<"local">>,
484+
<<"dest-uri">> => <<"amqp://localhost:", Port/binary>>,
485+
<<"dest-queue">> => <<"local.dest.test">>
486+
}
487+
}, ?CREATED).
488+
458489
await_shovel_startup(Config, Name) ->
459490
await_shovel_startup(Config, Name, 10_000).
460491

@@ -480,4 +511,4 @@ does_shovel_exist(Config, Name) ->
480511
case lookup_shovel_status(Config, Name) of
481512
not_found -> false;
482513
_Found -> true
483-
end.
514+
end.

0 commit comments

Comments
 (0)