Results 1 to 5 of 5

Thread: publish-subscribe-channel causing out of memory error

  1. #1

    Default publish-subscribe-channel causing out of memory error

    I have a publish-subscribe-channel as defined below.

    Code:
    <task:executor id="my-subscbr-pool" pool-size="1"/>
    	
    <!--  All Messages will published on this channel.   -->
    <publish-subscribe-channel id="myChannel" task-executor="my-subscbr-pool"/>
    Subscriber takes around 5-30 seconds to process each message that is received on the channel. When publisher sends hundreds of messages am getting OutOfMemory error.

    I do not see a way of defining 'capacity' for this channel. How do you specify capacity? What are the other ways of implementing this?

    If channel reaches the capacity can SI block the sender (publisher) thread until space is available?

    Thanks
    Last edited by pgondi; Oct 4th, 2011 at 10:55 AM.

  2. #2
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    pub-sub channel does nopt have capacity because it is not a buffering channel. Its a direct hand-off. In other words messages never accumulate in the pub-sub channel, so it can not possibly cause OME
    Also, if you have that many messages why are you using single thread in your config?

  3. #3
    Join Date
    Jan 2008
    Location
    Mohnton, PA USA (that's near Philadelphia)
    Posts
    2,148

    Default

    Also, your OME is probably because of your task-executor configuration. Your task-executor currently is configured with 1 thread and unlimited queue size (default) and no rejection policy.
    Please read this to for details on how to configure the task-executor and let us know if something is unclear.
    http://static.springsource.org/sprin...cheduling.html

  4. #4
    Join Date
    Oct 2005
    Location
    Boston, MA
    Posts
    2,853

    Default

    Specifically read the section on the "executor" element, and you will see the following:
    By default, the queue is unbounded, but this is rarely the desired configuration, because it can lead to OutOfMemoryErrors if enough tasks are added to that queue while all pool threads are busy.
    The following paragraph then addresses rejection policy options as well.

  5. #5

    Default

    Thanks a lot for quick replies.

    The reason I have thread-pool size as 1 is I have to process them in the order they are received.

    I was under the impression that underlying channel holds the messages. I got what your saying and it makes sense.

    I appreciate your time and help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •