You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by RadoslavStoyanov <ra...@softwareag.com> on 2011/12/05 20:45:06 UTC

Performance issue with Camel JMS publish/subscribe

Hi,
I experience the next problem:
Created two Endpoints pointing to same JMS topic. The JMS provider is
WmBroker.
Used Spring xml descriptor to define the Camel context. The first endpoint
is used for publishing, the second for subscribing.
I instantiated two of our pub/sub API classes to test the performance - one
using directly our wmBroker api, and another one using Camel for pub/sub.

The test is:
There is registered one subscriber listener.
In another thread there are sent 10000 messages. 
Ther start time is registered. 
When the last message is received the listener register the end time.
Then the sent messages are devided by the passed time and the result is the
passed through messages per second.

The disturbing thing is that the custom API using the same connection
factory shows 10:1 better performance in same conditions as Camel.
Do you have any ide why Camel shows so big performance drawback?
This is the used camel context, if it is neded I could provide also the test
java code used for the performance test.

<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.xsd
       http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">

	<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
		
		<jmxAgent id="agent" createConnector="true" />	
		<endpoint id="inboundSMS"
uri="jms:topic:Event::WebM::Communication::Sms::SmsSent" />
		<endpoint id="outboundSMS"
uri="jms:topic:Event::WebM::Communication::Sms::SmsSent" />
		
	</camelContext>

	<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
		<property name="connectionFactory">
			<bean class="com.webmethods.jms.impl.WmConnectionFactoryImpl">
				<property name="BrokerHost" value="localhost:6849" />
				<property name="BrokerName" value="Broker #1" />
				<property name="ClientGroup" value="StressGroup" />
			</bean>
		</property>
	</bean>

	<bean id="etStoreConfig"
	
class="com.softwareag.eda.configuration.beans.FileEventTypeStoreConfigType">
		<property name="location" value="E:/SoftwareAG/common/EventTypeStore" />
	</bean>

	<bean id="edaEventTypeStore"
class="com.softwareag.eda.store.api.EventTypeStoreFactory"
		factory-method="createEventTypeStore" depends-on="etStoreConfig">
		<constructor-arg name="configuration" ref="etStoreConfig"
type="com.softwareag.eda.configuration.beans.EventTypeStoreConfigType"/>
	</bean>	

	<bean id="camelConnector"
class="org.apache.camel.example.spring.CamelConnector">
		<property name="context" ref="camel" />
	</bean>

	<bean id="eventTypeID" class="com.softwareag.eda.store.api.EDAEventTypeID">
		<constructor-arg name="namespace"
value="http://namespaces.softwareag.com/EDA/WebM/Communication/Sms"/>
		<constructor-arg name="name" value="SmsSent"/>
	</bean>

	<bean id="edaOrchestratorCamel"
class="com.softwareag.eda.orchestrator.impl.EDAOrchestratorImpl"
depends-on="camelConnector, edaEventTypeStore">
		<constructor-arg name="connector" ref="camelConnector"
type="com.softwareag.eda.connector.EventBusConnector"/>
		<constructor-arg name="eventTypeStore" ref="edaEventTypeStore"
type="com.softwareag.eda.store.api.EDAEventTypeStore"/>
	</bean>

	<bean id="streamConfiguration" class="java.io.FileInputStream" >
		<constructor-arg value="C:/edaconfig/edaConfig.xml"
type="java.lang.String"/>
	</bean>

	<bean id="edaOrchestratorCustom"
class="com.softwareag.eda.orchestrator.api.EDAOrchestratorFactory"
factory-method="createOrchestrator" depends-on="streamConfiguration">
		<constructor-arg ref="streamConfiguration" type="java.io.InputStream"/>
	</bean>
	

	<bean id="testClient" class="org.apache.camel.example.spring.TestClient"
		init-method="init" depends-on="edaOrchestratorCamel,
edaOrchestratorCustom">
		<property name="orchestratorCamel" ref="edaOrchestratorCamel" />
		<property name="orchestratorCustom" ref="edaOrchestratorCustom" />
		<property name="edaEventTypeID" ref="eventTypeID" />
	</bean>

</beans>


--
View this message in context: http://camel.465427.n5.nabble.com/Performance-issue-with-Camel-JMS-publish-subscribe-tp5049909p5049909.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Performance issue with Camel JMS publish/subscribe

Posted by RadoslavStoyanov <ra...@softwareag.com>.
Sorry I mean producer, not publisher ....

--
View this message in context: http://camel.465427.n5.nabble.com/Performance-issue-with-Camel-JMS-publish-subscribe-tp5049909p5052134.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Performance issue with Camel JMS publish/subscribe

Posted by RadoslavStoyanov <ra...@softwareag.com>.
Hi Sven,
Thanks a lot!
This explains the current behavior, I'll try the proposed solution and will
give you a feedback if the problem is still present or is solved.

Regards,
Rado

--
View this message in context: http://camel.465427.n5.nabble.com/Performance-issue-with-Camel-JMS-publish-subscribe-tp5049909p5054760.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Performance issue with Camel JMS publish/subscribe

Posted by RadoslavStoyanov <ra...@softwareag.com>.
Hi Sven,

Thanks for the hint! 
We'll investigate further...
Thanks once more for the nice assistance!

Regards,
Rado

--
View this message in context: http://camel.465427.n5.nabble.com/Performance-issue-with-Camel-JMS-publish-subscribe-tp5049909p5068422.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Performance issue with Camel JMS publish/subscribe

Posted by Sven Zethelius <sv...@expedia.com>.
No idea.  Next steps are probably to turn on tracing on the Camel Context so that it logs a record of every message sent.  Then you can use that to correlate and see if Camel thinks the JMS provider accepted the message, then start looking at possibly the messages being lost by the JMS implementation.  Additionally, think about registering an ExceptionListener to see if the JMS is reporting any useful information about lost messages.

-----Original Message-----
From: RadoslavStoyanov [mailto:radoslav.stoyanov@softwareag.com] 
Sent: Thursday, December 08, 2011 8:38 AM
To: users@camel.apache.org
Subject: RE: Performance issue with Camel JMS publish/subscribe

Hi Sven,

Adding the cached factory wrapper increased the performance with 800%!
Now I have another issue, when I do threaded send - 10 threads publish to
the same endpoint and one consumer - it happens that some of the messages
are lost (didn't reach the consumer) - not a big number, but there are lost
messages. The broker is local, so no network issues are possible.
Do you think this could be because of endpoint setup?

Regards,
Rado

--
View this message in context: http://camel.465427.n5.nabble.com/Performance-issue-with-Camel-JMS-publish-subscribe-tp5049909p5059357.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Performance issue with Camel JMS publish/subscribe

Posted by RadoslavStoyanov <ra...@softwareag.com>.
Hi Sven,

Adding the cached factory wrapper increased the performance with 800%!
Now I have another issue, when I do threaded send - 10 threads publish to
the same endpoint and one consumer - it happens that some of the messages
are lost (didn't reach the consumer) - not a big number, but there are lost
messages. The broker is local, so no network issues are possible.
Do you think this could be because of endpoint setup?

Regards,
Rado

--
View this message in context: http://camel.465427.n5.nabble.com/Performance-issue-with-Camel-JMS-publish-subscribe-tp5049909p5059357.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Performance issue with Camel JMS publish/subscribe

Posted by Sven Zethelius <sv...@expedia.com>.
Camel Producer uses a Spring-JMS JmsTemplate.  The JmsTemplate doesn't keep a reference to JMS Connection or Session between calls to execute.  It relies on the ConnectionFactory to manage that, hence the SingleConnectionFactory and CachingConnectionFactory.

-----Original Message-----
From: RadoslavStoyanov [mailto:radoslav.stoyanov@softwareag.com] 
Sent: Tuesday, December 06, 2011 5:54 AM
To: users@camel.apache.org
Subject: RE: Performance issue with Camel JMS publish/subscribe

Hi Sven,

This is code snippet of my publish functionality:

			Producer producer = producers.get(eventTypeID);
			if(producer == null)
			{
				String inChannel = resolveEventTypeToInChannel(eventTypeID);
				Endpoint send = context.getEndpoint(inChannel);
				producer = send.createProducer();
				producers.put(eventTypeID, producer);
			}
			
			Exchange exchange = producer.createExchange();
			exchange.getIn().setBody(content); 
			producer.process(exchange);

Doesn't that logic guarantee that I use the same connection every time,
since I use the same publisher?

--
View this message in context: http://camel.465427.n5.nabble.com/Performance-issue-with-Camel-JMS-publish-subscribe-tp5049909p5052131.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Performance issue with Camel JMS publish/subscribe

Posted by RadoslavStoyanov <ra...@softwareag.com>.
Hi Sven,

This is code snippet of my publish functionality:

			Producer producer = producers.get(eventTypeID);
			if(producer == null)
			{
				String inChannel = resolveEventTypeToInChannel(eventTypeID);
				Endpoint send = context.getEndpoint(inChannel);
				producer = send.createProducer();
				producers.put(eventTypeID, producer);
			}
			
			Exchange exchange = producer.createExchange();
			exchange.getIn().setBody(content); 
			producer.process(exchange);

Doesn't that logic guarantee that I use the same connection every time,
since I use the same publisher?

--
View this message in context: http://camel.465427.n5.nabble.com/Performance-issue-with-Camel-JMS-publish-subscribe-tp5049909p5052131.html
Sent from the Camel - Users mailing list archive at Nabble.com.

RE: Performance issue with Camel JMS publish/subscribe

Posted by Sven Zethelius <sv...@expedia.com>.
I suspect you aren't caching the connection/sessions.  Try wrapping the connectionfactory with a org.springframework.jms.connection.SingleConnectionFactory or org.springframework.jms.connection.CachingConnectionFactory.  In your direct case, you have a persisted connections, and most likely a single session.  The default behavior of Spring-JMS, which is what Camel is using, is to let the connectionfactory worry about the caching by asking it each time for a fresh instance (e.g. through the SingleConnectionFactory or CachingConnectionFactory wrappers).

-----Original Message-----
From: RadoslavStoyanov [mailto:radoslav.stoyanov@softwareag.com] 
Sent: Monday, December 05, 2011 11:45 AM
To: users@camel.apache.org
Subject: Performance issue with Camel JMS publish/subscribe

Hi,
I experience the next problem:
Created two Endpoints pointing to same JMS topic. The JMS provider is
WmBroker.
Used Spring xml descriptor to define the Camel context. The first endpoint
is used for publishing, the second for subscribing.
I instantiated two of our pub/sub API classes to test the performance - one
using directly our wmBroker api, and another one using Camel for pub/sub.

The test is:
There is registered one subscriber listener.
In another thread there are sent 10000 messages. 
Ther start time is registered. 
When the last message is received the listener register the end time.
Then the sent messages are devided by the passed time and the result is the
passed through messages per second.

The disturbing thing is that the custom API using the same connection
factory shows 10:1 better performance in same conditions as Camel.
Do you have any ide why Camel shows so big performance drawback?
This is the used camel context, if it is neded I could provide also the test
java code used for the performance test.

<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.xsd
       http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">

	<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
		
		<jmxAgent id="agent" createConnector="true" />	
		<endpoint id="inboundSMS"
uri="jms:topic:Event::WebM::Communication::Sms::SmsSent" />
		<endpoint id="outboundSMS"
uri="jms:topic:Event::WebM::Communication::Sms::SmsSent" />
		
	</camelContext>

	<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
		<property name="connectionFactory">
			<bean class="com.webmethods.jms.impl.WmConnectionFactoryImpl">
				<property name="BrokerHost" value="localhost:6849" />
				<property name="BrokerName" value="Broker #1" />
				<property name="ClientGroup" value="StressGroup" />
			</bean>
		</property>
	</bean>

	<bean id="etStoreConfig"
	
class="com.softwareag.eda.configuration.beans.FileEventTypeStoreConfigType">
		<property name="location" value="E:/SoftwareAG/common/EventTypeStore" />
	</bean>

	<bean id="edaEventTypeStore"
class="com.softwareag.eda.store.api.EventTypeStoreFactory"
		factory-method="createEventTypeStore" depends-on="etStoreConfig">
		<constructor-arg name="configuration" ref="etStoreConfig"
type="com.softwareag.eda.configuration.beans.EventTypeStoreConfigType"/>
	</bean>	

	<bean id="camelConnector"
class="org.apache.camel.example.spring.CamelConnector">
		<property name="context" ref="camel" />
	</bean>

	<bean id="eventTypeID" class="com.softwareag.eda.store.api.EDAEventTypeID">
		<constructor-arg name="namespace"
value="http://namespaces.softwareag.com/EDA/WebM/Communication/Sms"/>
		<constructor-arg name="name" value="SmsSent"/>
	</bean>

	<bean id="edaOrchestratorCamel"
class="com.softwareag.eda.orchestrator.impl.EDAOrchestratorImpl"
depends-on="camelConnector, edaEventTypeStore">
		<constructor-arg name="connector" ref="camelConnector"
type="com.softwareag.eda.connector.EventBusConnector"/>
		<constructor-arg name="eventTypeStore" ref="edaEventTypeStore"
type="com.softwareag.eda.store.api.EDAEventTypeStore"/>
	</bean>

	<bean id="streamConfiguration" class="java.io.FileInputStream" >
		<constructor-arg value="C:/edaconfig/edaConfig.xml"
type="java.lang.String"/>
	</bean>

	<bean id="edaOrchestratorCustom"
class="com.softwareag.eda.orchestrator.api.EDAOrchestratorFactory"
factory-method="createOrchestrator" depends-on="streamConfiguration">
		<constructor-arg ref="streamConfiguration" type="java.io.InputStream"/>
	</bean>
	

	<bean id="testClient" class="org.apache.camel.example.spring.TestClient"
		init-method="init" depends-on="edaOrchestratorCamel,
edaOrchestratorCustom">
		<property name="orchestratorCamel" ref="edaOrchestratorCamel" />
		<property name="orchestratorCustom" ref="edaOrchestratorCustom" />
		<property name="edaEventTypeID" ref="eventTypeID" />
	</bean>

</beans>


--
View this message in context: http://camel.465427.n5.nabble.com/Performance-issue-with-Camel-JMS-publish-subscribe-tp5049909p5049909.html
Sent from the Camel - Users mailing list archive at Nabble.com.