Reputation: 13585
I am not able to connect to camel route having a SEDA queue. On sever side I have following configuration:
<camel:route>
<camel:from uri="seda:input"/>
<camel:log message =">>>>>data is : ${body}"/>
<camel:inOnly uri="activemq:queue:TESTQUEUE"/>
</camel:route>
I am trying to hit this route from a standalone client like this:
public static void main(String[] args) {
CamelContext context = new DefaultCamelContext();
producer = context.createProducerTemplate();
producer.sendBody("seda:input","Hey");
}
But my producer is not able to connect to the seda queue. Not able to hit queue of my route. Not able to add camelContext in my bean property. I am getting "Invalid property 'camelContext' of bean class". If I am sending the body to SEDA queue, message is going there but not to the next element of the rout
Upvotes: 1
Views: 7344
Reputation: 21015
As Petter suggested, your client needs to connect to the same Camel Context which the SEDA route is defined in. In your example, it appears that you are creating a new DefaultCamelContext() and trying to send a message through to the route that is defined in another context.
Generally, I define the Camel Context in Spring XML and then inject the context into any classes that need it...
<camelContext id="camelContext" xmlns="http://camel.apache.org/schema/spring">
<routeBuilder ref="myRouter"/>
</camelContext>
<bean id="myClient" class="com.mycompany.MyClient">
<property name="camelContext" ref="camelContext"/>
</bean>
Then, your client code would simply need to call the following...
getCamelContext().createProducerTemplate().sendBody("seda:input","Hey");
That said, if your client code is not in the same JVM or not able to get a handle to the same CamelContext, then your options are to use JMS, REST, HTTP (or any camel component that support remote client interfaces)...instead of or around the SEDA endpoint.
For example, you could wrap access to your SEDA queue with an HTTP endpoint (via camel-jetty) like this...
from("jetty:http://localhost:9001/input").to("seda:input");
Upvotes: 5
Reputation: 22279
The SEDA component in camel is indended as an asynchrnous internal channel. This is very useful if you need to decouple message processing into multiple threads and have a more elastic implementation.
In your example, you have an activemq endpoint. On a conceptual basis, it will do pretty much the same a SEDA component, but with more fetures. I suggest you use activemq or another protocol for clients communicating with Camel.
That said, if your client runs in the same java application as Camel and your client can get hold of the Camel context (which is a design I recommend against in general), you could use ProducerTemplates to send messages to SEDA components. Look at the VM component, which is pretty much the same as SEDA, but could be used in the same VM instead of the same Camel Context.How ProducerTemplate works.
Upvotes: 1