1

I m trying to set a filename in my application.properties file. It work well when I use the file component as exaplained here : Smallrye doc

Notice that im in a quarkus context so I hava to double the $ as explained in the doc.

However I don't need to write in a file but in an azure blob. And things become more complicated with it.

Here is my configuration : mp.messaging.outgoing.water.endpoint-uri=azure-blob://xxxxxx/xxxxx/xxxx/xxxxx-${date:now:ddMMyyyy-hh:mm:ss}.json?credentials=#credentials&operation=updateBlockBlob

If I double the $ I got the following stacktrace :

2020-06-26 19:21:02,204 WARN  [org.apa.cam.com.rea.str.ReactiveStreamsConsumer] (Camel (camel-1) thread #0 - reactive-streams://87687045129B977-0000000000000000) Error processing exchange. Exchange[8768704512
9B977-0000000000000001]. Caused by: [java.lang.IllegalArgumentException - Illegal character in path at index 86: https://zstalrsdsmdatarec01.blob.core.windows.net/materiel/MTD-niveaudeau/niveaudeau-${date:now
:ddMMyyyy-hh:mm:ss}.json]: java.lang.IllegalArgumentException: Illegal character in path at index 86: https://zstalrsdsmdatarec01.blob.core.windows.net/materiel/MTD-niveaudeau/niveaudeau-${date:now:ddMMyyyy-h
h:mm:ss}.json                                                                                                                                                                                                   
        at java.net.URI.create(URI.java:852)                                                                                                                                                                    
        at org.apache.camel.component.azure.blob.BlobServiceUtil.prepareStorageBlobUri(BlobServiceUtil.java:214)                                                                                                
        at org.apache.camel.component.azure.blob.BlobServiceUtil.prepareStorageBlobUri(BlobServiceUtil.java:196)                                                                                                
        at org.apache.camel.component.azure.blob.BlobServiceUtil.createBlockBlobClient(BlobServiceUtil.java:135)                                                                                                
        at org.apache.camel.component.azure.blob.BlobServiceProducer.updateBlockBlob(BlobServiceProducer.java:140)                                                                                              
        at org.apache.camel.component.azure.blob.BlobServiceProducer.process(BlobServiceProducer.java:80)                                                                                                       
        at org.apache.camel.support.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:67)                                                                
        at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:174)                                                                                                                             
        at org.apache.camel.processor.errorhandler.RedeliveryErrorHandler$SimpleTask.run(RedeliveryErrorHandler.java:396)                                                                                       
        at org.apache.camel.impl.engine.DefaultReactiveExecutor$Worker.schedule(DefaultReactiveExecutor.java:153)                                                                                               
        at org.apache.camel.impl.engine.DefaultReactiveExecutor.scheduleMain(DefaultReactiveExecutor.java:60)                                                                                                   
        at org.apache.camel.processor.Pipeline.process(Pipeline.java:147)                                                                                                                                       
        at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:286)                                                                                                           
        at org.apache.camel.component.reactive.streams.ReactiveStreamsConsumer.lambda$doSend$3(ReactiveStreamsConsumer.java:100)                                                                                
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)                                                                                                                      
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)                                                                                                                      
        at java.lang.Thread.run(Thread.java:748)                                                                                                                                                                
Caused by: java.net.URISyntaxException: Illegal character in path at index 86: https://zstalrsdsmdatarec01.blob.core.windows.net/materiel/MTD-niveaudeau/niveaudeau-${date:now:ddMMyyyy-hh:mm:ss}.json          
        at java.net.URI$Parser.fail(URI.java:2848)                                                                                                                                                              
        at java.net.URI$Parser.checkChars(URI.java:3021)                                                                                                                                                        
        at java.net.URI$Parser.parseHierarchical(URI.java:3105)                                                                                                                                                 
        at java.net.URI$Parser.parse(URI.java:3053)                                                                                                                                                             
        at java.net.URI.<init>(URI.java:588)                                                                                                                                                                    
        at java.net.URI.create(URI.java:850)                                                                                                                                                                    
        ... 16 more                                                                                                                                                                                             

So I tried not to double the $. I don't have any error but in that case the filename looks like this in azure : MTD-niveaudeau/niveaudeau-now:ddMMyyyy-hh:mm:ss.json

I also tried to use the $simple{ } placeholder with no success.

I really want to use the @Outgoing annotation instead of writing like this :

@Incoming( "xxxxxxxx" )
    public void consume( final String message){

        log.info( "Incoming message : {}", message );

        final String now = LocalDateTime.now().format(DateTimeFormatter.ofPattern("ddMMyyyy-HH:mm:ss"));

        Multi
                .createFrom()
                .completionStage( camel
                        .createProducerTemplate()
                        .asyncSendBody(
                                "azure-blob://xxxxxxx/xxxxx/xxxxxx/xxxxx-"+now+".json?credentials=#credentials&operation=updateBlockBlob"
                                , message.toString() )
                )
                .subscribe()
                .with( e ->
                        log.info( "Message successfullt sent to azure" )
                )
        ;
    }

How to do it ?

Thank you!

bdeweer
  • 135
  • 1
  • 14
  • I dont know if `camel-smallrye` supports dynamic URI in configuration. This works with file component, because `fileName` is translated with File Language by component itself, it is not handled by framework. – Bedla Jun 27 '20 at 15:51
  • Thanx for answer, is it possible to improve smallrye to support it? I like the way to configure endpoint by configuration file but it would be super nice to allow dynamic uri on it! May I open a feature request in smallrye? – bdeweer Jun 27 '20 at 21:46
  • Only small part of code is in Smallrye. The main logic relevant for you is implemented in [camel-reactive-streams](https://github.com/apache/camel/tree/master/components/camel-reactive-streams). Can you ask on gitter ( https://gitter.im/apache/apache-camel ) before opening Jira issue? Just to check, If it is actually really not supported. – Bedla Jun 27 '20 at 23:42

0 Answers0