Camel mock producer and empty exchanges

757 views
Skip to first unread message

Christophe Pache

unread,
Nov 14, 2011, 4:31:03 AM11/14/11
to Akka User List
Hello

I'm a testing some Producer (akka implementation of camel producers)
and I get strenge resuts : I've followed the test of the akka-camel
module, using the mock component. My producer actually sends objects
to the mock producer, but they are always empty.

I'm sending akka.camel.Message to a producer with the uri "mock:foo",
and the test on the expectedMessageCount always passes, but the
exchange is empty.

Any idea would be welcome, I've checked in the receiveBeforeProduce
that the Message was still correct and it is.

Many thanks in advance


here some log:

09:23:24.012 [pool-6-thread-2] DEBUG
org.apache.camel.impl.ProducerCache - Adding to producer cache with
key: Endpoint[mock://foo] for producer: Producer[mock://foo]
09:23:24.016 [pool-6-thread-2] DEBUG o.a.camel.processor.SendProcessor
- >>>> Endpoint[mock://foo] Exchange[Message: ()]
09:23:24.018 [pool-6-thread-2] DEBUG o.a.c.component.mock.MockEndpoint
- mock://foo >>>> 0 : Exchange[Message: ()] with body: ()
09:23:26.022 [pool-6-thread-2] INFO o.a.c.component.mock.MockEndpoint
- Asserting: Endpoint[mock://foo] is satisfied
09:23:26.024 [pool-6-thread-2] DEBUG o.a.camel.processor.SendProcessor
- >>>> Endpoint[mock://foo] Exchange[Message: ()]
09:23:26.025 [pool-6-thread-2] DEBUG o.a.c.component.mock.MockEndpoint
- mock://foo >>>> 1 : Exchange[Message: ()] with body: ()
09:23:26.025 [pool-6-thread-2] INFO o.a.c.component.mock.MockEndpoint
- Asserting: Endpoint[mock://foo] is satisfied
09:23:26.026 [pool-6-thread-2] INFO o.a.c.component.mock.MockEndpoint
- Asserting: Endpoint[mock://foo] is satisfied
09:23:26.027 [pool-6-thread-2] DEBUG o.a.c.component.mock.MockEndpoint
- Waiting on the latch for: 0 millis
09:23:36.027 [pool-6-thread-2] DEBUG o.a.c.component.mock.MockEndpoint
- Took 10000 millis to complete latch
09:23:36.028 [pool-6-thread-2] DEBUG o.a.c.component.mock.MockEndpoint
- mock://foo failed and received[1]: Exchange[Message: ()]
09:23:36.028 [pool-6-thread-2] DEBUG o.a.c.component.mock.MockEndpoint
- mock://foo failed and received[2]: Exchange[Message: ()]
09:23:36.035 [pool-6-thread-2] DEBUG o.a.c.component.mock.MockEndpoint
$1 - Stopping producer: Producer[mock://foo]

Martin Krasser

unread,
Nov 14, 2011, 4:45:13 AM11/14/11
to akka...@googlegroups.com
Hi Christophe,

Please post some example code. Also, what Akka and Camel version are you
using?

Thanks,
Martin

Am 14.11.11 10:31, schrieb Christophe Pache:

--
Martin Krasser

blog: http://krasserm.blogspot.com
code: http://github.com/krasserm
twitter: http://twitter.com/mrt1nz

Christophe Pache

unread,
Nov 14, 2011, 5:05:57 AM11/14/11
to Akka User List
Hi Martin,

Thank you to consider my problem.

Here is some pasties that should be relevant : the test and the
producer http://pastebin.com/bxxz4cXb
I'm working with akka 1.2 and I depend on camel 2.8.1.

Martin Krasser

unread,
Nov 14, 2011, 8:28:11 AM11/14/11
to akka...@googlegroups.com
Thanks for sharing the example. Please give me a day or so to take a
closer look.

Cheers,
Martin

Am 14.11.11 11:05, schrieb Christophe Pache:

--

Martin Krasser

unread,
Nov 15, 2011, 2:08:11 AM11/15/11
to akka...@googlegroups.com
Hi Christophe,

Am 14.11.11 11:05, schrieb Christophe Pache:

> Hi Martin,
>
> Thank you to consider my problem.
>
> Here is some pasties that should be relevant : the test and the
> producer http://pastebin.com/bxxz4cXb

receiveBeforeProduce (PartialFunction[Any, Any]) must return the actual
message being produced. Your implementation returns Unit (which causes
the 'empty' exchanges you reported).

> I'm working with akka 1.2 and I depend on camel 2.8.1.
>
> On Nov 14, 10:45 am, Martin Krasser<krass...@googlemail.com> wrote:
>> Hi Christophe,
>>
>> Please post some example code. Also, what Akka and Camel version are you
>> using?

--

Christophe Pache

unread,
Nov 16, 2011, 2:33:47 AM11/16/11
to Akka User List
Hi Martin

Many thanks for your clear answer which solved my problem.

On Nov 15, 8:08 am, Martin Krasser <krass...@googlemail.com> wrote:
> Hi Christophe,
>
> Am 14.11.11 11:05, schrieb Christophe Pache:
>
> > Hi Martin,
>
> > Thank you to consider my problem.
>
> > Here is some pasties that should be relevant :  the test and the
> > producerhttp://pastebin.com/bxxz4cXb

Christophe Pache

unread,
Nov 21, 2011, 2:28:24 AM11/21/11
to Akka User List
Thanks again for your help, Martin

I'm now thinking on the lifecycle of my producers. Thus, the
possibility to send administrative messages for example (a dummy idea
would be to discard exchanges null and with this, by returning Unit on
receiveBeforProduce for example)

Of course, this is an advanced feature (and perhaps not relevant), I'm
not sure at the moment I need it in my current project, but I would
really be interested to have your opinion on this point.

Thanks in advance

All the best

Christophe

On Nov 15, 8:08 am, Martin Krasser <krass...@googlemail.com> wrote:
> Hi Christophe,
>

> Am 14.11.11 11:05, schrieb Christophe Pache:

> hb


> > Hi Martin,
>
> > Thank you to consider my problem.
>
> > Here is some pasties that should be relevant :  the test and the
> > producerhttp://pastebin.com/bxxz4cXb
>

> receiveBeforeProduce(PartialFunction[Any, Any]) must return the actual

Martin Krasser

unread,
Nov 21, 2011, 7:25:35 AM11/21/11
to akka...@googlegroups.com

Am 21.11.11 08:28, schrieb Christophe Pache:


> Thanks again for your help, Martin
>
> I'm now thinking on the lifecycle of my producers. Thus, the
> possibility to send administrative messages for example (a dummy idea
> would be to discard exchanges null and with this, by returning Unit on
> receiveBeforProduce for example)

You manage the lifecycle of producer actors via ActorRef's start() and
stop() methods. What else do you need for lifecycle management? If you
want certain messages not being produced by the producer actor, override
receive:

class MyProducer extends Actor with Producer {
override def receive = {
case DoNotProduce() => ...
case msg => super.receive(msg)

Christophe Pache

unread,
Nov 21, 2011, 8:08:11 AM11/21/11
to Akka User List
Hi Martin

Thanks for your advice. I was speaking about the Camel
SuspendableService.

Reply all
Reply to author
Forward
0 new messages