Hello list,
I am using Mule 2.0.2 in a projet.
The goal is to download a csv file from a FTP server, create an object for each line in the csv, get some data’s from a DB and process the objects and the data’s to crate new records in the DB.
I need to use Hibernate to read and write to the DB, how can I setup Mule in order to have access to the Hibernate session in my component?
Here is my config file:
<model>
<service name="ftpService">
<inbound>
<quartz:inbound-endpoint jobName="FtpJob"
repeatInterval="60000">
<quartz:event-generator-job />
</quartz:inbound-endpoint>
</inbound>
<component
class="com.marketip.tmc.component.FtpComponent">
</component>
<outbound>
<list-message-splitter-router>
<vm:outbound-endpoint path="events">
<payload-type-filter
expectedType="com.marketip.tmc.TrafficEventList" />
</vm:outbound-endpoint>
<vm:outbound-endpoint path="flow">
<payload-type-filter
expectedType="com.marketip.tmc.TrafficFlowList" />
</vm:outbound-endpoint>
</list-message-splitter-router>
</outbound>
</service>
<service name="eventService">
<inbound>
<vm:inbound-endpoint path="events">
</vm:inbound-endpoint>
</inbound>
<component
class="com.marketip.tmc.component.TrafficEventComponent" />
</service>
<service name="flowService">
<inbound>
<vm:inbound-endpoint path="flow"></vm:inbound-endpoint>
</inbound>
<component
class="com.marketip.tmc.component.TrafficFlowComponent" />
</service>
</model>
Thank you for your help.
Regards
|
---------------------------------------------------------------------------------------------------------
****
DISCLAIMER ****
This e-mail and any attachments thereto may contain information
which is confidential and/or protected by intellectual property rights
and are intended for the sole use of the recipient(s) named above.
Any use of the information contained herein (including, but not limited to,
total or partial reproduction, communication or distribution in any form)
by persons other than the designated recipient(s) is prohibited.
If you have received this e-mail in error, please notify the sender either
by telephone or by e-mail and delete the material from any computer.
Thank
you for your cooperation.
---------------------------------------------------------------------------------------------------------
Hello,
I found several information’s about this pattern, but I don’t know how to configure spring and mule to have access to my dao in the mule component.
Here is a spring config:
<beans
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.5.xsd">
<bean id="eventDao" class="com.marketip.tmc.dao.EventDaoImpl">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
<property name="configurationClass">
<value>org.hibernate.cfg.AnnotationConfiguration</value>
</property>
</bean>
</beans>
I include this configuration in mule configuration with
<spring:beans>
<spring:import resource="applicationContext.xml"/>
</spring:beans>
I my component, I have a private property of type EventDao, but the property is null when the component is called. How can I inject in mule the correct object defined in spring?
Sorry, I am new to Spring.
Thank you for your help.
|
---------------------------------------------------------------------------------------------------------
****
DISCLAIMER ****
This e-mail and any attachments thereto may contain information
which is confidential and/or protected by intellectual property rights
and are intended for the sole use of the recipient(s) named above.
Any use of the information contained herein (including, but not limited to,
total or partial reproduction, communication or distribution in any form)
by persons other than the designated recipient(s) is prohibited.
If you have received this e-mail in error, please notify the sender either
by telephone or by e-mail and delete the material from any computer.
Thank
you for your cooperation.
---------------------------------------------------------------------------------------------------------
De : Andrew
Perepelytsya [mailto:aper...@gmail.com]
Envoyé : lundi 27 octobre
2008 15:05
À : us...@mule.codehaus.org
Objet : Re: [mule-user] Using
Hibernate in a component
Hello Andew,
Here is my configuration file for Mule :
<spring:beans>
<spring:import resource="applicationContext.xml"/>
</spring:beans>
<model>
I need to use Hibernate in TrafficEventComponent and TrafficFlowComponent.
Here is a snippet of code of TrafficEventComponent:
public class TrafficEventComponent implements Callable {
private static final Logger log = LoggerFactory.getLogger(TrafficEventComponent.class);
private EventDao eventDao = null;
@Override
public Object onCall(MuleEventContext eventContext) throws Exception {
List<TrafficEvent> list = ((TrafficEventList)eventContext.getMessage().getPayload()).getEvents();
log.info("Start processing {} events", list.size());
TrafficEvent dbEvent = null;
for (TrafficEvent trafficEvent : list) {
dbEvent = eventDao.getEvent(trafficEvent.getMessageId());
}
return null;
}
}
Thank you.
|
---------------------------------------------------------------------------------------------------------
****
DISCLAIMER ****
This e-mail and any attachments thereto may contain information
which is confidential and/or protected by intellectual property rights
and are intended for the sole use of the recipient(s) named above.
Any use of the information contained herein (including, but not limited to,
total or partial reproduction, communication or distribution in any form)
by persons other than the designated recipient(s) is prohibited.
If you have received this e-mail in error, please notify the sender either
by telephone or by e-mail and delete the material from any computer.
Thank
you for your cooperation.
---------------------------------------------------------------------------------------------------------
De : Andrew
Perepelytsya [mailto:aper...@gmail.com]
Envoyé : lundi 27 octobre
2008 15:19
À : us...@mule.codehaus.org
Objet : Re: [mule-user] Using
Hibernate in a component
How did you configure your component in Mule?
Andrew
I added getter and setter for my DAO field, modified my Spring configuration as mentioned in the link below, but now I have this exception:
ERROR 2008-10-27 16:03:56,828 eventService.9 org.mule.service.DefaultServiceExceptionStrategy -
********************************************************************************
Message : Component that caused exception is: eventService. Message payload is of type: TrafficEventList
Type : org.mule.api.service.ServiceException
Code : MULE_ERROR--2
Payload : com.marketip.tmc.TrafficEventList@431d9d
JavaDoc : http://mule.mulesource.org/docs/apidocs/org/mule/api/service/ServiceException.html
********************************************************************************
Exception stack is:
1. No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here (org.hibernate.HibernateException)
org.springframework.orm.hibernate3.SpringSessionContext:63 (null)
2. Component that caused exception is: eventService. Message payload is of type: TrafficEventList (org.mule.api.service.ServiceException)
org.mule.component.DefaultLifecycleAdapter:214 (http://mule.mulesource.org/docs/apidocs/org/mule/api/service/ServiceException.html)
********************************************************************************
Root Exception stack trace:
org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
at org.springframework.orm.hibernate3.SpringSessionContext.currentSession(SpringSessionContext.java:63)
at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:544)
at com.marketip.tmc.dao.EventDaoImpl.getEvent(EventDaoImpl.java:34)
at com.marketip.tmc.component.TrafficEventComponent.processEvents(TrafficEventComponent.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.mule.model.resolvers.AbstractEntryPointResolver.invokeMethod(AbstractEntryPointResolver.java:147)
at org.mule.model.resolvers.ReflectionEntryPointResolver.invoke(ReflectionEntryPointResolver.java:127)
at org.mule.model.resolvers.DefaultEntryPointResolverSet.invoke(DefaultEntryPointResolverSet.java:50)
at org.mule.component.DefaultLifecycleAdapter.intercept(DefaultLifecycleAdapter.java:202)
at org.mule.component.AbstractJavaComponent.invokeComponentInstance(AbstractJavaComponent.java:84)
at org.mule.component.AbstractJavaComponent.doOnCall(AbstractJavaComponent.java:75)
at org.mule.component.AbstractComponent.onCall(AbstractComponent.java:96)
at org.mule.model.seda.SedaService$ComponentStageWorker.run(SedaService.java:536)
at org.mule.work.WorkerContext.run(WorkerContext.java:310)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1061)
at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:575)
at java.lang.Thread.run(Thread.java:619)
********************************************************************************
My DAO is defined as this:
public class EventDaoImpl extends HibernateDaoSupport implements EventDao {
Must I define a transaction manager? If yes, how can I do that?
Thank you.
De : Andrew
Perepelytsya [mailto:aper...@gmail.com]
Envoyé : lundi 27 octobre
2008 15:44
À : us...@mule.codehaus.org
Objet : Re: [mule-user] Using
Hibernate in a component
Check out http://mule.mulesource.org/display/MULE2USER/Using+Spring+Beans+as+Service+Components . You need to reference an existing spring bean when defining a Mule service.