[
https://issues.apache.org/jira/browse/CAMEL-12989?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16717102#comment-16717102
]
ASF GitHub Bot commented on CAMEL-12989:
----------------------------------------
davsclaus closed pull request #2664: CAMEL-12989 Allow Endpoint to set the key
that ProducerCache uses
URL: https://github.com/apache/camel/pull/2664
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/camel-core/src/main/java/org/apache/camel/Endpoint.java
b/camel-core/src/main/java/org/apache/camel/Endpoint.java
index 2069b8f6b98..e6d587f8ce7 100644
--- a/camel-core/src/main/java/org/apache/camel/Endpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/Endpoint.java
@@ -59,6 +59,14 @@
*/
String getEndpointKey();
+ /**
+ * Key that allows multiple endpoints to be associated with the same URI
+ * Allows for different configurations on the same endpoint e.g. multiple
SSL certificates
+ * @return
+ */
+ String getProducerCacheKey();
+ void setProducerCacheKey(String key);
+
/**
* Create a new exchange for communicating with this endpoint
*
diff --git
a/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
b/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
index 4b6b6ad0d64..db6fe912085 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/DefaultEndpoint.java
@@ -89,6 +89,9 @@
private boolean pollingConsumerBlockWhenFull = true;
private long pollingConsumerBlockTimeout;
+ // key that producer cache will use
+ private String producerCacheKey;
+
/**
* Constructs a fully-initialized DefaultEndpoint instance. This is the
* preferred method of constructing an object from Java code (as opposed to
@@ -548,4 +551,18 @@ protected void doStart() throws Exception {
protected void doStop() throws Exception {
// noop
}
+
+ @Override
+ public String getProducerCacheKey() {
+ if (producerCacheKey == null) {
+ // return URI as the default if no key is set
+ return getEndpointUri();
+ }
+ return this.producerCacheKey;
+ }
+
+ @Override
+ public void setProducerCacheKey(String key) {
+ this.producerCacheKey = key;
+ }
}
diff --git
a/camel-core/src/main/java/org/apache/camel/impl/InterceptSendToEndpoint.java
b/camel-core/src/main/java/org/apache/camel/impl/InterceptSendToEndpoint.java
index b4d1d906fd4..aae8239b10d 100644
---
a/camel-core/src/main/java/org/apache/camel/impl/InterceptSendToEndpoint.java
+++
b/camel-core/src/main/java/org/apache/camel/impl/InterceptSendToEndpoint.java
@@ -148,4 +148,14 @@ public void shutdown() throws Exception {
public String toString() {
return delegate.toString();
}
+
+ @Override
+ public String getProducerCacheKey() {
+ return delegate.getProducerCacheKey();
+ }
+
+ @Override
+ public void setProducerCacheKey(String key) {
+ delegate.setProducerCacheKey(key);
+ }
}
diff --git a/camel-core/src/main/java/org/apache/camel/impl/ProducerCache.java
b/camel-core/src/main/java/org/apache/camel/impl/ProducerCache.java
index 95314947f29..57fa3728fed 100644
--- a/camel-core/src/main/java/org/apache/camel/impl/ProducerCache.java
+++ b/camel-core/src/main/java/org/apache/camel/impl/ProducerCache.java
@@ -560,7 +560,7 @@ protected AsyncProcessor prepareProducer(Producer producer)
{
}
protected synchronized Producer doGetProducer(Endpoint endpoint, boolean
pooled) {
- String key = endpoint.getEndpointUri();
+ String key = endpoint.getProducerCacheKey();
Producer answer = producers.get(key);
if (pooled && answer == null) {
// try acquire from connection pool
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Allow Endpoint to set the key that ProducerCache uses
> -----------------------------------------------------
>
> Key: CAMEL-12989
> URL: https://issues.apache.org/jira/browse/CAMEL-12989
> Project: Camel
> Issue Type: Improvement
> Components: camel-core
> Affects Versions: 2.23.0
> Reporter: Richard Davis
> Priority: Minor
> Labels: features
>
> ProducerCache is heavily tied to Endpoint URIs. Using the Endpoint URI as the
> key to the cache does not allow for the creation of Endpoints with the same
> URI but different configurations. For example, using a RecipientList to call
> the same SOAP endpoint but with different SSL certificates isn't currently
> possible. As the URI is always the same.the ProducerCache will always use the
> first Endpoint it added to the map even if multiple Endpoints are added to
> the CamelContext with different keys.
> Adding getProducerCacheKey & setProducerCacheKey methods to the Endpoint
> interface would allow for setting the key programmatically.
> ProducerCache.doGetProducer would use the getProducerCacheKey method instead
> of getEndpointUri.
> DefaultEndpoint would have a new member variable producerCacheKey and could
> implement the getter such that if the producerCacheKey member was not set it
> would return getEndpointUri()
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)