Re: mocking future routes

2018-04-24 Thread Willem Jiang
Hi,

As the endpoint uri is string, you can change the prefix with some kind of
profile.
If you want to use it in the test, you can simply set the prefix to be
"stub".
In the production world, you can just set the prefix to be an empty string.


Willem Jiang

Blog: http://willemjiang.blogspot.com (English)
  http://jnn.iteye.com  (Chinese)
Twitter: willemjiang
Weibo: 姜宁willem

On Wed, Apr 25, 2018 at 4:20 AM, Yacov Schondorf 
wrote:

> Hi,
> So sorry for the late response; only now I was able to get back to this
> issue.
> I don't see how the stub component can help me here. This is a real route I
> need to mock in a production code.
> Consider this use case:
> 1. My route (let's call it route 1)  has a Jetty start endpoint, and is a
> configuration service so that an incoming call would cause a configuration
> change to the system. If the incoming call has some "flag" set to "true"
> then a new route needs to be created (route 2). Route 2 has a Kafka
> endpoint which I need to mock because the connection parameters are not
> relevant at test time.
> 2. On my test, I advise route 1, and replace the Jetty endpoint with a
> start endpoint, and send a message that should trigger creation of route 2.
> Creation of route 2 fails because of the wrong Kafka parameters.
>
> If I add "stub:" in route 2 ("Stub:kafka...") then in non-test time the
> route will not work.
>
> Any solution for this?
>
>
> 2018-02-01 18:58 GMT+02:00 Claus Ibsen :
>
> > You can try when you create the new route, to add "stub:" as the
> > prefix for your endpoints. Then you can use the stub component to mock
> > them.
> > http://camel.apache.org/stub
> >
> > On Wed, Jan 17, 2018 at 6:10 PM, Yacov Schondorf
> >  wrote:
> > > Hi,
> > > I know how to mock/advise existing routes. But what do I do if one of
> my
> > > routes creates new routes? For example, I can send a configuration
> > message
> > > to a configuration route which has an activeMQ From endpoint. The
> > endpoint
> > > is advised and replaced with direct:a, so I send a configuration
> message
> > in
> > > my test. The route continues by creating a new route from
> > > activeMQ:someTopic to kafka:someTopic. This route fails to create
> because
> > > there is no real ssl-enabled kafka and activeMQ in the test
> environment.
> > Is
> > > there anything that can be done?
> >
> >
> >
> > --
> > Claus Ibsen
> > -
> > http://davsclaus.com @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2
> >
>
>
>
> --
> יעקב שיינדורף
> מנכ"ל ומנהל פיתוח,
> מילות מפתח לאתרים
> 054-5750201
> http://keywords-4-websites.com 
>
> יעקב שיינדורף
> מנהל מוסיקלי StyleBrass
> 054-5750201
> http://www.stylebrass.co.il
>


Re: mocking future routes

2018-04-24 Thread Yacov Schondorf
Hi,
So sorry for the late response; only now I was able to get back to this
issue.
I don't see how the stub component can help me here. This is a real route I
need to mock in a production code.
Consider this use case:
1. My route (let's call it route 1)  has a Jetty start endpoint, and is a
configuration service so that an incoming call would cause a configuration
change to the system. If the incoming call has some "flag" set to "true"
then a new route needs to be created (route 2). Route 2 has a Kafka
endpoint which I need to mock because the connection parameters are not
relevant at test time.
2. On my test, I advise route 1, and replace the Jetty endpoint with a
start endpoint, and send a message that should trigger creation of route 2.
Creation of route 2 fails because of the wrong Kafka parameters.

If I add "stub:" in route 2 ("Stub:kafka...") then in non-test time the
route will not work.

Any solution for this?


2018-02-01 18:58 GMT+02:00 Claus Ibsen :

> You can try when you create the new route, to add "stub:" as the
> prefix for your endpoints. Then you can use the stub component to mock
> them.
> http://camel.apache.org/stub
>
> On Wed, Jan 17, 2018 at 6:10 PM, Yacov Schondorf
>  wrote:
> > Hi,
> > I know how to mock/advise existing routes. But what do I do if one of my
> > routes creates new routes? For example, I can send a configuration
> message
> > to a configuration route which has an activeMQ From endpoint. The
> endpoint
> > is advised and replaced with direct:a, so I send a configuration message
> in
> > my test. The route continues by creating a new route from
> > activeMQ:someTopic to kafka:someTopic. This route fails to create because
> > there is no real ssl-enabled kafka and activeMQ in the test environment.
> Is
> > there anything that can be done?
>
>
>
> --
> Claus Ibsen
> -
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>



-- 
יעקב שיינדורף
מנכ"ל ומנהל פיתוח,
מילות מפתח לאתרים
054-5750201
http://keywords-4-websites.com 

יעקב שיינדורף
מנהל מוסיקלי StyleBrass
054-5750201
http://www.stylebrass.co.il


Can't redirect from REST POST input to AMQ endpoint

2018-04-24 Thread Steve Hiller
Hi Folks,

Does anybody know why I can't redirect from REST POST input to AMQ endpoint? As 
follows:


  

  


Thanks,

Steve


What route returns

2018-04-24 Thread Hrvoje Djurdjevic
Hi,

I notice that if I split body without referencing aggregation strategy,
like this: split().body()
route returns the message like it was before splitting.
However, if I reference aggregation strategy in a split call like
this: .split(body(),new AggrStrat())
then route returns the message after aggregation. However, if I want to do
further tasks in a route after aggregator, in which I reference the same
strategy as in a splitter,
such as for example unmarshalling the aggregated message from fixedlength
format and marshalling into json, although these tasks were properly done,
which I can verify by logging body, the REST route that is calling the
observed route still receives the aggregated fixedlength message format.
So, basically I see json printed in java console, but in postman or browser
I get fixedlength format.
Does that mean that I have to implement conversion from fixedlength to json
in aggregation strategy class, or there is still a way to do it
somehow in a route builder class?

The outline of my route is like this:

from(getDirectRouteId(id))
.routeId(id)
.setBody(simple("original request message"))

.setHeader("CamelJmsDestinationName",constant("queue://QM_TEST/inputq?targetClient=1"))

.to(ExchangePattern.InOut,"websphere:queue:SYSTEM.DEFAULT.LOCAL.QUEUE?useMessageIDAsCorrelationID=true=REPLYQ")
.unmarshal(dataFormat)
.split(body(),new AgrStrat()).parallelProcessing()
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
//assemble new mq requests based on the content of splitted
response mq message
   }
})

.setHeader("CamelJmsDestinationName",constant("queue://QM_TEST/inputq?targetClient=1"))

.to(ExchangePattern.InOut,"websphere:queue:SYSTEM.DEFAULT.LOCAL.QUEUE?useMessageIDAsCorrelationID=true=REPLYQ")
.aggregate(constant(true),new AgrStrat()).completionTimeout(3000)
.log("${body}")
.unmarshal(dataFormat1)
.marshal().json(JsonLibrary.Jackson)
.log("${body}");

AgrStrat basically concatenates the newExchange with the oldExchange,
inserting "\n" in between, at the moment.
I guess I should move format conversion there? Thank you.