You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2012/08/26 11:47:16 UTC
svn commit: r1377404 - in /camel/branches/camel-2.9.x: ./
components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppPrivateChatProducer.java
Author: davsclaus
Date: Sun Aug 26 09:47:15 2012
New Revision: 1377404
URL: http://svn.apache.org/viewvc?rev=1377404&view=rev
Log:
CAMEL-5526: Fixed concurrency issue under heavy load in xmpp producer. Thanks to Alexander Titov for the patch.
Modified:
camel/branches/camel-2.9.x/ (props changed)
camel/branches/camel-2.9.x/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppPrivateChatProducer.java
Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
Merged /camel/trunk:r1377402
Merged /camel/branches/camel-2.10.x:r1377403
Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: camel/branches/camel-2.9.x/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppPrivateChatProducer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppPrivateChatProducer.java?rev=1377404&r1=1377403&r2=1377404&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppPrivateChatProducer.java (original)
+++ camel/branches/camel-2.9.x/components/camel-xmpp/src/main/java/org/apache/camel/component/xmpp/XmppPrivateChatProducer.java Sun Aug 26 09:47:15 2012
@@ -37,7 +37,7 @@ public class XmppPrivateChatProducer ext
private final XmppEndpoint endpoint;
private XMPPConnection connection;
private final String participant;
-
+
public XmppPrivateChatProducer(XmppEndpoint endpoint, String participant) {
super(endpoint);
this.endpoint = endpoint;
@@ -62,21 +62,7 @@ public class XmppPrivateChatProducer ext
}
ChatManager chatManager = connection.getChatManager();
-
- LOG.trace("Looking for existing chat instance with thread ID {}", endpoint.getChatId());
- Chat chat = chatManager.getThreadChat(endpoint.getChatId());
- if (chat == null) {
- LOG.trace("Creating new chat instance with thread ID {}", endpoint.getChatId());
- chat = chatManager.createChat(getParticipant(), endpoint.getChatId(), new MessageListener() {
- public void processMessage(Chat chat, Message message) {
- // not here to do conversation
- if (LOG.isDebugEnabled()) {
- LOG.debug("Received and discarding message from {} : {}", getParticipant(), message.getBody());
- }
- }
- });
- }
-
+ Chat chat = getOrCreateChat(chatManager);
Message message = null;
try {
message = new Message();
@@ -98,6 +84,28 @@ public class XmppPrivateChatProducer ext
+ " to: " + XmppEndpoint.getConnectionMessage(connection), exchange, e);
}
}
+
+ private synchronized Chat getOrCreateChat(ChatManager chatManager) {
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Looking for existing chat instance with thread ID {}", endpoint.getChatId());
+ }
+ Chat chat = chatManager.getThreadChat(endpoint.getChatId());
+ if (chat == null) {
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Creating new chat instance with thread ID {}", endpoint.getChatId());
+ }
+ chat = chatManager.createChat(getParticipant(), endpoint.getChatId(), new MessageListener() {
+ public void processMessage(Chat chat, Message message) {
+ // not here to do conversation
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Received and discarding message from {} : {}"
+ , getParticipant(), message.getBody());
+ }
+ }
+ });
+ }
+ return chat;
+ }
@Override
protected void doStart() throws Exception {