-
1. Re: JPA binding with Switchyard
igarashitm Dec 9, 2015 8:51 AM (in response to bhampton)Can you ellaborate on your problem? If you just need to control transaction boundary, take a look at Transaction Policy - Policy - SwitchYard - Project Documentation Editor
Also SwitchYard JPA binding is using Camel JPA component under the cover, so one of those options may help you - Apache Camel: JPA
-
2. Re: JPA binding with Switchyard
tcunning Dec 9, 2015 9:49 AM (in response to bhampton)Brennon,
Also, if you can attach a sample app that demonstrates the memory leak, that'd be very helpful in diagnosing where the leak occurs.
-
3. Re: JPA binding with Switchyard
bhampton Dec 10, 2015 4:21 AM (in response to igarashitm)Hi Tomohisa, thanks for your response. I have included code snippets to the problem I'm experiencing. Hope this helps.
Switchyard.xml
<sca:composite name="blah" targetNamespace="urn:blah:blah:1.0">
<sca:component name="CamelServiceRoute">
<camel:implementation.camel>
<camel:java class="CamelServiceRoute"/>
</camel:implementation.camel>
<sca:service name="TimerService">
<sca:interface.java interface="Timer"/>
</sca:service>
<sca:reference name="StoreMarket">
<sca:interface.java interface="StoreMarket"/>
</sca:reference>
</sca:component>
<sca:component name="StoreMarketBean">
<bean:implementation.bean class="StoreMarketBean"/>
<sca:service name="StoreMarket">
<sca:interface.java interface="StoreMarket"/>
</sca:service>
<sca:reference name="StoreSecurities">
<sca:interface.java interface="StoreSecurities"/>
</sca:reference>
<sca:reference name="StoreForex">
<sca:interface.java interface="StoreForex"/>
</sca:reference>
</sca:component>
<sca:reference name="StoreSecurities" multiplicity="0..1" promote="StoreMarketBean/StoreSecurities">
<sca:interface.java interface="StoreSecurities"/>
<jpa:binding.jpa name="jpa1">
<jpa:entityClassName>Security</jpa:entityClassName>
<jpa:persistenceUnit>SecurityUnit</jpa:persistenceUnit>
<jpa:transactionManager>#jtaTransactionManager</jpa:transactionManager>
<jpa:produce>
<jpa:flushOnSend>false</jpa:flushOnSend>
<jpa:usePersist>false</jpa:usePersist>
</jpa:produce>
</jpa:binding.jpa>
</sca:reference>
<sca:service name="TimerService" promote="CamelServiceRoute/TimerService">
<sca:interface.java interface="Timer"/>
<quartz:binding.quartz name="TimerService1">
<quartz:name>TimerService1</quartz:name>
<quartz:cron>0 */1 * * * ?</quartz:cron>
</quartz:binding.quartz>
</sca:service>
<sca:reference name="StoreForex" multiplicity="0..1" promote="StoreMarketBean/StoreForex">
<sca:interface.java interface="StoreForex"/>
<jpa:binding.jpa name="jpa2">
<jpa:entityClassName>Forex</jpa:entityClassName>
<jpa:persistenceUnit>SecurityUnit</jpa:persistenceUnit>
<jpa:transactionManager>#jtaTransactionManager</jpa:transactionManager>
<jpa:produce>
<jpa:flushOnSend>false</jpa:flushOnSend>
</jpa:produce>
</jpa:binding.jpa>
</sca:reference>
</sca:composite
CamelRoute
from("switchyard://TimerService").routeId("timerRoute").log(
"Received request from Timer Service")
.bean(StoreMarketBean.class, "saveSecurities(${body})")
.log("Securities saved to DB")
.bean(StoreMarketBean.class, "saveForex(${body})")
.log("Forex saved to DB");
StoreMarketBean
@Inject
@Reference("StoreSecurities")
private StoreSecurities securityService;
@Inject
@Reference("StoreForex")
private StoreForex forexService;
@Override
public void saveSecurities() {
for (int i = 0; i < 500; i++) {
Security security = new Security(); <-- persistence entity
security.setSecNo(String.valueOf(i));
securityService.execute(security);
}
}
@Override
public void saveForex() {
for (int i = 0; i < 50; i++) {
Forex forex = new Forex(); <-- persistence entity
forex.setCurrencyCode(String.valueOf(i));
forex.setStage(1l);
forexService.execute(forex);
}
}
persistence.xml
<persistence-unit name="SecurityUnit"
transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<!-- oracle datasource -->
<jta-data-source>java:jboss/datasources/OracleXADS</jta-data-source>
<classSecurity</class>
<class>Forex</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<!-- oracle DB -->
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.transaction.jta.platform"
value="org.hibernate.service.jta.platform.internal.JBossAppServerJtaPlatform" />
</properties>
</persistence-unit>
</persistence>
-
4. Re: JPA binding with Switchyard
bhampton Dec 10, 2015 5:16 AM (in response to tcunning)Hi Tom
Got a sample app, how do I get it to you? Are you just looking for the jar file?
regards
Brennon
-
5. Re: JPA binding with Switchyard
tcunning Dec 16, 2015 12:23 PM (in response to bhampton)Brennon,
I believe that if you switch to "Use advanced editor" you can add an attachment to this post (I see it in the lower right hand corner of the reply box). If you can't, could you open up a JIRA against SwitchYard at jira.jboss.org and attach it to the JIRA?
-
6. Re: JPA binding with Switchyard
bhampton Dec 17, 2015 3:37 AM (in response to tcunning)Hi Tom,
thanks again for the response. I have attached a sample app along with the source.Please be gentle with the critique, the holiday season is nearly upon us