Issue #2726: Fix context mappings for topics
Change-Id: I636883170c5061cdaf42cbfafffdd4b4b7e3e23f Former-commit-id:ecbd0d5720
[formerly b3d978d0e22b371eaa826d856156ba5360ee7be9] Former-commit-id:4ac996336e
This commit is contained in:
parent
fa5c0f71ad
commit
35b8b8bc15
2 changed files with 27 additions and 5 deletions
|
@ -21,9 +21,11 @@ package com.raytheon.uf.edex.esb.camel.context;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@ -52,6 +54,18 @@ import com.raytheon.uf.edex.core.EdexException;
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
public class ContextData {
|
public class ContextData {
|
||||||
|
/**
|
||||||
|
* Set of endpoint types that allow multiple consumers.
|
||||||
|
*/
|
||||||
|
private static final Set<String> MULTIPLE_CONSUMER_TYPES;
|
||||||
|
|
||||||
|
static {
|
||||||
|
Set<String> multipleConsumerTypes = new HashSet<String>(1, 1);
|
||||||
|
multipleConsumerTypes.add("topic");
|
||||||
|
MULTIPLE_CONSUMER_TYPES = Collections
|
||||||
|
.unmodifiableSet(multipleConsumerTypes);
|
||||||
|
}
|
||||||
|
|
||||||
private final List<CamelContext> contexts;
|
private final List<CamelContext> contexts;
|
||||||
|
|
||||||
private final Map<String, Route> consumerRouteMapping;
|
private final Map<String, Route> consumerRouteMapping;
|
||||||
|
@ -63,7 +77,7 @@ public class ContextData {
|
||||||
* the endpoint URI.
|
* the endpoint URI.
|
||||||
*/
|
*/
|
||||||
private static final Pattern endpointUriParsePattern = Pattern
|
private static final Pattern endpointUriParsePattern = Pattern
|
||||||
.compile("([^:]+)://([^?]+)");
|
.compile("(?:[^:]+:)*([^:]+):(?://)?([^?]+)\\??.*$");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses passed contexts for route and endpoint data about all contexts.
|
* Parses passed contexts for route and endpoint data about all contexts.
|
||||||
|
@ -78,9 +92,11 @@ public class ContextData {
|
||||||
.unmodifiableMap(generateRouteMappings(this.contexts));
|
.unmodifiableMap(generateRouteMappings(this.contexts));
|
||||||
Map<String, String> idUriMapping = new HashMap<String, String>(
|
Map<String, String> idUriMapping = new HashMap<String, String>(
|
||||||
consumerRouteMapping.size(), 1);
|
consumerRouteMapping.size(), 1);
|
||||||
for (Route route : consumerRouteMapping.values()) {
|
for (CamelContext ctx : this.contexts) {
|
||||||
idUriMapping.put(route.getId(), route.getEndpoint()
|
for (Route route : ctx.getRoutes()) {
|
||||||
.getEndpointUri());
|
idUriMapping.put(route.getId(), route.getEndpoint()
|
||||||
|
.getEndpointUri());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.routeIdUriMapping = Collections.unmodifiableMap(idUriMapping);
|
this.routeIdUriMapping = Collections.unmodifiableMap(idUriMapping);
|
||||||
|
@ -109,7 +125,9 @@ public class ContextData {
|
||||||
String endpointName = typeAndName.getSecond();
|
String endpointName = typeAndName.getSecond();
|
||||||
|
|
||||||
Route prev = routeMapping.put(endpointName, route);
|
Route prev = routeMapping.put(endpointName, route);
|
||||||
if (prev != null) {
|
if ((prev != null)
|
||||||
|
&& !MULTIPLE_CONSUMER_TYPES
|
||||||
|
.contains(typeAndName.getFirst())) {
|
||||||
throw new ConfigurationException(
|
throw new ConfigurationException(
|
||||||
"Two contexts listen to the same endpoint name ["
|
"Two contexts listen to the same endpoint name ["
|
||||||
+ endpointName
|
+ endpointName
|
||||||
|
|
|
@ -218,6 +218,10 @@ case $func in
|
||||||
stopEDEX $service &
|
stopEDEX $service &
|
||||||
done
|
done
|
||||||
wait
|
wait
|
||||||
|
|
||||||
|
# small sleep for wrapper lock to disappear so that we don't make .1 version of log files
|
||||||
|
sleep 5
|
||||||
|
|
||||||
for service in ${SERVICES[*]};
|
for service in ${SERVICES[*]};
|
||||||
do
|
do
|
||||||
echo "Starting EDEX Camel ($service): "
|
echo "Starting EDEX Camel ($service): "
|
||||||
|
|
Loading…
Add table
Reference in a new issue