Suggested Pages

Tuesday, February 7, 2017

Maven Optional Dependency

Here an example of maven optional usage:

Maven Optional can be described as a dependency that is marked as excluded by default. This means that if your project X depends on a specific library Y that declares a dependency with Z as optional, then your project X does not include Z as library because it is considered optional.

Because of this all the functionalities of Y that does not regard Z can be used normally, but the functionality expressed by Z cannot be used by project X unless X declares a specific dependency on Z.

project Y
       
 
     <dependency>
      <groupId>groupZ</groupId>
      <artifactId>Z</artifactId>
      <version>1.0</version>
      <scope>compile</scope>
     <optional>true</optional>
     </dependency>
As you can see project X should include and direct dependency on Z if the project X needs the functionality of the project Y expressed by project Z. project X
       
  <dependencies> 

     <dependency>
      <groupId>groupY</groupId>
      <artifactId>Y</artifactId>
      <version>1.0</version>
      <scope>compile</scope>
    </dependency>
 
     <dependency>
      <groupId>groupZ</groupId>
      <artifactId>Z</artifactId>
      <version>1.0</version>
      <scope>compile</scope>
       </dependency>

  </dependencies> 

Monday, February 6, 2017

Producer/Consumer Poison Pill

Poison pill is a technique used by a Producer to drug a Consumer in order to communicate the end of trasmission.

This kind of technique is generally used when a Producer and a Consumer share only one pipe for normal communication.

We can consider Poson Pill as a common practice when the pipe between Producer and Consumer is a datatype channel: the same channel is used to exchange different kind of data types between endpoints.

So because the datatype channel is used for different message types, it's usual to divide message into two categories:
- message data types;
- control message data types. 

A Poison Pill is a Control Message Data Type used to communicate the state of the entire channel: the intension of the Producer to stop itself.

Suggested Pages