Re: JDBC component and jboss ds.xml file

2014-04-15 Thread moj0002
okay I figured it out I think, 

The CamelJdbcUpdateCount contains rows inpacted included rows DELETED, maybe
it is using a prepared statement behind the scene 

I first dumped all the headers to uri=log:myLog?showHeaders=true/ and
found the property in the input header 

Then this works
log message=Running Scheduled deletion at  ${date:now:-MM-dd
HH:mm:ss z}   Rows deleted: $simple{header.CamelJdbcUpdateCount} /

I am still confused as to why I am looking at the input headers and not
output headers.



--
View this message in context: 
http://camel.465427.n5.nabble.com/JDBC-component-and-jboss-ds-xml-file-tp5750137p5750227.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Split XML with xmlTokenizer and add root element?

2014-04-15 Thread cgiera
Hello,

I have to deal with large xml data in our camel application. In the camel
documentation I've found the splitting with the
xmltokenizer(split().xmlTokenize(tag)).
First it looked fine for me, but then I noticed that there is no possibility
to add the root element to the splitted xml's.

Xml looks like this:
root
  tosplit
  /tosplit
  tosplit
  /tosplit
  tosplit
  /tosplit
  tosplit
  /tosplit
...
/root 

Output of xmltokenize(tosplit):
1. xml:
tosplit
/tosplit
2. xml:
tosplit
/tosplit
...

Output needed:
1. xml:
root
  tosplit
  /tosplit
root
2. xml:
root
  tosplit
  /tosplit
root
...

Maybe I missed something in the camel docu, is there a way in camel to get
the output from above?
Perhaps I can use something other than the xmltokenizer?

kind regards, 
Christoph 




--
View this message in context: 
http://camel.465427.n5.nabble.com/Split-XML-with-xmlTokenizer-and-add-root-element-tp5750237.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Split XML with xmlTokenizer and add root element?

2014-04-15 Thread Aki Yoshida
I think you are right.
currently, the result is a series of child elements and the parent
context information is not included in the result (except the
namespace binding information that can be extracted into the split
child elements).

When I pushed the current implementation, I had the code sitting
around in my repo to add such options of either wrapping the child
with the its parent container part or set the parent container part in
a separate header. But I didn't push that part, as I was not sure
about whether this was useful (I mean, to be included directly in the
splitter, as opposed to have this parent extraction step separately)
and how to expose the configuration parameter for it.

Probably including the extraction in the splitter is a good idea. I'll
look at it again.
regards, aki



2014-04-15 12:04 GMT+02:00 cgiera christoph.gi...@mic-cust.com:
 Hello,

 I have to deal with large xml data in our camel application. In the camel
 documentation I've found the splitting with the
 xmltokenizer(split().xmlTokenize(tag)).
 First it looked fine for me, but then I noticed that there is no possibility
 to add the root element to the splitted xml's.

 Xml looks like this:
 root
   tosplit
   /tosplit
   tosplit
   /tosplit
   tosplit
   /tosplit
   tosplit
   /tosplit
 ...
 /root

 Output of xmltokenize(tosplit):
 1. xml:
 tosplit
 /tosplit
 2. xml:
 tosplit
 /tosplit
 ...

 Output needed:
 1. xml:
 root
   tosplit
   /tosplit
 root
 2. xml:
 root
   tosplit
   /tosplit
 root
 ...

 Maybe I missed something in the camel docu, is there a way in camel to get
 the output from above?
 Perhaps I can use something other than the xmltokenizer?

 kind regards,
 Christoph




 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Split-XML-with-xmlTokenizer-and-add-root-element-tp5750237.html
 Sent from the Camel - Users mailing list archive at Nabble.com.


AW: Split XML with xmlTokenizer and add root element?

2014-04-15 Thread jhm
 I think you are right.
 currently, the result is a series of child elements and the parent
 context information is not included in the result (except the namespace
 binding information that can be extracted into the split child
 elements).
 
 When I pushed the current implementation, I had the code sitting around
 in my repo to add such options of either wrapping the child with the
 its parent container part or set the parent container part in a
 separate header. But I didn't push that part, as I was not sure about
 whether this was useful (I mean, to be included directly in the
 splitter, as opposed to have this parent extraction step separately)
 and how to expose the configuration parameter for it.
 
 Probably including the extraction in the splitter is a good idea. I'll
 look at it again.
 regards, aki

I appreciate such an option.
We also have such a data structure containing of a root, a header and multiple 
data nodes.


Jan

root
  header
...
  /header
  body
data one /data
data two /data
  /body
/root

==

root
  header
...
  /header
  body
data one /data
  /body
/root

root
  header
...
  /header
  body
data two /data
  /body
/root



Re: JDBC component and jboss ds.xml file

2014-04-15 Thread Claus Ibsen
On Mon, Apr 14, 2014 at 8:53 PM, moj0002 mortenjensenh...@hotmail.com wrote:
 okay I figured it out I think,

 The CamelJdbcUpdateCount contains rows inpacted included rows DELETED, maybe
 it is using a prepared statement behind the scene

 I first dumped all the headers to uri=log:myLog?showHeaders=true/ and
 found the property in the input header

 Then this works
 log message=Running Scheduled deletion at  ${date:now:-MM-dd
 HH:mm:ss z}   Rows deleted: $simple{header.CamelJdbcUpdateCount} /

 I am still confused as to why I am looking at the input headers and not
 output headers.


This page may help a bit
http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html



 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/JDBC-component-and-jboss-ds-xml-file-tp5750137p5750227.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/


Re: Camel transaction handler forces reconnecting to ActiveMQ

2014-04-15 Thread Claus Ibsen
On Mon, Apr 14, 2014 at 3:24 PM, nqbeel a.nabeelaha...@gmail.com wrote:
 Trying to set up a route with transaction handling on a camel, this leads to
 connection to the activeMQ drop and reconnect every few milliseconds is this
 expected, is there a work around?


Do you use caching as recommended here, eg see that 2nd box on the top
of the page
http://camel.apache.org/jms


 Logs showing repeatedly reconnecting to ActiveMQ server:

 ActiveMQ FailoverTransport Successfully connected to
 ssl://serveraddress:61617
 ActiveMQ FailoverTransport Successfully connected to
 ssl://serveraddress:61617
 ActiveMQ FailoverTransport Successfully connected to
 ssl://serveraddress:61617



 --
 View this message in context: 
 http://camel.465427.n5.nabble.com/Camel-transaction-handler-forces-reconnecting-to-ActiveMQ-tp5750224.html
 Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-
Red Hat, Inc.
Email: cib...@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/


Re: Camel transaction handler forces reconnecting to ActiveMQ

2014-04-15 Thread kraythe .
Interestingly i found something similar but using Atomikos JTA in a test
environment. My logs show the creation and commit of transactions
constantly (see below) but that wasn't a high priority because it was a
test environment. It especially occurs if a test has to wait a while for
the mocks to be satisfied. However if there is something inside camel
causing this in production, that is another matter.

09:12:06,350 INFO  [Tracer] ID-rsimmonsjr-mbp-58071-1397571125528-0-12 
(TestRoute)
marshal[org.apache.camel.component.jackson.JacksonDataFormat@70256760] --
activemq://queue:outbox  Pattern:InOnly,
Headers:{breadcrumbId=ID-rsimmonsjr-mbp-58071-1397571125528-0-1,
JMSCorrelationID=null, JMSXGroupID=null, JMSReplyTo=null,
JMSDestination=queue://inbox, JMSPriority=4, JMSTimestamp=1397571126253,
JMSType=null, JMSRedelivered=false,
CamelInterceptedEndpoint=activemq://queue:inbox, JMSXUserID=null,
JMSDeliveryMode=2,
JMSMessageID=ID:rsimmonsjr-mbp-58070-1397571125204-3:5:2:3:1,
JMSExpiration=0}, BodyType:byte[],
Body:{case_date:2013-11-06T08:03:08.000+,case_id:5000NQLj8N9J11}

After this the test case has to wait. (To mock it I set it to expect more
messages then it will ever get.)

09:12:06,352 INFO  [CompositeTransactionImp] registerSynchronization (
com.atomikos.jms.ConsumerProducerSupport$JmsRequeueSynchronization@80553152)
for transaction 20140415-091204_AtomikosTxnMgr000121
09:12:06,353 INFO  [CompositeTransactionImp] addParticipant (
XAResourceTransaction:
32303134303431352D3039313230345F41746F6D696B6F7354786E4D677230303031323030303031:32303134303431352D3039313230345F41746F6D696B6F7354786E4D67723132
) for transaction 20140415-091204_AtomikosTxnMgr000121
09:12:06,353 INFO  [XAResourceTransaction] XAResource.start (
32303134303431352D3039313230345F41746F6D696B6F7354786E4D677230303031323030303031:32303134303431352D3039313230345F41746F6D696B6F7354786E4D67723132
, XAResource.TMNOFLAGS ) on resource amq-embedded represented by XAResource
instance TransactionContext{transactionId=null}
09:12:06,353 INFO  [Tracer] ID-rsimmonsjr-mbp-58071-1397571125528-0-12 
(TestRoute) activemq://queue:outbox --
unmarshal[org.apache.camel.component.jackson.JacksonDataFormat@70256760]
 Pattern:InOnly, Headers:{JMSCorrelationID=null, JMSRedelivered=false,
JMSMessageID=ID:rsimmonsjr-mbp-58070-1397571125204-3:5:2:3:1,
JMSDeliveryMode=2, JMSPriority=4, JMSXGroupID=null,
breadcrumbId=ID-rsimmonsjr-mbp-58071-1397571125528-0-1,
JMSTimestamp=1397571126253, JMSType=null, JMSXUserID=null,
JMSDestination=queue://inbox,
CamelInterceptedEndpoint=activemq://queue:outbox, JMSExpiration=0,
JMSReplyTo=null}, BodyType:byte[],
Body:{case_date:2013-11-06T08:03:08.000+,case_id:5000NQLj8N9J11}
09:12:06,354 INFO  [Tracer] ID-rsimmonsjr-mbp-58071-1397571125528-0-12 
(TestRoute)
unmarshal[org.apache.camel.component.jackson.JacksonDataFormat@70256760]
-- mock://after_to_queue  Pattern:InOnly, Headers:{JMSExpiration=0,
JMSTimestamp=1397571126253, JMSCorrelationID=null,
JMSDestination=queue://inbox, JMSReplyTo=null,
CamelInterceptedEndpoint=activemq://queue:outbox,
JMSMessageID=ID:rsimmonsjr-mbp-58070-1397571125204-3:5:2:3:1,
JMSXGroupID=null, JMSXUserID=null,
breadcrumbId=ID-rsimmonsjr-mbp-58071-1397571125528-0-1, JMSDeliveryMode=2,
JMSType=null, JMSRedelivered=false, JMSPriority=4},
BodyType:com.ea.wwce.camel.test.utilities.TransactionTestTools.CaseRecord,
Body:{case_date=2013-11-06 02:03:08.0, case_id=5000NQLj8N9J11}
09:12:06,354 INFO  [XAResourceTransaction] XAResource.end (
32303134303431352D3039313230345F41746F6D696B6F7354786E4D677230303031323030303031:32303134303431352D3039313230345F41746F6D696B6F7354786E4D67723132
, XAResource.TMSUCCESS ) on resource amq-embedded represented by XAResource
instance
TransactionContext{transactionId=XID:[1096044365,globalId=32303134303431352d3039313230345f41746f6d696b6f7354786e4d677230303031323030303031,branchId=32303134303431352d3039313230345f41746f6d696b6f7354786e4d67723132]}
09:12:06,354 INFO  [CompositeTransactionImp] commit() done (by application)
of transaction 20140415-091204_AtomikosTxnMgr000121
09:12:06,355 INFO  [XAResourceTransaction] XAResource.commit (
32303134303431352D3039313230345F41746F6D696B6F7354786E4D677230303031323030303031:32303134303431352D3039313230345F41746F6D696B6F7354786E4D67723132
, true ) on resource amq-embedded represented by XAResource instance
TransactionContext{transactionId=null}
09:12:06,355 INFO  [BaseTransactionManager] resume (
com.atomikos.icatch.imp.CompositeTransactionImp@7ceb8014 ) done for
transaction 20140415-091204_AtomikosTxnMgr000101
09:12:06,356 INFO  [XAResourceTransaction] XAResource.end (
32303134303431352D3039313230345F41746F6D696B6F7354786E4D677230303031303030303031:32303134303431352D3039313230345F41746F6D696B6F7354786E4D67723130
, XAResource.TMSUCCESS ) on resource amq-embedded represented by XAResource
instance
TransactionContext{transactionId=XID:[1096044365,globalId

Set header from velocity template

2014-04-15 Thread dunnlow
I currently use velocity to set the message body.  Now, I would like to use
it to set a _header_.  I haven't found any example of this.  Obviously I
could write a processor/bean.  Is there a better way?  Thanks. -J



--
View this message in context: 
http://camel.465427.n5.nabble.com/Set-header-from-velocity-template-tp5750248.html
Sent from the Camel - Users mailing list archive at Nabble.com.


AW: Set header from velocity template

2014-04-15 Thread jhm
 I currently use velocity to set the message body.  Now, I would like to
 use it to set a _header_.  I haven't found any example of this.
 Obviously I could write a processor/bean.  Is there a better way?

Why do you want to use velocity for that?

Just

from(...)
  .setHeader(headerName, constant(constant value))
  .setHeader(xmlHeader, xpath(xpath/on/xml/body))
  ...


Jan



Configuring JMS connection pool for WMQ

2014-04-15 Thread smadarapu
Hi

I have been successfully running several routes connecting to a JMS queue
using Websphere MQ. I have several routes each of them handling specific
messages (using selectors). No I am at a point where the number of
connections to the queue are growing and want to use a connection pool.

I am trying the CachingConnectionFactory but running into class cast
exceptions...

bean id=inCachingConnectionFactory
class=org.springframework.jms.connection.CachingConnectionFactory
property name=targetConnectionFactory 
ref=inboundMqConnectionFactory1
/
property name=sessionCacheSize value=5 /
/bean

bean id=inboundWebsphereMq1
class=org.apache.camel.component.jms.JmsComponent
property name=connectionFactory ref=inCachingConnectionFactory /
property name=destinationResolver ref=jmsDestinationResolver /
property name=transacted value=true /
property name=transactionManager ref=txManager1 /
/bean

bean id=inboundMqConnectionFactory1
class=com.ibm.mq.jms.MQQueueConnectionFactory
property name=hostName value=${isi.inbound.queue.host2} /
property name=port value=${isi.inbound.queue.port} /
property name=queueManager 
value=${isi.inbound.queue.queuemanager2} /
property name=channel value=${isi.inbound.queue.channel2} /
property name=transportType value=${isi.queue.transportType} /
/bean

Could not find a WMQ specific connection pool and according to this post
http://stackoverflow.com/questions/8922339/how-to-pooling-the-jms-connection-in-a-standalone-java-applications
the pool support has been removed by WMQ, not sure why.

Have any body have success using a connection pool with camel, spring, wmq ?

Thanks



--
View this message in context: 
http://camel.465427.n5.nabble.com/Configuring-JMS-connection-pool-for-WMQ-tp5750258.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Set header from velocity template

2014-04-15 Thread dunnlow
Sorry, I should have given more detail.  

I am using velocity to create web pages.  My template is an html formatted
document (about 40 lines) that uses existing exchange headers.  (This gets
turned into a web page downstream.)  

In my (xml) route I have something like:

 to uri=velocity://tohtml.vm/

However, this puts my html template into the BODY.  I need to keep the
current body intact (downstream routes depend on having the original
message) so I want to do this same evaluation, but put the new evaluated
template it into a HEADER.

Thanks again,
-J



--
View this message in context: 
http://camel.465427.n5.nabble.com/Set-header-using-velocity-template-tp5750248p5750259.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Set header from velocity template

2014-04-15 Thread Bilgin Ibryam
Velocity will put the result of the evaluation in the message body, you
cannot change that.
But you could preserve the existing body by putting it into a header before
calling velocity template, and then swap the template result with the
previous body afterwards...

HTH



On 15 April 2014 18:13, dunnlow dunn...@yahoo.com wrote:

 Sorry, I should have given more detail.

 I am using velocity to create web pages.  My template is an html formatted
 document (about 40 lines) that uses existing exchange headers.  (This gets
 turned into a web page downstream.)

 In my (xml) route I have something like:

  to uri=velocity://tohtml.vm/

 However, this puts my html template into the BODY.  I need to keep the
 current body intact (downstream routes depend on having the original
 message) so I want to do this same evaluation, but put the new evaluated
 template it into a HEADER.

 Thanks again,
 -J



 --
 View this message in context:
 http://camel.465427.n5.nabble.com/Set-header-using-velocity-template-tp5750248p5750259.html
 Sent from the Camel - Users mailing list archive at Nabble.com.




-- 
Bilgin Ibryam

Apache Camel  Apache OFBiz committer
Blog: ofbizian.com
Twitter: @bibryam https://twitter.com/bibryam

Author of Instant Apache Camel Message Routing
http://www.amazon.com/dp/1783283475


Re: Camel transaction handler forces reconnecting to ActiveMQ

2014-04-15 Thread nqbeel
Yes, I do have cache level set to CACHE_CONSUMER as recommended.   

Below is my spring configuration,

bean id=jms
class=org.apache.activemq.camel.component.ActiveMQComponent
property name=configuration ref=activeMQConfig/   

property name=transacted value=true/
property name=transactionManager ref=jmsTxManager/
/bean

bean id=activeMQConfig

class=org.apache.activemq.camel.component.ActiveMQConfiguration
property name=connectionFactory ref=conFactory /
property name=cacheLevelName value=CACHE_CONSUMER /
property name=concurrentConsumers value=10 /  
/bean

bean id=conFactory
class=org.apache.activemq.ActiveMQConnectionFactory
property name=brokerURL value=${activemq.broker.url} /
property name=userName value=${userName} /
property name=password value=${password} /
property name=watchTopicAdvisories value=false /
/bean

bean id=jmsTxManager
class=org.springframework.jms.connection.JmsTransactionManager
property name=connectionFactory ref=conFactory /
/bean


Claus Ibsen-2 wrote
 On Mon, Apr 14, 2014 at 3:24 PM, nqbeel lt;

 a.nabeelahamed@

 gt; wrote:
 Trying to set up a route with transaction handling on a camel, this leads
 to
 connection to the activeMQ drop and reconnect every few milliseconds is
 this
 expected, is there a work around?

 
 Do you use caching as recommended here, eg see that 2nd box on the top
 of the page
 http://camel.apache.org/jms
 
 
 Logs showing repeatedly reconnecting to ActiveMQ server:

 ActiveMQ FailoverTransport Successfully connected to
 ssl://serveraddress:61617
 ActiveMQ FailoverTransport Successfully connected to
 ssl://serveraddress:61617
 ActiveMQ FailoverTransport Successfully connected to
 ssl://serveraddress:61617



 --
 View this message in context:
 http://camel.465427.n5.nabble.com/Camel-transaction-handler-forces-reconnecting-to-ActiveMQ-tp5750224.html
 Sent from the Camel - Users mailing list archive at Nabble.com.
 
 
 
 -- 
 Claus Ibsen
 -
 Red Hat, Inc.
 Email: 

 cibsen@

 Twitter: davsclaus
 Blog: http://davsclaus.com
 Author of Camel in Action: http://www.manning.com/ibsen
 hawtio: http://hawt.io/
 fabric8: http://fabric8.io/





--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-transaction-handler-forces-reconnecting-to-ActiveMQ-tp5750224p5750261.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Camel transaction handler forces reconnecting to ActiveMQ

2014-04-15 Thread nqbeel
Also I did see that when I remove failover from the Broker URL it seems to be
working fine.

Currently its set to 
broker.url=failover:(ssl://server:61617)?maxReconnectDelay=6

Is there anything that needs to be changed to accommodate failover?




--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-transaction-handler-forces-reconnecting-to-ActiveMQ-tp5750224p5750267.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Set header from velocity template

2014-04-15 Thread dunnlow
ah!  Thank you, works as expected:

route
   from uri=direct:buildPage/
   setHeader headerName=currentBodysimple${body}/simple/setHeader
   to uri=velocity://responseEmail.vm/
   setHeader headerName=mailTemplatesimple${body}/simple/setHeader
   setBodysimpleheaders.currentBody/simple/setBody
   to uri=direct:paradigm/
/route

...albeit not as clean as a toHeader option on the velocity component :)



--
View this message in context: 
http://camel.465427.n5.nabble.com/Set-header-using-velocity-template-tp5750248p5750271.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Transactions: Rollback Destination but Not Dead Letter Queue or Source

2014-04-15 Thread kraythe .
So I think there is a problem with the way rollback is implemented in
relation to Camel. As far as I can tell there is no way to get the
following working.

package com.ea.wwce.camel.test.utilities;

import com.ea.wwce.camel.utilities.data.RecordList;
import com.ea.wwce.camel.utilities.transactions.TxnHelper;
import org.apache.camel.ExchangePattern;
import org.apache.camel.builder.AdviceWithRouteBuilder;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.testng.annotations.Test;
import static com.ea.wwce.camel.test.utilities.TransactionTestTools.*;
import static
com.ea.wwce.camel.utilities.activemq.ActiveMQHelper.endpointAMQ;
import static
com.ea.wwce.camel.utilities.jackson.RecordSerialization.toListOfJsonStrings;
import static org.apache.camel.ExchangePattern.InOnly;

/** This test suite validates the transaction configuration in the test
suite. */
public class JMSOnlyTransactionTest extends AMQRouteTestSupport {
  private static final String QUEUE_DEAD = dead;
  private static final String QUEUE_INBOX = inbox;
  private static final String QUEUE_OUTBOX = outbox;
  private static final String ROUTE_ID_FEED = Feed;
  private static final String ROUTE_ID_TEST_ROUTE = TestRoute;
  private static final String ROUTE_ID_RESULTS = ResultsRoute;
  private static final String ROUTE_ID_DEAD = DeadRoute;
  private static final String DIRECT_FEED_INBOX = direct:feed_inbox;

  private static final String MOCK_END = mock:end;
  private static final String MOCK_BEFORE_TO_QUEUE = mock:before_to_queue;
  private static final String MOCK_AFTER_TO_QUEUE = mock:after_to_queue;

  /** Mock endpoints. */
  private MockEndpoint mockEnd, mockDead, mockOutbox, mockBeforeToQueue,
mockAfterToQueue;

  /** Helper to initialize mocks in the test. */
  private void initMocks() {
mockEnd = assertAndGetMockEndpoint(MOCK_END);
mockDead = assertAndGetMockEndpoint(MOCK_DEAD);
mockBeforeToQueue = assertAndGetMockEndpoint(MOCK_BEFORE_TO_QUEUE);
mockAfterToQueue = assertAndGetMockEndpoint(MOCK_AFTER_TO_QUEUE);
mockOutbox = assertAndGetMockEndpoint(mockEndpointAMQ(QUEUE_OUTBOX));
  }

  @Override
  protected RouteBuilder createRouteBuilder() {
System.out.println(createRouteBuilder);
return new RouteBuilder(this.context) {
  @Override
  public void configure() {
getContext().setTracing(true);
from(DIRECT_FEED_INBOX).routeId(ROUTE_ID_FEED)
.transacted(TxnHelper.KEY_TXNPOLICY_REQUIRED)

.split(body()).marshal(dfCaseRecord).to(endpointAMQ(QUEUE_INBOX));
from(endpointAMQ(QUEUE_OUTBOX)).routeId(ROUTE_ID_RESULTS)
.transacted(TxnHelper.KEY_TXNPOLICY_REQUIRED)
.unmarshal(dfCaseRecord).to(MOCK_END);
from(endpointAMQ(QUEUE_DEAD)).routeId(ROUTE_ID_DEAD)
.transacted(TxnHelper.KEY_TXNPOLICY_REQUIRED)
.unmarshal(dfCaseRecord).to(MOCK_DEAD);
from(endpointAMQ(QUEUE_INBOX)).routeId(ROUTE_ID_TEST_ROUTE)

.onException(RuntimeException.class).handled(true).useOriginalMessage()
  .to(InOnly, endpointAMQ(QUEUE_DEAD)).end()
.transacted(TxnHelper.KEY_TXNPOLICY_REQUIRES_NEW)
.unmarshal(dfCaseRecord)
.to(MOCK_BEFORE_TO_QUEUE)
.marshal(dfCaseRecord)
.to(endpointAMQ(QUEUE_OUTBOX))
.unmarshal(dfCaseRecord)
.to(MOCK_AFTER_TO_QUEUE);
  }
};
  }

  /** Advice the route, mocking ActiveMQ endpoints. */
  protected void adviceRoute() throws Exception {
this.context.getRouteDefinition(ROUTE_ID_TEST_ROUTE).adviceWith(
this.context, new AdviceWithRouteBuilder() {
  @Override
  public void configure() throws Exception {
mockEndpoints(activemq:queue:*);
  }
}
);
  }

  @Test
  public void testNormalRouting() throws Exception {
adviceRoute();
startCamelContext();
initMocks();
final RecordList cases = casesA();

mockEnd.expectedBodiesReceived(cases);
mockBeforeToQueue.expectedBodiesReceivedInAnyOrder(cases);
mockOutbox.expectedBodiesReceivedInAnyOrder(toListOfJsonStrings(mapper,
cases));
mockAfterToQueue.expectedBodiesReceivedInAnyOrder(cases);

template.sendBody(DIRECT_FEED_INBOX, cases);

mockBeforeToQueue.assertIsSatisfied();
mockAfterToQueue.assertIsSatisfied();
mockEnd.assertIsSatisfied();
mockDead.assertIsSatisfied();
mockOutbox.assertIsSatisfied();
  }

  @Test
  public void testRollbackBeforeEnqueue() throws Exception {
adviceRoute();
startCamelContext();
initMocks();
final RecordList cases = casesA();

mockEnd.expectedBodiesReceivedInAnyOrder(cases.get(1), cases.get(2));
mockDead.expectedBodiesReceived(cases.get(0));
mockBeforeToQueue.expectedBodiesReceivedInAnyOrder(cases);
mockBeforeToQueue.whenExchangeReceived(1, EXCEPTION_PROCESSOR);
mockOutbox.expectedBodiesReceivedInAnyOrder(toListOfJsonStrings(mapper,
cases.get(1), 

Re: Set header from velocity template

2014-04-15 Thread Willem Jiang
As the message header could be override or lost in the processor. My suggest is 
put the old message body into exchange property. Camel is copying the exchange 
properties by default.

--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.iteye.com (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On April 16, 2014 at 1:23:59 AM, Bilgin Ibryam (bibr...@gmail.com) wrote:
 Velocity will put the result of the evaluation in the message body, you
 cannot change that.
 But you could preserve the existing body by putting it into a header before
 calling velocity template, and then swap the template result with the
 previous body afterwards...
  
 HTH
  
  
  
 On 15 April 2014 18:13, dunnlow wrote:
  
  Sorry, I should have given more detail.
 
  I am using velocity to create web pages. My template is an html formatted
  document (about 40 lines) that uses existing exchange headers. (This gets
  turned into a web page downstream.)
 
  In my (xml) route I have something like:
 
   
 
  However, this puts my html template into the BODY. I need to keep the
  current body intact (downstream routes depend on having the original
  message) so I want to do this same evaluation, but put the new evaluated
  template it into a HEADER.
 
  Thanks again,
  -J
 
 
 
  --
  View this message in context:
  http://camel.465427.n5.nabble.com/Set-header-using-velocity-template-tp5750248p5750259.html

  Sent from the Camel - Users mailing list archive at Nabble.com.
 
  
  
  
 --
 Bilgin Ibryam
  
 Apache Camel  Apache OFBiz committer
 Blog: ofbizian.com
 Twitter: @bibryam  
  
 Author of Instant Apache Camel Message Routing
 http://www.amazon.com/dp/1783283475