1 Reply Latest reply on Jul 28, 2011 8:34 AM by e.gherardini

    Messaging pattern performance issue (synchronized publishMessage)

    Uday Joshi-Oracle
      We are using Incubator Messaging pattern version with Coherence 3.7. While analyzing performance under load, we found that com.oracle.coherence.patterns.messaging.DefaultMessagingSession.publishMessage looks to be the bottleneck. DefaultMessagingSession.publishMessage is synchronized (see below) and if there are concurrent messages to be put in the queue things slow down considerably. In our testing we found that even with 30 or so concurrent client threads sending messages to be put in the mesaging queue does not perform better than DB backed AQ JMS. Wondering if something can be done about this.

      * <p>Publish the message by creating a {@link Message} object and putting it directly into
      * the backing map. See {@link PublishMessageProcessor} for further explanation.</p>
      * <p>This method must be synchronized since we are generating a request id that must be
      * in the order that the {@link PublishMessageProcessor} runs. This id is used to prevent messages
      * from being published twice in the case of a partition fail over. This request id is also used
      * by AbstractSubscriber to verify that messages sent by this publisher arrived in the correct order.</p>
      * @param destinationIdentifier destination identifier
      * @param payload message payload
      public synchronized void publishMessage(Identifier destinationIdentifier,
      Object payload)

      // Invoke the processor to put the message in the cache. Note that the
      // publisherId
      // is used as a key but there is no entry in the map for that key. This
      // will ensure
      // that all messages published by this session (i.e. publisher) go to
      // the same partition
      NamedCache messageCache = CacheFactory.getCache(Message.CACHENAME);
      PublishRequestIdentifier requestId = new PublishRequestIdentifier(this.publisherId, this.requestNumber++);
      messageCache.invoke(this.publisherId, new PublishMessageProcessor(destinationIdentifier, requestId, payload));