Re: Handle first delivery failure differently then all following retries?

2014-10-30 Thread John Taylor
dunnlow  writes:

> I'm using Camel 2.10.3 and Spring 3.1 with XML route configuration.   I have
> a transacted route that is getting messages from several different sources
> (and saving them to a database).  When there is an exception writing to the
> database I want to send an alert (a web service) on the FIRST roll back.  In
> other words, when the database is down, I want to keep retying the database,
> but I don't want to send an alert for every retry.
>
> For JMS I know I can look at the JMSRedelivered header, but for other
> endpoints (ie file) I don't know how to check for a redelivered message.  As
> I understand it, there isn't a way.
>
> I'm considering pushing every non-JMS message that fails to the JMS queue
> perhaps with a custom header.  If I do that, is there a way to add that
> custom header to the message that is getting rolled back from my JMS queue
> (the first time)?  Is there a better way to implement this?
>
> Thanks -J
>
>
>
>
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Handle-first-delivery-failure-differently-then-all-following-retries-tp5757453.html
> Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Blueprint RouteContext Error

2020-11-19 Thread John Taylor
Hi Joe,
That error you see is that the blueprint xml file failed validation, and
that is because import is not a valid element in the blueprint schema.

Invalid content was found starting with element '{"
http://www.osgi.org/xmlns/blueprint/v1.0.0":import}'.

Indeed, importing other xml documents into blueprint isn't allowed at all.
You're using the fileinstall blueprint deployer (files dropped into deploy)
and that will mean each file is generated into one osgi bundle (see
http://karaf.apache.org/manual/latest/#_deployers )
The way I run camel-in-karaf includes blueprint deployer as well, where
each bundle (blueprint file) defines a camel context. If i need
communication across bundles / contexts in the same karaf env, that's done
either through messaging (JMS) or with direct-vm, although those are not
the only options.

-John



On Thu, Nov 19, 2020 at 2:57 PM Robert Dean  wrote:

> I have been learning Karaf and Camel for about 8 months. I am working on
> designing my first Karaf / Camel solution. I am trying to understand how I
> can split up the solution with multiple blueprint xml files. At this point
> I am just trying to get the examples from 2015 working. I am using Karaf
> 4.2.8 and Camel 3.4.0.  I am getting an error on the loading of the Camel
> Context. I am using two (2) xml files.
>
>
>
> I have been looking at this type of sample:
> http://camel.465427.n5.nabble.com/blueprint-routeContext-tag-prevents-Camel-from-starting-td5770023.html
>
>
>
> *Installed Camel components: (all show started)*
>
>- xml-specs-api 2.9.0
>- camel-core  3.4.0
>- camel-blueprint 3.4.0
>- camel-jms3.4.0
>- camel-mllp  3.4.0
>- camel-stream 3.4.0
>
>
>
> *ContextMain.xml*
>
> 
>
> http://www.w3.org/2001/XMLSchema-instance";
>
>xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
>
>xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
> http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd";>
>
>
>
> 
>
>
>
> http://camel.apache.org/schema/blueprint";>
>
> 
>
> 
>
> 
>
>
>
> *global_routes.xml*
>
> 
>
> http://www.w3.org/2001/XMLSchema-instance";
>
>xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
>
>xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
> http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd";>
>
> http://camel.apache.org/schema/blueprint";>
>
> 
>
> 
>
> 
>
> global message [${date:now:-MM-dd
> HH:mm:ss}]
>
> 
>
> 
>
>
>
> 
>
> 
>
>
>
> *Here is the error from Hawtio:*
>
> Timestamp
>
> 2020-11-19 09:27:28
>
> Level
>
> ERROR
>
> Logger
>
> org.apache.aries.blueprint.container.BlueprintContainerImpl
>
> Class
>
> org.apache.aries.blueprint.container.BlueprintContainerImpl
>
> Method
>
> doRun
>
> File
>
> BlueprintContainerImpl.java:460
>
> Thread
>
> fileinstall-/home/administrator/dev/karaf-4.2.8/deploy
>
> Message
>
> Unable to start container for blueprint bundle ContextMain.xml/0.0.0
>
> Stack Trace
>
> · org.osgi.service.blueprint.container.ComponentDefinitionException:
> Unable to validate xml
>
> · at
> org.apache.aries.blueprint.parser.Parser.validate(Parser.java:349)
> ~[!/:1.10.2]
>
> · at
> org.apache.aries.blueprint.parser.Parser.validate(Parser.java:336)
> ~[!/:1.10.2]
>
> · at
> org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:365)
> [!/:1.10.2]
>
> · at
> org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:298)
> [!/:1.10.2]
>
> · at
> org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:311)
> [!/:1.10.2]
>
> · at
> org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:280)
> [!/:1.10.2]
>
> · at
> org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:276)
> [!/:1.10.2]
>
> · at
> org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:266)
> [!/:1.10.2]
>
> · at
> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)
> [!/:1.10.2]
>
> · at
> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)
> [!/:1.10.2]
>
> · at
> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)
> [!/:1.10.2]
>
> · at
> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)
> [!/:1.10.2]
>
> · at
> org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHoo

Re: Using Camel, Blueprint (Aries), OSGI and Spring - Place holder issue

2021-09-16 Thread John Taylor
Hi,

A single property-placeholder is only going to allow one backing
persistent-id.
You can instead create multiple property-placeholders with different ids,
e.g.
  https://stackoverflow.com/questions/50354932/how-to-use-multiple-property-placeholder-in-jboss-fuse-blueprint

Hope that helps.
-John

On Thu, Sep 16, 2021 at 7:58 AM Andrei Petru Mura 
wrote:

> Hi all,
>
> I'm trying to migrate my camel routes from an older karaf using Spring-DM
> to a newer one using Blueprint. For this, I intend to import my spring XML
> configuration in my blueprint XML file. The camel context is defined in the
> blueprint XML file.
> Currently I'm stuck with a placeholder issue. I'm trying to import some
> configuration properties from OSGI environment which are stored in a few
> files under the ${karaf.home}/etc directory.
> I tried many ways according to this documentation page (
> https://camel.apache.org/components/2.x/properties-component.html), but
> still not getting the functionality which I want.
>
> On short, I want to be able to define in my XML files (blueprint, spring)
> some default values for some properties, overriding them with the
> configurations found in the configuration files from ${karaf.home}/etc/ and
> be able to use them in in both blueprint XML and spring XML files.
> Preferable by ${variableName}.
>
> Currently, I did this:
>
> Blueprint XML:
>
> http://www.osgi.org/xmlns/blueprint/v1.0.0";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xmlns:bean="http://www.springframework.org/schema/beans";
> xmlns:camel="http://camel.apache.org/schema/spring";
> xmlns:osgix="http://www.springframework.org/schema/osgi-compendium";
> xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0";
> xsi:schemaLocation="
> http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd
> http://camel.apache.org/schema/spring
> http://camel.apache.org/schema/spring/camel-spring.xsd
> http://www.springframework.org/schema/osgi-compendium
>
> http://www.springframework.org/schema/osgi-compendium/spring-osgi-compendium.xsd
> ">
>
>  persistent-id="edigrid.persistence,edigrid.server.id
> ,edigrid.cluster,edigrid.ftpconfig,edigrid.reports">
> ...
> 
>
> ...
>
> 
> 
> ... accessing ${configVarHere1}
> 
> 
> 
>
> http://www.springframework.org/schema/beans";
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xmlns:ctx="http://www.springframework.org/schema/context";
> xsi:schemaLocation="http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans.xsd
> http://www.springframework.org/schema/context
> http://www.springframework.org/schema/context/spring-context.xsd";>
>
> 
>
>  class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
> 
>
> ...accessing ${configVarHere2}
> 
> 
>
> I get this kind of error (because of spring XML):
> Failed to convert property value of type 'java.lang.String' to required
> type 'int' for property 'configPropName'; nested exception is
> java.lang.NumberFormatException: For input string: "${configProprName}"
>
> after I get a few messages like:
> The property placeholder processor for ${, } in bundle
> bundleName/BundleVersion found an immutable Constructor Argument at
> location Bean named beanName->Argument index -1 and value type null->. This
> may prevent properties, beans, or other items referenced by this component
> from being properly processed.
>
> Any idea how I can solve my issue?
>
> Thanks,
> Mura Andrei
>


Re: Camel 3.21 & groovy scripting - Class loading errors

2023-11-13 Thread John Taylor
Hi,
I also use camel in karaf with groovy.

Although it shows in the exports, groovy xml is not included in the groovy
package from org.codehaus.groovy/groovy/3.0.8 but is in a different bundle
so you have to add it.

You can do that with
install mvn:org.codehaus.groovy/groovy-xml/3.0.8
Or you can include it in your own feature.

-John



On Mon, Nov 13, 2023 at 10:47 AM Ephemeris Lappis <
ephemeris.lap...@gmail.com> wrote:

> Hello.
>
> I'm migrating camel projects from old Camel 2.x to Camel 3.21.
>
> Camel routes are deployed as OSGi blueprints to be executed in Karaf.
>
> I have a strange exception I had not before about some Groovy classes
> that are not found while the groovy scripts seem to be executed.
>
> My bundle manifest declares a dynamic import for groovy scripting (and
> quartz) :
>
> DynamicImport-Package =
> groovy.*,
> org.codehaus.groovy.*,
> org.apache.camel.pollconsumer.*
>
> But classes in package groovy.xml are not resolved as expected.
> Statements like this :
>
> 
> new
> groovy.xml.XmlParser().parse(request.getBody(File.class))
> 
>
> Fails with the following error :
>
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup
> failed:
> Script_bb14d11f44acc4f9bf59e5db81b864e4.groovy: 3: unable to resolve
> class groovy.xml.XmlParser
>
> When I check exports and imports, all seems to be ok :
>
> admin@root()> exports | grep groovy.xml
> groovy.xml
>   │ 3.0.8 │ 883 │ groovy
>
> admin@root()> imports | grep groovy | grep 975
> groovy.*
>   (0x  ││ 975 │
> caterpillar-switch
> org.codehaus.groovy.*
>   (0x  ││ 975 │
> caterpillar-switch
>
> What has changed in groovy scripting that could be the cause of these
> errors ? It seems the script classloader doesn't include the dynamic
> import.
>
> Thanks for your help.
>
> Regards.
>


Re: Camel ScheduledPollEndpoint class scheduler setup in SqlComponent

2016-06-04 Thread John Taylor
Hi. If that really is your xml it's because you're not escaping the &. You
have to use & entity ref in the endpoint uri
-John
On Jun 3, 2016 2:12 AM, "qwertywx"  wrote:

hi,

I have created an endpoint like:



But when I do that, jvm throws:

org.apache.camel.FailedToCreateConsumerException: Failed to create Consumer
for endpoint: Endpoint[sql://$select * from
dual?dataSourceRef=veloxityDS&scheduler=spring&scheduler.cron=0+6+8++&useIterator=false].
Reason: There are 1 scheduler parameters that couldn't be set on the
endpoint. Check the uri if the parameters are spelt correctly and that they
are properties of the endpoint. Unknown parameters=[{cron=0 6 8 * *}]

I have read documents and inspected source code about it, debugged it. As
far as I have seen,
org.apache.camel.impl.ScheduledPollEndpoint.configureScheduledPollConsumerProperties(Map, Map) method is running before
org.apache.camel.impl.ScheduledPollEndpoint.setScheduler(String) .

So the first method always try to initialize scheduler as default camel
scheduler.

Am I missing something or is this really a bug?

It still gives exception. The only case that it initialize scheduler
correctly is , when I create a spring bean and give it like
..scheduler=#scheduler

Thx



--
View this message in context:
http://camel.465427.n5.nabble.com/Camel-ScheduledPollEndpoint-class-scheduler-setup-in-SqlComponent-tp5783390.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: camel sql joined query with parameters won't run on sql server

2016-06-25 Thread John Taylor

Hi Ronny,
I had the same kind of problem recently and it turned out to be
something to do with the driver not correctly returning the number of
parameters. I ended up needing to use the parametersCount option. It is
described at http://camel.apache.org/sql-component.html
Regards,

-John



Ronny Aerts  writes:

> Hello camel user community,
>
> I have strange problem with a Microsoft sql server database joined query 
> where I would like to have some advice.
>
> I have 2 spring dsl steps in a route:
> 
> 
>
> The siteno and locationno are in a header.
> Both steps run perfectly good in a firebird database and produce following 
> logs:
> [org.apache.camel.component.sql.DefaultSqlPrepareStatementStrategy]
> Prepared query: select s.SITENAME, l.LOCATIONNAME from VGMSITE s,
> VGMLOCATION l where l.SITENO=? and l.LOCATIONNO=? and
> s.SITENO=l.SITENO
> [org.apache.camel.component.sql.DefaultSqlPrepareStatementStrategy] Setting 
> parameter #1 with value: 1
> [org.apache.camel.component.sql.DefaultSqlPrepareStatementStrategy] Setting 
> parameter #2 with value: 1
> [org.apache.camel.component.sql.SqlProducer] Got result list from
> query: org.apache.commons.dbcp.DelegatingResultSet@7270bbb6,
> outputType=SelectOne
> [sql-output] Exchange[
> , Id: ID-LPT-030915-001-59524-1466882394560-0-25
> , ExchangePattern: InOut
> , Properties: {CamelCreatedTimestamp=Sat Jun 25 21:20:18 CEST 2016,
> CamelFilterMatched=true,
> CamelMessageHistory=[DefaultMessageHistory[routeId=dpwa.solas.vgm.location.route,
> node=setHeader16],
> DefaultMessageHistory[routeId=dpwa.solas.vgm.location.route,
> node=log17],
> DefaultMessageHistory[routeId=dpwa.solas.vgm.location.route,
> node=choice7],
> DefaultMessageHistory[routeId=dpwa.solas.vgm.location.route,
> node=to30],
> DefaultMessageHistory[routeId=dpwa.solas.vgm.location.route,
> node=to31]],
> CamelToEndpoint=log://sql-output?ShowAll=true&multiline=true}
> , Headers: {accept=application/json, text/javascript, */*; q=0.01,
> accept-encoding=gzip, deflate, sdch,
> accept-language=en-GB,en;q=0.8,en-US;q=0.6,nl;q=0.4,
> breadcrumbId=ID-LPT-030915-001-59524-1466882394560-0-23,
> cache-control=max-age=0, CamelCreatedTimestamp=Sat Jun 25 21:20:18
> CEST 2016, CamelHttpMethod=GET, CamelHttpPath=,
> CamelHttpQuery=siteno=1&locationno=1,
> CamelHttpServletRequest=org.apache.catalina.connector.RequestFacade@bd60042,
> CamelHttpServletResponse=org.apache.catalina.connector.ResponseFacade@44782f90,
> CamelHttpUri=/TrisESB-dpwa-dvl-vgm%23%232016.06.14/web/camel/dpwa/vgm/location.ajax,
> CamelHttpUrl=http://lpt-030915-001:8080/TrisESB-dpwa-dvl-vgm%23%232016.06.14/web/camel/dpwa/vgm/location.ajax,
> CamelServletContextPath=/dpwa/vgm/location.ajax, CamelSqlRowCount=1,
> connection=keep-alive, Content-Type=null,
> cookie=JSESSIONID=C54F4B1B756A13257236FF39067522EB,
> host=lpt-030915-001:8080, locationno=1,
> referer=http://lpt-030915-001:8080/TrisESB-dpwa-dvl-vgm%23%232016.06.14/web/vgmweigher.jsp?siteno=1&locationno=1,
> siteno=1, user-agent=Mozilla/5.0 (Windows NT 10.0; WOW64)
> AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103
> Safari/537.36, x-requested-with=XMLHttpRequest}
> , BodyType: org.springframework.util.LinkedCaseInsensitiveMap
> , Body: {SITENAME=AGW, LOCATIONNAME=yard}
> , Out: null:
> ]
>
> When I run exactly the same query in a sql driver db (with
> driver=com.microsoft.sqlserver.jdbc.SQLServerDriver and
> url=jdbc:sqlserver://lpt-030915-001;databaseName=dpwa-solas-vgm;integratedSecurity=true),
> I get an error The multi-part identifier "l.SITENO" could not be
> bound.
> The log don't show the "Setting parameter" lines but I don't know why.
>
> The logs for sql server:
> [org.apache.camel.component.sql.DefaultSqlPrepareStatementStrategy]
> Prepared query: select s.SITENAME, l.LOCATIONNAME from VGMSITE s,
> VGMLOCATION l where l.SITENO=? and l.LOCATIONNO=? and
> s.SITENO=l.SITENO
> [org.springframework.beans.factory.xml.XmlBeanDefinitionReader]
> Loading XML bean definitions from class path resource
> [org/springframework/jdbc/support/sql-error-codes.xml]
> [org.springframework.jdbc.support.SQLErrorCodesFactory] SQLErrorCodes
> loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle,
> PostgreSQL, Sybase, Hana]
> [org.apache.camel.processor.DefaultErrorHandler] Failed delivery for
> (MessageId: ID-LPT-030915-001-59810-1466882533439-0-16 on ExchangeId:
> ID-LPT-030915-001-59810-1466882533439-0-18). Exhausted after delivery
> attempt: 1 caught: org.springframework.jdbc.UncategorizedSQLException:
> PreparedStatementCallback; uncategorized SQLException for SQL []; SQL
> state [null]; error code [0];
> com.microsoft.sqlserver.jdbc.SQLServerException: The multi-part
> identifier "l.SITENO" could not be bound.; nested exception is
> com.microsoft.sqlserver.jdbc.SQLServerException:
> com.microsoft.sqlserver.jdbc.SQLServerException: The multi-part
> identifier "l.SITENO" could not be bound.
>
> When I do a sql server query with only one table, everything works just fine.
>
> 

Re: Is GenericFileOperationFailedException handled differently than other exceptions?

2016-10-27 Thread John Taylor
Klaus Johansen  writes:

> Hi all,
>
> I have used a lot time configuring a deadLetterChannel errorHandler and a
> custom PollingConsumerPollStrategy for our PollingConsumers (mostly sFTP
> and FTPS).
>
> In combination with "throwExceptionOnConnectFailed=true" and
> "consumer.bridgeErrorHandler=true" we have a generally robust setup, where
> the Camel error-handler handles both consumer and producer errors. It does
> redelivery and sends an alert when exhausted. This allows us to handle e.g.
> connection timeouts to FTP servers in both consumer and producer in the
> same controlled way.
>
> Recently we had several situations with FTP error code 150 (e.g. socket
> timeouts) which ends up in an org.apache.camel.component.file.
> GenericFileOperationFailedException.
>
> Similar if the FTP server replies with "550 File not found, access denied."
> it results in the following exception:
>
> org.apache.camel.component.file.GenericFileOperationFailedException: Cannot
> retrieve file: RemoteFile[TestFil.XML] from: Endpoint[ftp://127.0.0.1:21/?
> autoCreate=false&binary=true&consumer.bridgeErrorHandler=
> true&delete=true&disconnect=true&doneFileName=%24%7Bfile%3Aname%7D.SEM&
> 
>  include=%28%3Fi%29.*%5C.XML&localWorkDirectory=c%3A%5Ctest%5Cftpworkdir&
> maximumReconnectAttempts=0&passiveMode=true&password=xx&pollStrategy=%
> 23poll30times&readLock=none&reconnectDelay=24&
> scheduler=spring&scheduler.cron=30+*+*+*+*+MON-FRI&stepwise=false&
> throwExceptionOnConnectFailed=true&username=testuser]
>
> According to the log, the GenericFileOperationFailedException is directly
> followed by the configured "onPrepareFailure" processor and then handled by
> the "FatalFallbackErrorHandler". As a result the "commit" method of the
> custom PollingConsumerPollStrategy is invoked and no redelivery attempted.
>
> Is GenericFileOperationFailedException handled differently by the Camel
> Error Handler than other exceptions? - Or is it a bug?
>
> If working as designed: Can I somehow configure an onException section or
> something different to override this behaviour?
>
> I'm currently using camel 2.17.3.
>
> Best regards,
> Klaus


Re: Using a specific bundle version (in Karaf in Blueprint/Camel context route.

2015-11-10 Thread John Taylor
rwoolf  writes:

> My blueprint xml file is my "bundle."  I drop the blueprint xml file into
> the deploy directory.  I have two different blueprint xml files for the two
> different contexts.  So in this regard they are different bundles.  But
> they are not packaged as jar based bundles.  I'm guessing from what you
> said that neither blueprint or camel will be able to provide any means to
> declare a specific version dependency.  I would need to package these
> blueprint xml files into real jar bundles in order to be able to declare
> version dependencies.  Am I right?
>
> It would be really nice if I could declare a version dependency in the
> blueprint xml file and then just deploy that xml file.  Since blueprint is
> geared towards OSGi it would be great if I could do something like this.
>

The version imports are going to be a function of the osgi deployment,
and in this specific case would be driven by the Karaf "Blueprint
Deployer" see [1], specifically the section on customizing the generated
manifest where it shows

http://karaf.apache.org/xmlns/deployer/blueprint/v1.0.0";>
Require-Bundle= my-bundle


The Require-Bundle header is documented at osgi.org at [2].

[1] https://karaf.apache.org/manual/latest/users-guide/deployers.html
[2] http://wiki.osgi.org/wiki/Require-Bundle


Hope that helps.
-John