<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Un expresso sans sucre &#187; jms</title>
	<atom:link href="http://blog.tartachuc.org/tag/jms/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tartachuc.org</link>
	<description>Java,  Architecture &#38; Methodes agiles par Thomas Recloux</description>
	<lastBuildDate>Wed, 18 Jan 2012 09:30:10 +0000</lastBuildDate>
	<language>fr</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.tartachuc.org' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Un expresso sans sucre &#187; jms</title>
		<link>http://blog.tartachuc.org</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.tartachuc.org/osd.xml" title="Un expresso sans sucre" />
	<atom:link rel='hub' href='http://blog.tartachuc.org/?pushpress=hub'/>
		<item>
		<title>Spring JMS : Augmenter les performances</title>
		<link>http://blog.tartachuc.org/2008/10/29/spring-jms-augmenter-les-performances/</link>
		<comments>http://blog.tartachuc.org/2008/10/29/spring-jms-augmenter-les-performances/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 06:50:27 +0000</pubDate>
		<dc:creator>Thomas Recloux</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[jms]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://blog.tartachuc.org/?p=37</guid>
		<description><![CDATA[A plusieurs occasions, j&#8217;ai eu l&#8217;occasion de conseiller l&#8217;utilisation de Spring JMS car cette API simplifie énormément la manipulation de l&#8217;API JMS qui il faut l&#8217;avouer n&#8217;est vraiment intuitive. En effet l&#8217;API JMS nécessite de manipuler 6 objets (QueueConnectionFactory, QueueConnection, QueueSession, Queue, MessageProducer, TextMessage) pour simplement envoyer un message texte ! Avant de pouvoir utiliser [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.tartachuc.org&amp;blog=23137075&amp;post=37&amp;subd=tartachuc&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A plusieurs occasions, j&#8217;ai eu l&#8217;occasion de conseiller l&#8217;utilisation de <a title="Spring JMS" href="http://static.springframework.org/spring/docs/2.5.x/reference/jms.html">Spring JMS</a> car cette API simplifie énormément la manipulation de l&#8217;<a title="JMS API" href="http://java.sun.com/j2ee/1.4/docs/api/javax/jms/package-summary.html">API JMS</a> qui il faut l&#8217;avouer n&#8217;est vraiment intuitive.</p>
<p>En effet l&#8217;API JMS nécessite de manipuler 6 objets (QueueConnectionFactory, QueueConnection, QueueSession, Queue, MessageProducer, TextMessage) pour simplement envoyer un message texte !</p>
<p>Avant de pouvoir utiliser l&#8217;api Spring JMS, il faut configurer une ConnectionFactory  (Exemple avec Active MQ) :<br />
<code><br />
&lt;bean name="activeMqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory"&gt;<br />
&lt;property name="brokerURL" value="tcp://theactivemqserver:61616" /&gt;<br />
&lt;/bean&gt;</code></p>
<p>Ensuite, il faut récupérer un objet <a title="JmsTemplate" href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jms/core/JmsTemplate.html">JmsTemplate</a> dans lequel la <a title="ConnectionFactory" href="http://java.sun.com/j2ee/1.4/docs/api/javax/jms/ConnectionFactory.html">ConnectionFactory </a>aura été injectée.</p>
<p>Enfin, l&#8217;envoi d&#8217;un message peut se faire de différentes manières mais un simple appel de la méthode <a title="convertAndSend" href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jms/core/JmsTemplate.html#convertAndSend(java.lang.String,%20java.lang.Object)">convertAndSend</a> pourra suffir.</p>
<p>Il se trouve que par défaut le JmsTemplate peut limiter les performances des applications car il entraine la création des objets Connection, Session et MessageProducer pour chaque envoi.</p>
<p>La solution peut se trouver du coté du provider JMS qui comme ActiveMQ peut proposer une <a title="PooledConnectionFactory" href="http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/pool/PooledConnectionFactory.html">ConnectionFactory</a> adaptée en gérant un pool d&#8217;objets Connection, Session  et MessageProducer.</p>
<p>La solution peut aussi venir d&#8217;un objet fourni par Spring depuis la V2.5.3 : <a title="CachingConnectionFactory" href="http://static.springframework.org/spring/docs/2.5.x/api/org/springframework/jms/connection/CachingConnectionFactory.html">CachingConnectionFactory</a> cette ConnectionFactory peut encapsuler n&#8217;importe quelle autre ConnectionFactory et mettre en place le cache de Connection, Session et MessageProducer.</p>
<p>Dans mon cas, l&#8217;utilisation de la CachingConnectionFactory a résolu nos problèmes. Un profiling de l&#8217;application avait montré que nos Threads passait leur temps à ouvrir des Session JMS.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/tartachuc.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/tartachuc.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/tartachuc.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/tartachuc.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/tartachuc.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/tartachuc.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/tartachuc.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/tartachuc.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/tartachuc.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/tartachuc.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/tartachuc.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/tartachuc.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/tartachuc.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/tartachuc.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.tartachuc.org&amp;blog=23137075&amp;post=37&amp;subd=tartachuc&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.tartachuc.org/2008/10/29/spring-jms-augmenter-les-performances/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/19b0cd2457923995444d0e963cf799bd?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96&#38;r=G" medium="image">
			<media:title type="html">trecloux</media:title>
		</media:content>
	</item>
	</channel>
</rss>
