{{ !articles[0].partner.isSponsoringArticle ? "Platinum" : "Portal" }} Partner
java,enterprise-integration,patterns,design patterns,tips and tricks

When To Use The Chain of Responsabilities Pattern


The pattern chains the receiving objects together, and then passes any request messages from object to object until it reaches an object capable of handling the message. The number and type of handler objects isn’t known a priori, they can be configured dynamically. The chaining mechanism uses recursive composition to allow an unlimited number of handlers to be linked.

Chain of Responsibility simplifies object interconnections. Instead of senders and receivers maintaining references to all candidate receivers, each sender keeps a single reference to the head of the chain, and each receiver keeps a single reference to its immediate successor in the chain.


  •  Reduced coupling
  •  Added flexibility in assigning responsibilities to objects
  •  Allows a set of classes to behave as a whole, because events producedin one class can be sent on to other handler classes within the composite

When to use:

  • More than one object can handle a request, and the handler isn’t known.
  • You want to issue a request to one of several objects without specifying the receiver explicitly.
  • The set of objects that can handle a request should be specified dynamically.


Code samples can be downloaded here.

Published at DZone with permission of {{ articles[0].authors[0].realName }}, DZone MVB. (source)

Opinions expressed by DZone contributors are their own.

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks