@@ -45,6 +45,7 @@ public class HookHandler implements LoggableResource {
45
45
public static final String HOOK_ROUTES_LISTED = "x-hook-routes-listed" ;
46
46
public static final String HOOKS_LISTENERS_URI_PART = "/_hooks/listeners/" ;
47
47
public static final String LISTENER_QUEUE_PREFIX = "listener-hook" ;
48
+ private static final String X_QUEUE = "x-queue" ;
48
49
private static final String LISTENER_HOOK_TARGET_PATH = "listeners/" ;
49
50
50
51
public static final String HOOKS_ROUTE_URI_PART = "/_hooks/route" ;
@@ -683,7 +684,7 @@ private void callListener(final HttpServerRequest request, final Buffer buffer,
683
684
log .debug (" > external target: " + targetUri );
684
685
}
685
686
686
- String queue = LISTENER_QUEUE_PREFIX + "-" + listener .getListenerId ();
687
+ String queue = listener .getDestinationQueue ();
687
688
688
689
// Create a new multimap, copied from the original request,
689
690
// so that the original request is not overridden with the new values.
@@ -1232,6 +1233,16 @@ private void registerListener(Buffer buffer) {
1232
1233
1233
1234
extractAndAddStaticHeadersToHook (jsonHook , hook );
1234
1235
1236
+ Map <String , String > staticHeaders = hook .getStaticHeaders ();
1237
+ String destinationQueue = null ;
1238
+ if (staticHeaders != null ) {
1239
+ // remove static x-queue header. Otherwise it will be re-queued at the end of the queue.
1240
+ destinationQueue = hook .getStaticHeaders ().remove (X_QUEUE );
1241
+ }
1242
+ if (destinationQueue == null ) {
1243
+ destinationQueue = LISTENER_QUEUE_PREFIX + "-" + listenerId ;
1244
+ }
1245
+
1235
1246
/*
1236
1247
* Despite the fact, that every hook
1237
1248
* should have an expiration time,
@@ -1281,7 +1292,7 @@ private void registerListener(Buffer buffer) {
1281
1292
}
1282
1293
1283
1294
// create and add a new listener (or update an already existing listener)
1284
- listenerRepository .addListener (new Listener (listenerId , getMonitoredUrlSegment (requestUrl ), target , hook ));
1295
+ listenerRepository .addListener (new Listener (listenerId , getMonitoredUrlSegment (requestUrl ), target , hook , destinationQueue ));
1285
1296
}
1286
1297
1287
1298
/**
@@ -1296,7 +1307,7 @@ private void extractAndAddStaticHeadersToHook(final JsonObject jsonHook, final H
1296
1307
if (staticHeaders != null && staticHeaders .size () > 0 ) {
1297
1308
hook .addStaticHeaders (new LinkedHashMap <>());
1298
1309
for (Map .Entry <String , Object > entry : staticHeaders .getMap ().entrySet ()) {
1299
- hook .getStaticHeaders ().put (entry .getKey (), entry .getValue ().toString ());
1310
+ hook .getStaticHeaders ().put (entry .getKey (). toLowerCase () , entry .getValue ().toString ());
1300
1311
}
1301
1312
}
1302
1313
}
0 commit comments