You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by smo001 <s....@titoco.de> on 2008/12/11 10:24:55 UTC

How to create a filepoller which send a file to an eip pipeline

Hi all,

i have got a question about how to read files into a jbi container. I'd like
to read a file from a directory with a filepoller. Then it should be send to
an eip pipeline for xslt transformation and the transformed object should
delivered to JMS endpoint (a ActiveMQ Messagequeue). 
I took the example from
http://servicemix.apache.org/creating-a-protocol-bridge-30.html and added a
filepoller SU. The example uses a http SU to send an input.

Is it the right way to use the pipeline example to create a solution for my
problem? An how to implement the filepoller? I understand it like this, that
i have to put my file into a message container to send it to the next
service, is that right?

Actual my filepoller is like this, but i get an error "No endpoint found" in
the filepoller-su.

<?xml version="1.0" encoding="UTF-8"?>

<!-- XBean.xml -->

<beans xmlns:f="http://servicemix.apache.org/file/1.0"
       xmlns:b="http://servicemix.apache.org/formattransform/bridge"
	   xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://activemq.apache.org/camel/schema/spring
http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
	   

	<!-- the JBI container -->
	<container id="jbi">
		<property name="useMBeanServer" value="true"/>
		<property name="createMBeanServer" value="true"/>
		<property name="dumpStats" value="true"/>
		<property name="statsInterval" value="10"/>
		<!--property name="transactionManager" ref="transactionManager"/-->
		
		<components>
			<!-- Look for files in the inbox directory -->
			<component id="FilePoller" service="b:FilePoller"
class="org.servicemix.components.file.FilePoller">
				<property name="targetService" value="b:outputSender"/>
				<property name="targetEndpoint" value="endpoint" />
				<property name="endpoint" value="FilePoller"/>
				
				<property name="workManager" ref="workManager"/>
				<property name="file" value="file:///C:\Servicemix\inbox_opentrans"/>
				<property name="period" value="20000"/>
				<property name="filter">
					<bean class="org.apache.commons.io.filefilter.WildcardFilter">
						<constructor-arg value="*.xml"/>
					</bean>
				</property>
		</component> 
		<!-- Publish the result to a JMS destination -->
		<component id="outputSender" service="b:outputSender"
class="org.servicemix.components.jms.JmsSenderComponent">
			<property name="targetService" value="b:EipPipeline"/> 
			<property name="targetEndpoint" value="endpoint"/>
			<property name="endpoint" value="endpoint"/>
			
			<property name="template">
				<bean class="org.springframework.jms.core.JmsTemplate">
					<property name="connectionFactory">
						<ref local="jmsFactory"/>
					</property>
					<property name="pubSubDomain" value="true"/>
					<property name="deliveryModePersistent" value="true"/>
					<property name="priority" value="4"/>
					<property name="timeToLive" value="0"/>
				</bean>
			</property>
		</component>	
			
	    </components>    
	</container>
  	
	<bean id="transactionManager"
class="org.springframework.jndi.JndiObjectFactoryBean"> 
		<property name="jndiName" value="java:comp/env/smx/TransactionManager"/> 
	</bean>
	
	<bean id="jmsFactory"
class="org.apache.activemq.pool.PooledConnectionFactory">
		<property name="connectionFactory">
			<bean class="org.apache.activemq.ActiveMQConnectionFactory">
				<property name="brokerURL">
					<value>tcp://localhost:61616</value>
				</property>
			</bean>
		</property>
	</bean>
	
	<bean id="workManager" class="org.jencks.factory.WorkManagerFactoryBean">
		<property name="threadPoolSize" value="30"/>
		<property name="transactionManager" ref="transactionManager" />
	</bean>  
</beans>

Thanks for your help
Greetz
-- 
View this message in context: http://www.nabble.com/How-to-create-a-filepoller-which-send-a-file-to-an-eip-pipeline-tp20952145p20952145.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: How to create a filepoller which send a file to an eip pipeline

Posted by smo001 <s....@titoco.de>.
Hello again,

i've found the answer to my questions by my self. For everyone who has the
same problem with the usage of the bean components. the solution is to
create the bean project and to implement your methods in the java file. in
the xml file you call the init-method of your own class. So it should work.

Regards 
Stefan



Hello, 

thanks for your answer. I took a little bit time to read a lot about the
servicemix components and i found a solution for my problem. But at the
moment have the problem to read my messages from en ActiveMQ messagequeue. I
have already tested it with the jms consumer component and it works, but i'd
like to change some information in the messagebody and write them into a
file. So i use a bean component and implement in the java file to append
some text to my message body. But think my bean didn't listen to the message
queue, because nothing happens. 
Now i don't know which kind of bean i have to use. The onMessageExchange
method is only called, if i send a jms message. But my bean should listen
active to a message queue. 

example:
some applicationen puts messages to a activemq message queue -> my bean
service listens to the queue and if a message arrives in the queue, my
service took the message, appends something to the bodycontent and writes
the body to a file. 

Another example is the consumertool.java example in the apache activemq
package, it connects to a queue and waits for incoming messages. 

My problem is to integrate it into servicemix. 

Can someone explain me how it should work?

Regards

Stefan



-- 
View this message in context: http://www.nabble.com/How-to-create-a-filepoller-which-send-a-file-to-an-eip-pipeline-tp20952145p21213864.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: How to create a filepoller which send a file to an eip pipeline

Posted by smo001 <s....@titoco.de>.
Hello, 

thanks for your answer. I took a little bit time to read a lot about the
servicemix components and i found a solution for my problem. But at the
moment have the problem to read my messages from en ActiveMQ messagequeue. I
have already tested it with the jms consumer component and it works, but i'd
like to change some information in the messagebody and write them into a
file. So i use a bean component and implement in the java file to append
some text to my message body. But think my bean didn't listen to the message
queue, because nothing happens. 
Now i don't know which kind of bean i have to use. The onMessageExchange
method is only called, if i send a jms message. But my bean should listen
active to a message queue. 

example:
some applicationen puts messages to a activemq message queue -> my bean
service listens to the queue and if a message arrives in the queue, my
service took the message, appends something to the bodycontent and writes
the body to a file. 

Another example is the consumertool.java example in the apache activemq
package, it connects to a queue and waits for incoming messages. 

My problem is to integrate it into servicemix. 

Can someone explain me how it should work?

Regards

Stefan





Gert Vanthienen wrote:
> 
> L.S.,
> 
> The file you're using here contains a full container definition.  You 
> can use it for static configuration (where you specify everything in a 
> file and then run the container from that file), but from your mail I 
> gather you want to use ServiceMix in a stand-alone way as a container 
> and then deploy SA to it.
> 
> I would also recommend you to use the JBI components (as is shown in the 
> tutorials) rather than the lightweight components.  Perhaps you can take 
> a look at 
> http://servicemix.apache.org/2-beginner-using-maven-to-develop-jbi-applications.html 
> for a introduction in building SU/SA with Maven as that will no doubt 
> clarify things for you.
> 
> Regards,
> 
> Gert
> 
> smo001 wrote:
>> Hi all,
>>
>> i have got a question about how to read files into a jbi container. I'd
>> like
>> to read a file from a directory with a filepoller. Then it should be send
>> to
>> an eip pipeline for xslt transformation and the transformed object should
>> delivered to JMS endpoint (a ActiveMQ Messagequeue). 
>> I took the example from
>> http://servicemix.apache.org/creating-a-protocol-bridge-30.html and added
>> a
>> filepoller SU. The example uses a http SU to send an input.
>>
>> Is it the right way to use the pipeline example to create a solution for
>> my
>> problem? An how to implement the filepoller? I understand it like this,
>> that
>> i have to put my file into a message container to send it to the next
>> service, is that right?
>>
>> Actual my filepoller is like this, but i get an error "No endpoint found"
>> in
>> the filepoller-su.
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>>
>> <!-- XBean.xml -->
>>
>> <beans xmlns:f="http://servicemix.apache.org/file/1.0"
>>        xmlns:b="http://servicemix.apache.org/formattransform/bridge"
>> 	   xmlns="http://www.springframework.org/schema/beans"
>>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>        xsi:schemaLocation="
>>        http://www.springframework.org/schema/beans
>> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
>>        http://activemq.apache.org/camel/schema/spring
>> http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
>> 	   
>>
>> 	<!-- the JBI container -->
>> 	<container id="jbi">
>> 		<property name="useMBeanServer" value="true"/>
>> 		<property name="createMBeanServer" value="true"/>
>> 		<property name="dumpStats" value="true"/>
>> 		<property name="statsInterval" value="10"/>
>> 		<!--property name="transactionManager" ref="transactionManager"/-->
>> 		
>> 		<components>
>> 			<!-- Look for files in the inbox directory -->
>> 			<component id="FilePoller" service="b:FilePoller"
>> class="org.servicemix.components.file.FilePoller">
>> 				<property name="targetService" value="b:outputSender"/>
>> 				<property name="targetEndpoint" value="endpoint" />
>> 				<property name="endpoint" value="FilePoller"/>
>> 				
>> 				<property name="workManager" ref="workManager"/>
>> 				<property name="file" value="file:///C:\Servicemix\inbox_opentrans"/>
>> 				<property name="period" value="20000"/>
>> 				<property name="filter">
>> 					<bean class="org.apache.commons.io.filefilter.WildcardFilter">
>> 						<constructor-arg value="*.xml"/>
>> 					</bean>
>> 				</property>
>> 		</component> 
>> 		<!-- Publish the result to a JMS destination -->
>> 		<component id="outputSender" service="b:outputSender"
>> class="org.servicemix.components.jms.JmsSenderComponent">
>> 			<property name="targetService" value="b:EipPipeline"/> 
>> 			<property name="targetEndpoint" value="endpoint"/>
>> 			<property name="endpoint" value="endpoint"/>
>> 			
>> 			<property name="template">
>> 				<bean class="org.springframework.jms.core.JmsTemplate">
>> 					<property name="connectionFactory">
>> 						<ref local="jmsFactory"/>
>> 					</property>
>> 					<property name="pubSubDomain" value="true"/>
>> 					<property name="deliveryModePersistent" value="true"/>
>> 					<property name="priority" value="4"/>
>> 					<property name="timeToLive" value="0"/>
>> 				</bean>
>> 			</property>
>> 		</component>	
>> 			
>> 	    </components>    
>> 	</container>
>>   	
>> 	<bean id="transactionManager"
>> class="org.springframework.jndi.JndiObjectFactoryBean"> 
>> 		<property name="jndiName"
>> value="java:comp/env/smx/TransactionManager"/> 
>> 	</bean>
>> 	
>> 	<bean id="jmsFactory"
>> class="org.apache.activemq.pool.PooledConnectionFactory">
>> 		<property name="connectionFactory">
>> 			<bean class="org.apache.activemq.ActiveMQConnectionFactory">
>> 				<property name="brokerURL">
>> 					<value>tcp://localhost:61616</value>
>> 				</property>
>> 			</bean>
>> 		</property>
>> 	</bean>
>> 	
>> 	<bean id="workManager"
>> class="org.jencks.factory.WorkManagerFactoryBean">
>> 		<property name="threadPoolSize" value="30"/>
>> 		<property name="transactionManager" ref="transactionManager" />
>> 	</bean>  
>> </beans>
>>
>> Thanks for your help
>> Greetz
>>   
> 
> 
> 
> -----
> ---
> Gert Vanthienen
> http://gertvanthienen.blogspot.com
> 

-- 
View this message in context: http://www.nabble.com/How-to-create-a-filepoller-which-send-a-file-to-an-eip-pipeline-tp20952145p21090814.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: How to create a filepoller which send a file to an eip pipeline

Posted by Gert Vanthienen <ge...@skynet.be>.
L.S.,

The file you're using here contains a full container definition.  You 
can use it for static configuration (where you specify everything in a 
file and then run the container from that file), but from your mail I 
gather you want to use ServiceMix in a stand-alone way as a container 
and then deploy SA to it.

I would also recommend you to use the JBI components (as is shown in the 
tutorials) rather than the lightweight components.  Perhaps you can take 
a look at 
http://servicemix.apache.org/2-beginner-using-maven-to-develop-jbi-applications.html 
for a introduction in building SU/SA with Maven as that will no doubt 
clarify things for you.

Regards,

Gert

smo001 wrote:
> Hi all,
>
> i have got a question about how to read files into a jbi container. I'd like
> to read a file from a directory with a filepoller. Then it should be send to
> an eip pipeline for xslt transformation and the transformed object should
> delivered to JMS endpoint (a ActiveMQ Messagequeue). 
> I took the example from
> http://servicemix.apache.org/creating-a-protocol-bridge-30.html and added a
> filepoller SU. The example uses a http SU to send an input.
>
> Is it the right way to use the pipeline example to create a solution for my
> problem? An how to implement the filepoller? I understand it like this, that
> i have to put my file into a message container to send it to the next
> service, is that right?
>
> Actual my filepoller is like this, but i get an error "No endpoint found" in
> the filepoller-su.
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <!-- XBean.xml -->
>
> <beans xmlns:f="http://servicemix.apache.org/file/1.0"
>        xmlns:b="http://servicemix.apache.org/formattransform/bridge"
> 	   xmlns="http://www.springframework.org/schema/beans"
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>        xsi:schemaLocation="
>        http://www.springframework.org/schema/beans
> http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
>        http://activemq.apache.org/camel/schema/spring
> http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
> 	   
>
> 	<!-- the JBI container -->
> 	<container id="jbi">
> 		<property name="useMBeanServer" value="true"/>
> 		<property name="createMBeanServer" value="true"/>
> 		<property name="dumpStats" value="true"/>
> 		<property name="statsInterval" value="10"/>
> 		<!--property name="transactionManager" ref="transactionManager"/-->
> 		
> 		<components>
> 			<!-- Look for files in the inbox directory -->
> 			<component id="FilePoller" service="b:FilePoller"
> class="org.servicemix.components.file.FilePoller">
> 				<property name="targetService" value="b:outputSender"/>
> 				<property name="targetEndpoint" value="endpoint" />
> 				<property name="endpoint" value="FilePoller"/>
> 				
> 				<property name="workManager" ref="workManager"/>
> 				<property name="file" value="file:///C:\Servicemix\inbox_opentrans"/>
> 				<property name="period" value="20000"/>
> 				<property name="filter">
> 					<bean class="org.apache.commons.io.filefilter.WildcardFilter">
> 						<constructor-arg value="*.xml"/>
> 					</bean>
> 				</property>
> 		</component> 
> 		<!-- Publish the result to a JMS destination -->
> 		<component id="outputSender" service="b:outputSender"
> class="org.servicemix.components.jms.JmsSenderComponent">
> 			<property name="targetService" value="b:EipPipeline"/> 
> 			<property name="targetEndpoint" value="endpoint"/>
> 			<property name="endpoint" value="endpoint"/>
> 			
> 			<property name="template">
> 				<bean class="org.springframework.jms.core.JmsTemplate">
> 					<property name="connectionFactory">
> 						<ref local="jmsFactory"/>
> 					</property>
> 					<property name="pubSubDomain" value="true"/>
> 					<property name="deliveryModePersistent" value="true"/>
> 					<property name="priority" value="4"/>
> 					<property name="timeToLive" value="0"/>
> 				</bean>
> 			</property>
> 		</component>	
> 			
> 	    </components>    
> 	</container>
>   	
> 	<bean id="transactionManager"
> class="org.springframework.jndi.JndiObjectFactoryBean"> 
> 		<property name="jndiName" value="java:comp/env/smx/TransactionManager"/> 
> 	</bean>
> 	
> 	<bean id="jmsFactory"
> class="org.apache.activemq.pool.PooledConnectionFactory">
> 		<property name="connectionFactory">
> 			<bean class="org.apache.activemq.ActiveMQConnectionFactory">
> 				<property name="brokerURL">
> 					<value>tcp://localhost:61616</value>
> 				</property>
> 			</bean>
> 		</property>
> 	</bean>
> 	
> 	<bean id="workManager" class="org.jencks.factory.WorkManagerFactoryBean">
> 		<property name="threadPoolSize" value="30"/>
> 		<property name="transactionManager" ref="transactionManager" />
> 	</bean>  
> </beans>
>
> Thanks for your help
> Greetz
>