You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by lekkie <le...@gmail.com> on 2009/11/18 15:36:55 UTC

how to create a dynamic recipient list using a java bean

I have not been able to lay my hands on a complete tutorial that explains how
to create a recipientlist osgi bundle.

What I rily like to do is shown below:

jms:queue -> recipientlist

I am building using maven which I am a lil new to as well, so I'll
appreciate if pointers are shown how to also compile (if java bean is used
for loading dynamic routes) the java class.

Here is what I think my camel-context.xml should look like.

<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
		<property name="connectionFactory" ref="jmsConnectionFactory"/>
	</bean>

	<bean id="jmsConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
		<property name="alwaysSessionAsync" value="true"/>
		<property name="alwaysSyncSend" value="false"/>
		<property name="brokerURL" value="tcp://localhost:61616"/>
        </bean>

<bean id="recipientList" class="com.services.RouteBuilder"/>

  	<osgi:camelContext
xmlns="http://activemq.apache.org/camel/schema/spring">
		<route>
			<from uri="jms:queue:requestQueue" />
			<to uri="recipientList" />
		</route>
	</osgi:camelContext>

	<bean class="org.apache.servicemix.common.osgi.EndpointExporter" />

is the bold line correct? I expect whatever routes defined in the routes
have messages sent to them.

Content of route builder class
public class RouteBuilder {

	@RecipientList
    public String[] route(String body) {
        return new
String[]{"jbi:endpoint:http://services.com/nauService/endpoint?mep=in-out"};
    }

}

Are the route routes returned by the java class supposed to be endpoint
names defined in the bean.xml files or full endpoint name as registered by
NMR (It seems they are not always the same). Can they also e ordinary
service names as defined in the bean.xml files?

kr.
-- 
View this message in context: http://old.nabble.com/how-to-create-a-dynamic-recipient-list-using-a-java-bean-tp26408382p26408382.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: how to create a dynamic recipient list using a java bean

Posted by Gert Vanthienen <ge...@gmail.com>.
L.S.,

To get Maven to compile this class, you just have to add the .java
file to the src/main/java folder inside your bundle project.  The XML
file you pasted is getting very close to what you actually need.  You
already added your routing bean to the beans file and gave it an id
'recipientList'.

The routed itself needs one little fix afaik and should look like this:
<route>
    <from uri="jms:queue:requestQueue" />
    <bean ref="recipientList" method="route" />
</route>

The names returned by the bean are Camel endpoint uris so you can use
anything you could use for a to(...) method in a Camel route, e.g. if
you return "file:/somedir", "jms:queue:responseQueue" and
"log:response" the exchange will be written to a local file, sent to a
JMS queue and a log message.  Actually, you can return any URI you can
find on the http://camel.apache.org/components.html page and the
related pages.  If you want to integrate with other JBI endpoints in
the ESB, you can use the syntax described on
http://camel.apache.org/jbi.html.

Regards,

Gert Vanthienen
------------------------
Open Source SOA: http://fusesource.com
Blog: http://gertvanthienen.blogspot.com/



2009/11/18 lekkie <le...@gmail.com>:
>
> I have not been able to lay my hands on a complete tutorial that explains how
> to create a recipientlist osgi bundle.
>
> What I rily like to do is shown below:
>
> jms:queue -> recipientlist
>
> I am building using maven which I am a lil new to as well, so I'll
> appreciate if pointers are shown how to also compile (if java bean is used
> for loading dynamic routes) the java class.
>
> Here is what I think my camel-context.xml should look like.
>
> <bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
>                <property name="connectionFactory" ref="jmsConnectionFactory"/>
>        </bean>
>
>        <bean id="jmsConnectionFactory"
> class="org.apache.activemq.ActiveMQConnectionFactory">
>                <property name="alwaysSessionAsync" value="true"/>
>                <property name="alwaysSyncSend" value="false"/>
>                <property name="brokerURL" value="tcp://localhost:61616"/>
>        </bean>
>
> <bean id="recipientList" class="com.services.RouteBuilder"/>
>
>        <osgi:camelContext
> xmlns="http://activemq.apache.org/camel/schema/spring">
>                <route>
>                        <from uri="jms:queue:requestQueue" />
>                        <to uri="recipientList" />
>                </route>
>        </osgi:camelContext>
>
>        <bean class="org.apache.servicemix.common.osgi.EndpointExporter" />
>
> is the bold line correct? I expect whatever routes defined in the routes
> have messages sent to them.
>
> Content of route builder class
> public class RouteBuilder {
>
>        @RecipientList
>    public String[] route(String body) {
>        return new
> String[]{"jbi:endpoint:http://services.com/nauService/endpoint?mep=in-out"};
>    }
>
> }
>
> Are the route routes returned by the java class supposed to be endpoint
> names defined in the bean.xml files or full endpoint name as registered by
> NMR (It seems they are not always the same). Can they also e ordinary
> service names as defined in the bean.xml files?
>
> kr.
> --
> View this message in context: http://old.nabble.com/how-to-create-a-dynamic-recipient-list-using-a-java-bean-tp26408382p26408382.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>