Hi,
I want to add a route for the camel-azure component 2.23.0 in pure JavaDSL with
no Spring. Documentation
https://github.com/apache/camel/blob/master/components/camel-azure/src/main/docs/azure-blob-component.adoc
only recommends to set the credentials and client options with a bean, but I
can't get that to work. How to set the options directly in the URI is not
described.
Without bean I get an exception like this:
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.6.0:java
(default-cli) on project testjava: An exception occured while executing the
Java class. Failed to create route route1:
Route(route1)[[From[azure-blob:/shared1/mxtest/blabla?azureB... because of
Failed to resolve endpoint:
azure-blob:///shared1/mxtest/blabla?azureBlobClient=client due to: Could not
find a suitable setter for property: azureBlobClient as there isn't a setter
method with same type: java.lang.String nor type conversion possible: No type
converter available to convert from type: java.lang.String to the required
type: com.microsoft.azure.storage.blob.CloudBlob with value client
With bean it is the same error "no type converter...with value #clientreg" - I
assume the bean lookup does not work - would be my 2. question how to fix
that..
The azureBlobClient option must be of type CloudBlockBlob, credentials of type
StorageCredentials.
How can I set the required credentials or client options in the URI ?
Peter
package testjava;
import org.apache.camel.*;
import org.apache.camel.impl.SimpleRegistry;
import org.apache.camel.language.Bean;
import org.apache.camel.main.Main;
import org.apache.camel.CamelContext;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.builder.RouteBuilder;
import com.microsoft.azure.storage.*;
import com.microsoft.azure.storage.blob.*;
public class MainApp
{
public static class ClientBean
{
public CloudBlockBlob client()
{
try
{
StorageCredentials creds = new
StorageCredentialsAccountAndKey("shared1", "here gooes my key jG/zyK....");
StorageUri storageURI = new
StorageUri(new java.net.URI("https://shared1.blob.core.windows.net/mxtest"));
CloudBlockBlob client = new
CloudBlockBlob(storageURI, creds);
return client;
}
catch(Exception e)
{
return null;
}
}
}
public static void main(String... args) throws Exception
{
SimpleRegistry myregistry = new SimpleRegistry();
CamelContext mycontext = new
DefaultCamelContext(myregistry);
myregistry.put("clientreg", new ClientBean());
// as bean does not work, I try to set the stuff
directly:
StorageCredentials creds = new
StorageCredentialsAccountAndKey("shared1", "here goes my key");
StorageUri storageURI = new StorageUri(new
java.net.URI("https://shared1.blob.core.windows.net/mxtest"));
CloudBlockBlob client = new CloudBlockBlob(storageURI,
creds);
mycontext.addRoutes
(new RouteBuilder()
{
@Override
public void
configure()
{
//bean does not work:
from("azure-blob:/shared1/mxtest/blabla?azureBlobClient=#clientreg")
from("azure-blob:/shared1/mxtest/blabla?azureBlobClient=client")
.to("file:c:\\mx\\source");
}
}
);
mycontext.start();
}
}
Knorr-Bremse Systeme für Schienenfahrzeuge GmbH
Sitz: München
Geschäftsführer: Dr. Jürgen Wilder (Vorsitzender), Mark Cleobury, Dr. Nicolas
Lange, Dr. Peter Radina, Harald Schneider
Vorsitzender des Aufsichtsrats: Klaus Deller
Registergericht München, HR B 91 181
This transmission is intended solely for the addressee and contains
confidential information.
If you are not the intended recipient, please immediately inform the sender and
delete the message and any attachments from your system.
Furthermore, please do not copy the message or disclose the contents to anyone
unless agreed otherwise. To the extent permitted by law we shall in no way be
liable for any damages, whatever their nature, arising out of transmission
failures, viruses, external influence, delays and the like.