Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: Is it possible to give a custom scope to a direct channel? (no subscriber issue)

  1. #11
    Join Date
    Aug 2011
    Location
    Belgium
    Posts
    23

    Default

    Oleg,

    That's correct. The message carries a header containing a unique piece of data which can be used to determine the destination thread.

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

    Default

    Thanks, and the other question is are you storing something in thread local? I mean can the same thread be shared by more then one Messages, as long as its the same thread?

  3. #13
    Join Date
    Aug 2011
    Location
    Belgium
    Posts
    23

    Default

    The only thing I store is an InheritableThreadLocal which contains the same value for all Messages which are processed by the same thread.

    An example. Suppose we have incoming messages on different working threads. On the worker thread, I create a threadlocal containing the value for the 'destination' header ( I do this because we apply a security check on these threads, and the security setup is related to the 'destination'.)

    All messages on the worker threads are then routed to their single 'dedicated thread', the threadlocal variable is passed to that dedicated thread, but because the routing mechanism only routes threads with the same 'destination' to the dedicated thread, it actually stays the same. But in short: yes, I am storing something in an (inheritable)threadlocal, but this value is always the same and can't and may not be altered.

    Message Message headers Incoming thread Dedicated thread
    MSG-1 destination=dedicatedThread1,.. Worker thread 3 dedicatedThread1
    MSG-2 destination=dedicatedThread2,.. Worker thread 5 dedicatedThread2
    MSG-3 destination=dedicatedThread1,.. Worker thread 9 dedicatedThread1

  4. #14

    Default

    I don't use scoped-proxy. We (ab)use the "invalid scope" for some integration tests, but not in production code.

Tags for this Thread

Posting Permissions

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