Error sending email from Camel application

2017-12-21 Thread Charles Berger
Hi,

I have the following route in my application which sends an email
based on a template filled out with data from the SingleImageModel
class:

from(ACTIVEMQ_EMAIL_QUEUE)
.routeId(ROUTE_EMAIL_NOTIFICATIONS)
.convertBodyTo(SingleImageModel.class)
// set subject, from address & to address
.setHeader("subject", constant(EMAIL_SUBJECT))
.setHeader("to", simple("${body.email}"))
.setHeader("from", constant(EMAIL_FROM))
// format the message body
.to(VELOCITY_EMAIL)
.log("${body}")
// send email
.to(SMTP_URL)
.end();

When it tries to execute the SMTP step the message fails with the
following error:

2017-12-21 17:30:08,034 []
org.apache.camel.processor.DefaultErrorHandler ERROR - Failed delivery
for (MessageId: ID-iusa16025-local-1513877322283-0-13 on ExchangeId:
ID-iusa16025-local-1513877322283-0-11). Exhausted after delivery
attempt: 1 caught: org.apache.camel.TypeConversionException: Error
during type conversion from type: java.lang.String to the required
type: java.lang.String with value queue://emailQueue due
com.fasterxml.jackson.databind.JsonMappingException: No serializer
found for class java.util.Vector$1 and no properties discovered to
create BeanSerializer (to avoid exception, disable
SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain:
org.apache.activemq.command.ActiveMQQueue["reference"]->javax.naming.Reference["all"])

The stacktrace is:

org.apache.camel.TypeConversionException: Error during type conversion
from type: java.lang.String to the required type: java.lang.String
with value queue://emailQueue due
com.fasterxml.jackson.databind.JsonMappingException: No serializer
found for class java.util.Vector$1 and no properties discovered to
create BeanSerializer (to avoid exception, disable
SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain:
org.apache.activemq.command.ActiveMQQueue["reference"]->javax.naming.Reference["all"])
at 
org.apache.camel.impl.converter.BaseTypeConverterRegistry.createTypeConversionException(BaseTypeConverterRegistry.java:667)
at 
org.apache.camel.impl.converter.BaseTypeConverterRegistry.convertTo(BaseTypeConverterRegistry.java:158)
at org.apache.camel.component.mail.MailBinding.asString(MailBinding.java:717)
at 
org.apache.camel.component.mail.MailBinding.appendHeadersFromCamelMessage(MailBinding.java:398)
at 
org.apache.camel.component.mail.MailBinding.populateMailMessage(MailBinding.java:117)
at org.apache.camel.component.mail.MailProducer.process(MailProducer.java:58)
at 
org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)
at 
org.apache.camel.processor.SendProcessor$2.doInAsyncProducer(SendProcessor.java:178)
at org.apache.camel.impl.ProducerCache.doInAsyncProducer(ProducerCache.java:445)
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:173)
at 
org.apache.camel.processor.interceptor.TraceInterceptor.process(TraceInterceptor.java:181)
at 
org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:548)
at 
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:138)
at org.apache.camel.processor.Pipeline.process(Pipeline.java:101)
at 
org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:201)
at 
org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:97)
at 
org.apache.camel.component.jms.EndpointMessageListener.onMessage(EndpointMessageListener.java:112)
at 
org.springframework.jms.listener.AbstractMessageListenerContainer.doInvokeListener(AbstractMessageListenerContainer.java:719)
at 
org.springframework.jms.listener.AbstractMessageListenerContainer.invokeListener(AbstractMessageListenerContainer.java:679)
at 
org.springframework.jms.listener.AbstractMessageListenerContainer.doExecuteListener(AbstractMessageListenerContainer.java:649)
at 
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.doReceiveAndExecute(AbstractPollingMessageListenerContainer.java:317)
at 
org.springframework.jms.listener.AbstractPollingMessageListenerContainer.receiveAndExecute(AbstractPollingMessageListenerContainer.java:255)
at 
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.invokeListener(DefaultMessageListenerContainer.java:1166)
at 
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.executeOngoingLoop(DefaultMessageListenerContainer.java:1158)
at 
org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:1055)
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at 

Re: Set shutdown timeout with blueprint

2017-12-21 Thread Quinn Stevenson
I just tested a simple route in Karaf 4.0.10 and Camel 2.17.7, and it seems to 
work.  (I apologize for the messy route - it’s just one I had laying around and 
I’m not actually sure where I got it).  Given the route I used, I can create a 
my.camel.bp.cfg file in the $KARAF_HOME/etc directory and change the value of 
the timeout (the route will restart and the bean will show the new value is in 
use.

The Blueprint I used looks like this:


http://www.osgi.org/xmlns/blueprint/v1.0.0;
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0;
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
  http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0
 
http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd;>

http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0;
persistent-id="my.camel.bp"
update-strategy="reload">






 








http://camel.apache.org/schema/blueprint;
xsi:schemaLocation="http://camel.apache.org/schema/blueprint

http://camel.apache.org/schema/blueprint/camel-blueprint.xsd;>




${properties:my.label}:${body}













And the context-info-logger bean source is:

public class ContextInfoProcessor implements Processor{
  Logger log = LoggerFactory.getLogger(this.getClass());

  @Override
  public void process(Exchange exchange) throws Exception {
String units = "UNKNOWN";

switch (exchange.getContext().getShutdownStrategy().getTimeUnit()) {
  case NANOSECONDS:
units = "NANOSECONDS";
break;
  case MICROSECONDS:
units = "MICROSECONDS";
break;
  case MILLISECONDS:
units = "MILLISECONDS";
break;
  case SECONDS:
units = "SECONDS";
break;
  case MINUTES:
units = "MINUTES";
break;
  case HOURS:
units = "HOURS";
break;
  case DAYS:
units = "DAYS";
}
log.info("* Shutdown Timeout = {} {} *", 
exchange.getContext().getShutdownStrategy().getTimeout(), units);
  }
}

Can you share the full XML you are using?

Quinn Stevenson
qu...@pronoia-solutions.com
(801) 244-7758



> On Dec 21, 2017, at 3:27 AM, Michael Esmann  
> wrote:
> 
> camel.shutdownstrategy.timeout



Set shutdown timeout with blueprint

2017-12-21 Thread Michael Esmann
Hi,

I am using Apache Camel 2.17.3 and Karaf 4.0.6.
I would like to change the default shutdown startegy timeout with blueprint.
It works if I do it like this, with a hardcoded timeout value:


     


But I would like the timeout to be configurable with a property like this:


     


If I do it like this I get an error when deploying:

"Unable to start blueprint container for bundle MyBundle
org.osgi.service.blueprint.container.ComponentDefinitionException: Name 
MyShutdownStrategy is already instanciated as null and cannot be removed."

Even if I resolve this problem then I could be afraid that I will get 
another error because "timeout" property is a long value(?).

Any suggestions about how I can solve these problems?

Thanks,
Michael



AW: Camel Clustering

2017-12-21 Thread Burkard Stephan
Hi, 

For JMS you can simply deploy multiple instances of your module and then they 
concurrently consume messages from the same queues (not round robin, but 
parallel processing. No zookeeper needed). Notice that even a single instance 
can have multiple concurrent consumers. 

For file endpoints concurrent consumers are probably not the best. For such 
cases we have single instance deployments and a watchdog that monitors and 
restarts the instance when needed (Spring Boot health check).

Regards
Stephan


-Ursprüngliche Nachricht-
Von: Ambika Das [mailto:ada...@sapient.com] 
Gesendet: Donnerstag, 21. Dezember 2017 09:38
An: users@camel.apache.org
Betreff: Camel Clustering

Hi,

I am looking for out of the box support for clustering in a hybrid environment. 
What the Zookeeper Route policy provides is a master / slave route policy where 
the slave becomes active only when master fails.

Is there any way of having multiple nodes and let these nodes consume file / 
message in a round robin way?

Thanks,
Das A.P


Re: Camel Clustering

2017-12-21 Thread Claus Ibsen
Hi

If you have a copy of the CiA2 book then it has a full chapter on clustering.

But in regards to zookeeper-master route-policy then it works with
only one node being active and the others are slaves, they are not all
active at the same time.
What you talk about is more like competing consumers on a shared set
of files, and that is a bit more tricky, the CiA2 book covers this in
the transaction/idempotent chapter in the latter part.

On Thu, Dec 21, 2017 at 9:38 AM, Ambika Das  wrote:
> Hi,
>
> I am looking for out of the box support for clustering in a hybrid 
> environment. What the Zookeeper Route policy provides is a master / slave 
> route policy where the slave becomes active only when master fails.
>
> Is there any way of having multiple nodes and let these nodes consume file / 
> message in a round robin way?
>
> Thanks,
> Das A.P



-- 
Claus Ibsen
-
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2


Camel Clustering

2017-12-21 Thread Ambika Das
Hi,

I am looking for out of the box support for clustering in a hybrid environment. 
What the Zookeeper Route policy provides is a master / slave route policy where 
the slave becomes active only when master fails.

Is there any way of having multiple nodes and let these nodes consume file / 
message in a round robin way?

Thanks,
Das A.P