diff --git a/exn-connector/build.gradle b/exn-connector/build.gradle index 7adbfc4..29582ee 100644 --- a/exn-connector/build.gradle +++ b/exn-connector/build.gradle @@ -15,9 +15,7 @@ dependencies { // Use the latest Groovy version for building this library implementation 'org.codehaus.groovy:groovy-all:3.0.10' - // This dependency is used internally, and not exposed to consumers on their own compile classpath. - implementation 'com.google.guava:guava:31.0.1-jre' - implementation group: 'org.apache.qpid', name: 'protonj2-client', version: '1.0.0-M16' + api group: 'org.apache.qpid', name: 'protonj2-client', version: '1.0.0-M16' implementation group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.12' implementation group: 'org.aeonbits.owner', name: 'owner', version: '1.0.12' diff --git a/exn-connector/src/main/examples/eu/nebulouscloud/exn/TestPublisher.java b/exn-connector/src/main/examples/eu/nebulouscloud/exn/TestPublisher.java index baffca3..de8379a 100644 --- a/exn-connector/src/main/examples/eu/nebulouscloud/exn/TestPublisher.java +++ b/exn-connector/src/main/examples/eu/nebulouscloud/exn/TestPublisher.java @@ -39,9 +39,9 @@ class MyPublisherTestConnectorHandler extends ConnectorHandler { developer, a check never did any harm. The state publisher is a core publisher with the required - methods to pubilsh component state. + methods to publish component state. - Calling these methods and bootstraing them into the application + Calling these methods and bootstrapping them into the application logic falls on the developer. */ @@ -70,7 +70,7 @@ class MyPublisherTestConnectorHandler extends ConnectorHandler { "one" ); (context.getPublisher("config")).send( - Map.of("hello","world"), + Map.of("good","bye"), "two" ); @@ -105,7 +105,8 @@ class TestPublisher{ "localhost", 5672, "admin", - "admin" + "admin", + 5 ) ); diff --git a/exn-connector/src/main/examples/eu/nebulouscloud/exn/TestReceiver.java b/exn-connector/src/main/examples/eu/nebulouscloud/exn/TestReceiver.java index 16c592b..8750386 100644 --- a/exn-connector/src/main/examples/eu/nebulouscloud/exn/TestReceiver.java +++ b/exn-connector/src/main/examples/eu/nebulouscloud/exn/TestReceiver.java @@ -81,7 +81,6 @@ class TestReceiver{ new Consumer("config_two","config", new Handler(){ @Override public void onMessage(String key, String address, Map body, Message rawMessage, Context context) { - System.out.println("These are my TWO config => "+ String.valueOf(body)); } },"two", true) diff --git a/exn-connector/src/main/groovy/eu/nebulouscloud/exn/Connector.groovy b/exn-connector/src/main/groovy/eu/nebulouscloud/exn/Connector.groovy index 8be3fe4..7c0c6a1 100644 --- a/exn-connector/src/main/groovy/eu/nebulouscloud/exn/Connector.groovy +++ b/exn-connector/src/main/groovy/eu/nebulouscloud/exn/Connector.groovy @@ -69,7 +69,6 @@ public class Connector { } this.config = configuration this.context = new Context( - "${configuration.url()}:${configuration.port()}", "${configuration.baseName()}.${this.component}", handler ) diff --git a/exn-connector/src/main/groovy/eu/nebulouscloud/exn/core/Context.groovy b/exn-connector/src/main/groovy/eu/nebulouscloud/exn/core/Context.groovy index fa87eaa..195914a 100644 --- a/exn-connector/src/main/groovy/eu/nebulouscloud/exn/core/Context.groovy +++ b/exn-connector/src/main/groovy/eu/nebulouscloud/exn/core/Context.groovy @@ -24,7 +24,6 @@ class Context { Logger logger = LoggerFactory.getLogger(Context.class) - private final String uri private final String base private final Map publishers = [:] private final Map consumers = [:] @@ -32,8 +31,7 @@ class Context { private Manager manager - public Context(String uri, String base, ConnectorHandler handler){ - this.uri = uri + public Context(String base, ConnectorHandler handler){ this.base = base this.handler = handler } @@ -98,6 +96,11 @@ class Context { } void registerPublisher(Publisher publisher) { + if(publishers.containsKey(publisher.key)){ + logger.warn("Trying to register a publisher that is already registered {}=>{} ",publisher.key(), publisher.address()) + return + } + publishers[publisher.key()] = publisher if(this.manager !=null && this.manager.getRunning()){ final Publisher p =publisher @@ -106,6 +109,10 @@ class Context { } void registerConsumer(Consumer consumer) { + if(consumers.containsKey(consumer.key)){ + logger.warn("Trying to register a consumer that is already registered {}=>{} ",consumer.key(),consumer.address()) + return + } logger.debug("Registering consumer {}=>{}",consumer.key(),consumer.address()) consumers[consumer.key()] = consumer if(this.manager !=null && this.manager.getRunning()){