Re: Apache camel mina concurrency issue

2009-09-14 Thread Claus Ibsen
On Mon, Sep 14, 2009 at 5:51 AM, jamhit hitha.a...@sabre-holdings.com wrote:

 Thanks Claus.  I am not sure, if the issue is due to remote host forcibly
 closing connection. My simple java socket client works fine by sending
 multiple concurrent transactions to the same legacy server. I have a feeling
 it is something in my mina configuration or codec setting. Does mina reuse
 connections for multiple messages? The legacy system is expecting separate
 connections per request.
 I am using an extension of CumulativeProtocolDecoder. Do I need to do
 something in dispose() method to forcibly close the connection or session?

I think you should ask at Apache Mina about this.


 Also, will you please post the link to the camel 2.0 trunk with concurrency
 unit test?



 Claus Ibsen-2 wrote:

 On Sun, Sep 13, 2009 at 6:38 AM, jamhit hitha.a...@sabre-holdings.com
 wrote:

 I am getting errors when trying to send more than one message to a legacy
 tcp/ip service using a Apache camel mina endpoint. Everything works as
 expected when requests are send one at a time.  Using camel 1.6.  Any
 clues
 will be appreciated. Following is the error I am getting.

 Caused by: java.io.IOException: An existing connection was forcibly
 closed
 by the remote host

 Looks like the remote server forbids multiple connections from same IP
 (client).

 There is a concurrency unit test in the unit tests for camel 2.x (trunk).
 So locally with mina itself it can handle multiple connections.

        at sun.nio.ch.SocketDispatcher.read0(Native Method)
        at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:25)
        at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:233)
        at sun.nio.ch.IOUtil.read(IOUtil.java:200)
        at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:236)
        at
 org.apache.mina.transport.socket.nio.SocketIoProcessor.read(SocketIoProcessor.java:218)
        at
 org.apache.mina.transport.socket.nio.SocketIoProcessor.process(SocketIoProcessor.java:198)
        at
 org.apache.mina.transport.socket.nio.SocketIoProcessor.access$400(SocketIoProcessor.java:45)
        at
 org.apache.mina.transport.socket.nio.SocketIoProcessor$Worker.run(SocketIoProcessor.java:485)
        at
 org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)

 --
 View this message in context:
 http://www.nabble.com/Apache-camel-mina-concurrency-issue-tp25420520p25420520.html
 Sent from the Camel - Users mailing list archive at Nabble.com.





 --
 Claus Ibsen
 Apache Camel Committer

 Open Source Integration: http://fusesource.com
 Blog: http://davsclaus.blogspot.com/
 Twitter: http://twitter.com/davsclaus



 --
 View this message in context: 
 http://www.nabble.com/Apache-camel-mina-concurrency-issue-tp25420520p25429960.html
 Sent from the Camel - Users mailing list archive at Nabble.com.





-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus


Re: Testability of routes

2009-09-14 Thread Willem Jiang

Hi,

Yes, you can use mock endpoint to check the exchange.
According to you description of the production configuration,
I think you can add a mock endpoint at the end of route, and check the 
exchange which is routed to this endpoint. But this will change your 
production route rule a litter bit.


Or you can treat the camel route as a black box, just use camel 
producerTemplate to send the message and check the response. This 
solution requires your message exchange pattern to be InOut.


Maybe we can add an debugInterceptor dsl which take the mock endpoint as 
the parameter and we can turn on or turn off the interceptor at camel 
runtime.


Any thought ?

Willem

HariKrishnan wrote:

Hi,

I am aware of the mock endpoints and test endpoints that can be used to test
various routes. I need some advice regarding testing production
configurations in my unit test. I use programmatic configuration and my
routes consist of calls to various services and also access to databases. I
want to write test around my configuration such that I can test drive my
routes.

But I realise that I can only do this with mock endpoints, that allow me to
assert that the exchange reached them. How can I test configurations that I
am actually going to deploy in production.

I am not a very big fan of integration tests and would like to unit test my
routes.

Please advice.

Cheers,
HariKrishnan

 




Re: Using @Produce / @Consume -- What am I missing?

2009-09-14 Thread James Strachan
2009/9/14 Scott Parkerson scott.parker...@ateb.com:
 Hello,

 I'm trying to use Camel 1.6.1 in SMX 4.1.0.2 (FUSE) and the POJO
 Producing / Consuming annotations as described in the online
 documentation.

 In one class (a CXF-based RESTful webservice), I have the following set
 up:

    // OutboundFooRequestHandler is an interface (see below)
   �...@produce(uri=activemq:queue:outbound_foo_req)
    private OutboundFooRequestHandler   outboundFooRequestHandler;

   �...@post
   �...@path(/sendfoo)
    public Response sendFoo(OutboundFooRequest sendFooRequest)
    {
        // (a bunch of web-specific code deleted)

        // send this sendFooReqest object on the queue
        outboundFooRequestHandler.handle(sendFooRequest);

        // Return HTTP response 202 Accepted
        return Response.status(202).build();
    }


 The interface that is annotated with Produce is shown below:

 @InOnly
 public interface OutboundFooRequestHandler
 {
    public void handle(OutboundFooRequest outboundFooRequest);
 }

 Here is the implementation of the interface:

    public class OutboundFooRequestHandlerImpl implements
        OutboundFooRequestHandler, InitializingBean, DisposableBean
    {

    private static final Logger logger =
        LoggerFactory.getLogger(OutboundFooRequestHandlerImpl.class);

   �...@override
   �...@consume(uri=activemq:queue:outbound_foo_req)
    public void handle(@Body OutboundFooRequest outboundFooRequest)
    {
        logger.debug(got it);

        // TODO: actually *do* something
    }

 The producer and the consumer's bundle-context.xml has this:

    camelContext
          xmlns=http://activemq.apache.org/camel/schema/spring; /

    bean name=activemq
          class=org.apache.camel.component.jms.JmsComponent
        property name=connectionFactory
            bean class=org.apache.activemq.ActiveMQConnectionFactory
                property name=brokerURL value=vm://default /
            /bean
        /property
    /bean

 I can send a message, but the consumer doesn't wake up and pick up the
 message.

 It's worth noting that the producer and the consumer are in two
 different bundles.

 What am I missing?

Are you creating your OutboundFooRequestHandlerImpl class by
configuring it in Spring XML? Or are you using the Spring 3 component
scan stuff?


-- 
James
---
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/


Re: Using @Produce / @Consume -- What am I missing?

2009-09-14 Thread Scott Parkerson
On Mon, 2009-09-14 at 16:07 +0100, James Strachan wrote:

 Are you creating your OutboundFooRequestHandlerImpl class by
 configuring it in Spring XML? Or are you using the Spring 3 component
 scan stuff?

Well, that question made me realize that I need to instantiate the bean
via Spring. Turns out two things were missing:

1. I needed to configure the Impl class in my bean, thusly:

bean name=outboundFooProcessor
class=com.ateb.dataproc.obc_processor.internal.OutboundFooRequestHandlerImpl 
/

2. I needed to configure the Apache Maven plugin to add the package
com.ateb.dataproc.obc_processor.internal to Private-Package in my
POM.

Now, I have a new issue:

Upon each message consumed, this is spewed to SMX's console:

com.ateb.dataproc.obc_processor.internal
11:26:11,796 | WARN  | nerContainer-240 |
DefaultMessageListenerContainer  | AbstractMessageListenerContainer  646
| Execution of JMS message listener failed
org.apache.camel.RuntimeCamelException:
org.apache.camel.component.jms.RuntimeJmsException: Failed to extract
body due to: javax.jms.JMSException: Failed to build body from content.
Serializable class not available to broker. Reason:
java.lang.ClassNotFoundException:
org.apache.camel.component.bean.BeanInvocation.

So, evidently, something needs to be added to my bundle's classpath via
the pom.xml? Or am I missing the component?

--sgp


Using @Produce / @Consume -- What am I missing?

2009-09-14 Thread Scott Parkerson
Hello,

I'm trying to use Camel 1.6.1 in SMX 4.1.0.2 (FUSE) and the POJO
Producing / Consuming annotations as described in the online
documentation. 

In one class (a CXF-based RESTful webservice), I have the following set
up:

// OutboundFooRequestHandler is an interface (see below)
@Produce(uri=activemq:queue:outbound_foo_req)
private OutboundFooRequestHandler   outboundFooRequestHandler;

@POST
@Path(/sendfoo)
public Response sendFoo(OutboundFooRequest sendFooRequest)
{
// (a bunch of web-specific code deleted)

// send this sendFooReqest object on the queue
outboundFooRequestHandler.handle(sendFooRequest);

// Return HTTP response 202 Accepted
return Response.status(202).build();
}


The interface that is annotated with Produce is shown below:

@InOnly
public interface OutboundFooRequestHandler
{
public void handle(OutboundFooRequest outboundFooRequest);
}

Here is the implementation of the interface:

public class OutboundFooRequestHandlerImpl implements
OutboundFooRequestHandler, InitializingBean, DisposableBean
{

private static final Logger logger = 
LoggerFactory.getLogger(OutboundFooRequestHandlerImpl.class);

@Override
@Consume(uri=activemq:queue:outbound_foo_req)
public void handle(@Body OutboundFooRequest outboundFooRequest)
{
logger.debug(got it);

// TODO: actually *do* something
}

The producer and the consumer's bundle-context.xml has this:

camelContext
  xmlns=http://activemq.apache.org/camel/schema/spring; /

bean name=activemq
  class=org.apache.camel.component.jms.JmsComponent
property name=connectionFactory
bean class=org.apache.activemq.ActiveMQConnectionFactory
property name=brokerURL value=vm://default /
/bean
/property
/bean

I can send a message, but the consumer doesn't wake up and pick up the
message.

It's worth noting that the producer and the consumer are in two
different bundles.

What am I missing?

--sgp



Regression in 2.0.0 : http fails with I/O Exception

2009-09-14 Thread Dragisa Krsmanovic
This simple example will fail in http component with I/O Exception. 

Worked in 2.0-M3 but fails in 2.0.0

Namespaces ns = new Namespaces(atom, http://www.w3.org/2005/Atom;);
from(rss:http://www.plosone.org/article/feed;)
 .marshal().rss()
 .setHeader(Exchange.HTTP_URI).xpath(//atom:entry/atom:li...@type=
\application/pdf\]/@href, ns)
 .to(http://foo;)
 .to(mock:end);

Here is debug output:

Camel thread 0: RssComponent] HttpProducer   DEBUG No
Content-Type provided for URI:
http://www.plosone.org/article/fetchObjectAttachment.action?uri=info:doi/10.1371/journal.pone.0006932representation=PDF
 with exchange: Exchange[Message: [...@150ecc7]
[   Camel thread 0: RssComponent] HttpProducer
DEBUG Executing http POST method:
http://www.plosone.org/article/fetchObjectAttachment.action?uri=info:doi/10.1371/journal.pone.0006932representation=PDF
[   Camel thread 0: RssComponent] HttpMethodDirector
INFO  I/O exception (java.net.SocketException) caught when processing
request: Connection reset
[   Camel thread 0: RssComponent] HttpMethodDirector
INFO  Retrying request
[   Camel thread 0: RssComponent] HttpMethodDirector
INFO  I/O exception (java.net.SocketException) caught when processing
request: Connection reset
[   Camel thread 0: RssComponent] HttpMethodDirector
INFO  Retrying request
[   Camel thread 0: RssComponent] HttpMethodDirector
INFO  I/O exception (java.net.SocketException) caught when processing
request: Connection reset
[   Camel thread 0: RssComponent] HttpMethodDirector
INFO  Retrying request
[   Camel thread 0: RssComponent] DefaultErrorHandler
DEBUG Failed delivery for exchangeId:
ID-dkrsmanovic-usws-55084-1252968147202-0-1. On delivery attempt: 0
caught: java.net.SocketException: Connection reset
[   

-- 
Dragisa Krsmanovic
Java Developer
Public Library of Science 
http://www.plos.org