DAVIES, GARETH I [AG-Contractor/1000]
2005-06-15 17:40:25 UTC
An update. I finally managed to get this working after solving two issues:
1) PEBKAC - after further review, I wasn't forcing the use of CGLIB proxies after all and some of my proxies were JdkDynamicAopProxy objects. Once I set "proxyTargetClass" of my DefaultAdvisorAutoProxyCreator to true, the PooledConnectionFactory bean's connectionFactory instance field was set correctly.
2) However, there remained the issue of my broker configuration file not being loaded when I switched from Spring's SingleConnectionFactory to ActiveMQ's PooledConnectionFactory. After comparing both classes, I hit on the idea of calling createConnection() from the start() method of PooledConnectionFactory (using the "init-method" attribute of my jmsProducerFactory bean) and this worked like a charm. Just for giggles, I close all PooledConnection objects in the cache in the stop() method (using the "destroy-method" attribute). Could this be added to ActiveMQ's PooledConnectionFactory in time for the 3.1 release?
Gareth
-----Original Message-----
From: DAVIES, GARETH I [AG-Contractor/1000] [mailto:gareth.i.davies-DFMCWbniinBWk0Htik3J/***@public.gmane.org]
Sent: Wednesday, June 08, 2005 9:49 AM
To: 'user-UzBZ5Px8zVVI+***@public.gmane.org'
Subject: RE: [activemq-user] Re: PooledConnectionFactory and Spring JMS T emplate using AOP
James,
I agree that this is probably a Spring thing and that this manifested only now because none of my other proxied beans have concrete classes as mutator method arguments. This is not limited to PooledConnectionFactory, but applies to any other bean using such mutator methods with AOP proxying.
As far as a test case is concerned, I was able to wreak havoc by applying Spring's TraceInterceptor using their TruePointcut:
<beans>
<bean id="traceAdvisor" class="org.springframework.aop.support.DefaultPointcutAdvisor">
<property name="pointcut">
<bean class="org.springframework.aop.TruePointcut"/>
</property>
<property name="advice">
<bean class="org.springframework.aop.interceptor.TraceInterceptor"/>
</property>
</bean>
<bean id="aopProxyCreator"
class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator">
</bean>
<bean id="jmsFactory" class="org.activemq.ActiveMQConnectionFactory">
<property name="brokerURL"><value>vm://localhost</value></property>
<property name="useEmbeddedBroker"><value>true</value></property>
<property name="brokerXmlConfig">
<value>com/monsanto/ag/message/test/activemq-broker-config.xml</value>
</property>
</bean>
<bean id="activeMQContainer" class="org.activemq.jca.JCAContainer" depends-on="jmsFactory">
<!-- Work manager (thread pool) for this container -->
<property name="workManager">
<bean class="org.activemq.work.SpringWorkManager"/>
</property>
<!-- JCA Resource Adapter -->
<property name="resourceAdapter">
<bean class="org.activemq.ra.ActiveMQResourceAdapter">
<property name="serverUrl"><value>vm://localhost</value></property>
<!-- Resource adapter cannot start its own embedded broker -->
<property name="useEmbeddedBroker"><value>false</value></property>
</bean>
</property>
</bean>
<bean id="inboundConnector1" factory-method="addConnector" factory-bean="activeMQContainer">
<!-- Subscription details -->
<property name="activationSpec">
<bean class="org.activemq.ra.ActiveMQActivationSpec">
<property name="destination"><value>test.ecms.1</value></property>
<property name="destinationType"><value>javax.jms.Queue</value></property>
</bean>
</property>
<!-- Use local JMS transactions for this message listener -->
<property name="endpointFactory">
<bean class="org.activemq.jca.DefaultEndpointFactory">
<property name="messageListener"><ref local="testListener1"/></property>
</bean>
</property>
</bean>
<bean id="inboundConnector2" factory-method="addConnector" factory-bean="activeMQContainer">
<!-- Subscription details -->
<property name="activationSpec">
<bean class="org.activemq.ra.ActiveMQActivationSpec">
<property name="destination"><value>test.ecms.2</value></property>
<property name="destinationType"><value>javax.jms.Queue</value></property>
</bean>
</property>
<!-- Use local JMS transactions for this message listener -->
<property name="endpointFactory">
<bean class="org.activemq.jca.DefaultEndpointFactory">
<property name="messageListener"><ref local="testListener2"/></property>
</bean>
</property>
</bean>
<bean id="testListener1" class="com.monsanto.ag.message.test.MockMessageBean"/>
<bean id="testListener2" class="com.monsanto.ag.message.test.MockMessageBean">
<property name="willThrowException"><value>true</value></property>
</bean>
<bean id="jmsProducerFactory" class="org.activemq.pool.PooledConnectionFactory">
<property name="connectionFactory"><ref local="jmsFactory"/></property>
</bean>
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory"><ref local="jmsProducerFactory"/></property>
<property name="pubSubDomain"><value>false</value></property>
<!-- Use local JMS transactions to send messages -->
<property name="sessionTransacted"><value>true</value></property>
</bean>
<bean id="producerTransactionManager" class="org.springframework.jms.connection.JmsTransactionManager">
<property name="connectionFactory"><ref local="jmsProducerFactory"/></property>
</bean>
<bean id="jmsOperations" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager"><ref local="producerTransactionManager"/></property>
<property name="target"><ref local="jmsTemplate"/></property>
<property name="transactionAttributes">
<props>
<prop key="convertAndSend*">PROPAGATION_REQUIRED</prop>
<prop key="send*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
</beans>
Attempting to load this configuration with the following line of code throws exceptions (starting with the "resourceAdapter" property of "inboundConnector1").
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("/path/to/context/file");
So, this probably belongs on the Spring forum, yes? For now, I'll revert to SingleConnectionFactory while I rethink my tracing strategy.
Gareth
-----Original Message-----
From: jstrachan [mailto:jastrachan-***@public.gmane.org]
Sent: Wednesday, June 08, 2005 12:27 AM
To: user-UzBZ5Px8zVVI+***@public.gmane.org
Subject: [activemq-user] Re: PooledConnectionFactory and Spring JMS Templa te using AOP
I forget how off the top of my head. But since you are already using
CGLIB AOP in the same spring.xml, it seems its not disabled.
a little test case of the AOP stuff you're doing and submit it, then we
can try experiment a bit to get it to work.
This is really sounding like a Spring issue, as the
PooledConnectionFactory and ActiveMQConnectionFactory are just POJOs, so
if the Spring AOP is messing things up its most probably a spring thing
I'd have thought - I can't see any good reason why spring can't
configure the POJOs and do its proxies properly.
James
_________________________________________________________________________________
This e-mail message may contain privileged and/or confidential information, and is intended to be received only by persons entitled to receive such information. If you have received this e-mail in error, please notify the sender immediately. Please delete it and all attachments from any servers, hard drives or any other media. Other use of this e-mail by you is strictly prohibited.
All e-mails and attachments sent and received are subject to monitoring, reading and archival by Monsanto. The recipient of this e-mail is solely responsible for checking for the presence of "Viruses" or other "Malware". Monsanto accepts no liability for any damage caused by any such code transmitted by or accompanying this e-mail or any attachment.
_________________________________________________________________________________
_________________________________________________________________________________
This e-mail message may contain privileged and/or confidential information, and is intended to be received only by persons entitled to receive such information. If you have received this e-mail in error, please notify the sender immediately. Please delete it and all attachments from any servers, hard drives or any other media. Other use of this e-mail by you is strictly prohibited.
All e-mails and attachments sent and received are subject to monitoring, reading and archival by Monsanto. The recipient of this e-mail is solely responsible for checking for the presence of "Viruses" or other "Malware". Monsanto accepts no liability for any damage caused by any such code transmitted by or accompanying this e-mail or any attachment.
_________________________________________________________________________________
1) PEBKAC - after further review, I wasn't forcing the use of CGLIB proxies after all and some of my proxies were JdkDynamicAopProxy objects. Once I set "proxyTargetClass" of my DefaultAdvisorAutoProxyCreator to true, the PooledConnectionFactory bean's connectionFactory instance field was set correctly.
2) However, there remained the issue of my broker configuration file not being loaded when I switched from Spring's SingleConnectionFactory to ActiveMQ's PooledConnectionFactory. After comparing both classes, I hit on the idea of calling createConnection() from the start() method of PooledConnectionFactory (using the "init-method" attribute of my jmsProducerFactory bean) and this worked like a charm. Just for giggles, I close all PooledConnection objects in the cache in the stop() method (using the "destroy-method" attribute). Could this be added to ActiveMQ's PooledConnectionFactory in time for the 3.1 release?
Gareth
-----Original Message-----
From: DAVIES, GARETH I [AG-Contractor/1000] [mailto:gareth.i.davies-DFMCWbniinBWk0Htik3J/***@public.gmane.org]
Sent: Wednesday, June 08, 2005 9:49 AM
To: 'user-UzBZ5Px8zVVI+***@public.gmane.org'
Subject: RE: [activemq-user] Re: PooledConnectionFactory and Spring JMS T emplate using AOP
James,
I agree that this is probably a Spring thing and that this manifested only now because none of my other proxied beans have concrete classes as mutator method arguments. This is not limited to PooledConnectionFactory, but applies to any other bean using such mutator methods with AOP proxying.
As far as a test case is concerned, I was able to wreak havoc by applying Spring's TraceInterceptor using their TruePointcut:
<beans>
<bean id="traceAdvisor" class="org.springframework.aop.support.DefaultPointcutAdvisor">
<property name="pointcut">
<bean class="org.springframework.aop.TruePointcut"/>
</property>
<property name="advice">
<bean class="org.springframework.aop.interceptor.TraceInterceptor"/>
</property>
</bean>
<bean id="aopProxyCreator"
class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator">
</bean>
<bean id="jmsFactory" class="org.activemq.ActiveMQConnectionFactory">
<property name="brokerURL"><value>vm://localhost</value></property>
<property name="useEmbeddedBroker"><value>true</value></property>
<property name="brokerXmlConfig">
<value>com/monsanto/ag/message/test/activemq-broker-config.xml</value>
</property>
</bean>
<bean id="activeMQContainer" class="org.activemq.jca.JCAContainer" depends-on="jmsFactory">
<!-- Work manager (thread pool) for this container -->
<property name="workManager">
<bean class="org.activemq.work.SpringWorkManager"/>
</property>
<!-- JCA Resource Adapter -->
<property name="resourceAdapter">
<bean class="org.activemq.ra.ActiveMQResourceAdapter">
<property name="serverUrl"><value>vm://localhost</value></property>
<!-- Resource adapter cannot start its own embedded broker -->
<property name="useEmbeddedBroker"><value>false</value></property>
</bean>
</property>
</bean>
<bean id="inboundConnector1" factory-method="addConnector" factory-bean="activeMQContainer">
<!-- Subscription details -->
<property name="activationSpec">
<bean class="org.activemq.ra.ActiveMQActivationSpec">
<property name="destination"><value>test.ecms.1</value></property>
<property name="destinationType"><value>javax.jms.Queue</value></property>
</bean>
</property>
<!-- Use local JMS transactions for this message listener -->
<property name="endpointFactory">
<bean class="org.activemq.jca.DefaultEndpointFactory">
<property name="messageListener"><ref local="testListener1"/></property>
</bean>
</property>
</bean>
<bean id="inboundConnector2" factory-method="addConnector" factory-bean="activeMQContainer">
<!-- Subscription details -->
<property name="activationSpec">
<bean class="org.activemq.ra.ActiveMQActivationSpec">
<property name="destination"><value>test.ecms.2</value></property>
<property name="destinationType"><value>javax.jms.Queue</value></property>
</bean>
</property>
<!-- Use local JMS transactions for this message listener -->
<property name="endpointFactory">
<bean class="org.activemq.jca.DefaultEndpointFactory">
<property name="messageListener"><ref local="testListener2"/></property>
</bean>
</property>
</bean>
<bean id="testListener1" class="com.monsanto.ag.message.test.MockMessageBean"/>
<bean id="testListener2" class="com.monsanto.ag.message.test.MockMessageBean">
<property name="willThrowException"><value>true</value></property>
</bean>
<bean id="jmsProducerFactory" class="org.activemq.pool.PooledConnectionFactory">
<property name="connectionFactory"><ref local="jmsFactory"/></property>
</bean>
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory"><ref local="jmsProducerFactory"/></property>
<property name="pubSubDomain"><value>false</value></property>
<!-- Use local JMS transactions to send messages -->
<property name="sessionTransacted"><value>true</value></property>
</bean>
<bean id="producerTransactionManager" class="org.springframework.jms.connection.JmsTransactionManager">
<property name="connectionFactory"><ref local="jmsProducerFactory"/></property>
</bean>
<bean id="jmsOperations" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager"><ref local="producerTransactionManager"/></property>
<property name="target"><ref local="jmsTemplate"/></property>
<property name="transactionAttributes">
<props>
<prop key="convertAndSend*">PROPAGATION_REQUIRED</prop>
<prop key="send*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
</beans>
Attempting to load this configuration with the following line of code throws exceptions (starting with the "resourceAdapter" property of "inboundConnector1").
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("/path/to/context/file");
So, this probably belongs on the Spring forum, yes? For now, I'll revert to SingleConnectionFactory while I rethink my tracing strategy.
Gareth
-----Original Message-----
From: jstrachan [mailto:jastrachan-***@public.gmane.org]
Sent: Wednesday, June 08, 2005 12:27 AM
To: user-UzBZ5Px8zVVI+***@public.gmane.org
Subject: [activemq-user] Re: PooledConnectionFactory and Spring JMS Templa te using AOP
James,
ApplicationConnectionFactory is a subclass of
ActiveMQConnectionFactory (used to integrate the Spring application
context with the broker configuration - there was a previous thread on
this), so I assumed that would work...
Ah OK - then it that case, it should work.ApplicationConnectionFactory is a subclass of
ActiveMQConnectionFactory (used to integrate the Spring application
context with the broker configuration - there was a previous thread on
this), so I assumed that would work...
I am using CGLIB dynamic proxies, since the tracing advisor applies to
some classes that do not implement interfaces (horrors!).
:)some classes that do not implement interfaces (horrors!).
By "Have you CGLIB AOP support enabled?", is there something special I
have to do in ActiveMQ.
No its a Spring thing. There's a way of disabling CGLIB when doing AOP;have to do in ActiveMQ.
I forget how off the top of my head. But since you are already using
CGLIB AOP in the same spring.xml, it seems its not disabled.
I also tried adding (ugly) code to the setConnectionFactory() method
of my modified PooledConnectionFactory to pull the
ApplicationConnectionFactory object out of the Advised.TargetSource
object. This worked OK, but once again my broker configuration file
was not loaded (e.g. no persistence adapter found).
Hmmm, I don't have many other ideas yet. I wonder, could you try createof my modified PooledConnectionFactory to pull the
ApplicationConnectionFactory object out of the Advised.TargetSource
object. This worked OK, but once again my broker configuration file
was not loaded (e.g. no persistence adapter found).
a little test case of the AOP stuff you're doing and submit it, then we
can try experiment a bit to get it to work.
This is really sounding like a Spring issue, as the
PooledConnectionFactory and ActiveMQConnectionFactory are just POJOs, so
if the Spring AOP is messing things up its most probably a spring thing
I'd have thought - I can't see any good reason why spring can't
configure the POJOs and do its proxies properly.
James
_________________________________________________________________________________
This e-mail message may contain privileged and/or confidential information, and is intended to be received only by persons entitled to receive such information. If you have received this e-mail in error, please notify the sender immediately. Please delete it and all attachments from any servers, hard drives or any other media. Other use of this e-mail by you is strictly prohibited.
All e-mails and attachments sent and received are subject to monitoring, reading and archival by Monsanto. The recipient of this e-mail is solely responsible for checking for the presence of "Viruses" or other "Malware". Monsanto accepts no liability for any damage caused by any such code transmitted by or accompanying this e-mail or any attachment.
_________________________________________________________________________________
_________________________________________________________________________________
This e-mail message may contain privileged and/or confidential information, and is intended to be received only by persons entitled to receive such information. If you have received this e-mail in error, please notify the sender immediately. Please delete it and all attachments from any servers, hard drives or any other media. Other use of this e-mail by you is strictly prohibited.
All e-mails and attachments sent and received are subject to monitoring, reading and archival by Monsanto. The recipient of this e-mail is solely responsible for checking for the presence of "Viruses" or other "Malware". Monsanto accepts no liability for any damage caused by any such code transmitted by or accompanying this e-mail or any attachment.
_________________________________________________________________________________